Signed-off-by: Fam Zheng <famz@redhat.com>
---
mods/testing.py | 6 ++++++
tests/test_testing.py | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/mods/testing.py b/mods/testing.py
index 2d0ed0f..44e8822 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -453,6 +453,12 @@ class TestingGetView(APILoginRequiredView):
# Shouldn't happen, but let's protect against it
if not t:
continue
+ if not t.get("enabled"):
+ if isinstance(r, MessageResult):
+ _instance.recalc_pending_tests(r.message)
+ else:
+ _instance.recalc_pending_tests(r.project)
+ continue
reqs = t.get("requirements", "")
for req in [x.strip() for x in reqs.split(",") if x]:
if req not in capabilities:
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@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
--
2.17.2
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
On 31/10/2018 02:24, Fam Zheng wrote: > continue > + if not t.get("enabled"): > + if isinstance(r, MessageResult): > + _instance.recalc_pending_tests(r.message) > + else: > + _instance.recalc_pending_tests(r.project) > + continue This can just use r.obj. However, I think the bug is that on_set_property should also iterate over all PENDING tests for the messages, as in the attached patch. Paolo _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel
On Wed, 10/31 13:34, Paolo Bonzini wrote: > On 31/10/2018 02:24, Fam Zheng wrote: > > continue > > + if not t.get("enabled"): > > + if isinstance(r, MessageResult): > > + _instance.recalc_pending_tests(r.message) > > + else: > > + _instance.recalc_pending_tests(r.project) > > + continue > > This can just use r.obj. > > However, I think the bug is that on_set_property should also iterate > over all PENDING tests for the messages, as in the attached patch. Good idea, I'll resend this one. Fam > > Paolo > > diff --git a/mods/testing.py b/mods/testing.py > index 2e1124a..441f1b8 100644 > --- a/mods/testing.py > +++ b/mods/testing.py > @@ -124,7 +124,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: > @@ -145,8 +145,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: > @@ -172,6 +175,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 \ _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel
© 2016 - 2024 Red Hat, Inc.