[Patchew-devel] [PATCH] testing: update failures when the set of tests changes

Paolo Bonzini posted 1 patch 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew next tags/patchew/20191008091544.5416-1-pbonzini@redhat.com
mods/testing.py | 8 ++++++++
1 file changed, 8 insertions(+)

[Patchew-devel] [PATCH] testing: update failures when the set of tests changes

Posted by Paolo Bonzini 1 week ago
Failures for the project HEAD are cached in a property in order to generate
the project badge quickly.  However, when a test was disabled it was still
being recorded as a failure, causing the badge to show up as red even
after all CI failures were cleaned up.  Fix this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 mods/testing.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mods/testing.py b/mods/testing.py
index b155dc6..7955ca8 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -222,6 +222,14 @@ class TestingModule(PatchewModule):
     def project_recalc_pending_tests(self, project):
         self.recalc_pending_tests(project)
 
+        # Delete failures if their corresponding results do not exist anymore
+        test_dict = self.get_tests(obj)
+        failures = obj.get_property("testing.failures")
+        failures = [r.name
+            for r in self.get_testing_results(obj)
+            if r.name in failures and v.get("enabled", False)]
+        obj.set_property("testing.failures", failures)
+
         # 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
-- 
2.21.0

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel