[Patchew-devel] [PATCH 2/3] testing: Recalculate pending tests after disabling tests
Fam Zheng
famz at redhat.com
Thu Nov 1 07:06:13 UTC 2018
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 \
More information about the Patchew-devel
mailing list