[Patchew-devel] [PATCH v3] testing: Recalculate pending tests after disabling tests

Paolo Bonzini pbonzini at redhat.com
Thu Nov 1 08:19:18 UTC 2018


On 01/11/2018 08:13, Fam Zheng wrote:
> Use Paolo's fix that updates all pending tests when project properties
> change.
> ---
>  mods/testing.py       | 17 +++++++++++++++--
>  tests/test_testing.py | 19 +++++++++++++++++++
>  2 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/mods/testing.py b/mods/testing.py
> index 2d0ed0f..b3e4b07 100644
> --- a/mods/testing.py
> +++ b/mods/testing.py
> @@ -130,7 +130,7 @@ class TestingModule(PatchewModule):
>              self.clear_and_start_testing(obj)
>          elif isinstance(obj, Project) and name.startswith("testing.tests.") \
>              and old_value != value:
> -            self.recalc_pending_tests(obj)
> +            self.project_recalc_pending_tests(obj)
>  
>      def on_result_update(self, evt, obj, old_status, result):
>          if result.name.startswith("testing.") and result.status != old_status:
> @@ -151,8 +151,11 @@ class TestingModule(PatchewModule):
>              and result.data.get("tag") and result.data.get("repo"):
>                  self.clear_and_start_testing(obj)
>  
> +    def filter_testing_results(self, queryset, *args, **kwargs):
> +        return queryset.filter(name__startswith='testing.', *args, **kwargs)
> +
>      def get_testing_results(self, obj, *args, **kwargs):
> -        return obj.results.filter(name__startswith='testing.', *args, **kwargs)
> +        return self.filter_testing_results(obj.results, *args, **kwargs)
>  
>      def get_testing_result(self, obj, name):
>          try:
> @@ -178,6 +181,16 @@ class TestingModule(PatchewModule):
>                  return
>          obj.set_property("testing.done", True)
>  
> +    def project_recalc_pending_tests(self, project):
> +        self.recalc_pending_tests(project)
> +
> +        # Only operate on messages for which testing has not completed yet.
> +        message_ids = self.filter_testing_results(MessageResult.objects,
> +                message__project=project, status=Result.PENDING).values('message_id')
> +        messages = Message.objects.filter(id__in=message_ids)
> +        for obj in messages:
> +            self.recalc_pending_tests(obj)
> +
>      def clear_and_start_testing(self, obj, test=""):
>          for k in list(obj.get_properties().keys()):
>              if k == "testing.done" or \
> diff --git a/tests/test_testing.py b/tests/test_testing.py
> index c9452a4..6e960f1 100755
> --- a/tests/test_testing.py
> +++ b/tests/test_testing.py
> @@ -348,6 +348,25 @@ class TestingResetTest(PatchewTestCase):
>                                    "testing.c": Result.PENDING})
>          self.assertFalse(msg.get_property("testing.done"))
>  
> +class TestingDisableTest(PatchewTestCase):
> +
> +    def setUp(self):
> +        self.create_superuser()
> +
> +        self.repo = self.create_git_repo("repo")
> +
> +        self.p1 = self.add_project("QEMU", "qemu-devel at nongnu.org")
> +        create_test(self.p1, "a")
> +
> +    def test_disable_test(self):
> +        self.cli_login()
> +        self.cli_import('0013-foo-patch.mbox.gz')
> +        self.do_apply()
> +        self.p1.set_property("testing.tests.a.enabled", False)
> +        out, err = self.check_cli(["tester", "-p", "QEMU", "--no-wait"])
> +        self.assertNotIn("Project: QEMU\n", out)
> +        self.cli_logout()
> +
>  # do not run tests on the abstract class
>  del TestingTestCase
>  
> 

Great, thanks for writing the test.  Please apply, I'm officially on
vacation today. :)

Paolo




More information about the Patchew-devel mailing list