[Patchew-devel] [PATCH 3/4] testing: Don't reset all tests upon git result update

Fam Zheng famz at redhat.com
Thu Aug 2 08:14:21 UTC 2018


Git results move to "PENDING" to get applier redo the apply if replies
have added "reviewed-by" tags etc. The testing mod's event handler
on_result_update cannot tell if this is only adding tags, in which case
re-test is not necessary and may result in duplicated error reports.

Instead, subscribe to TagsUpdate event and handle "Based-on:" tag
specifically.

Signed-off-by: Fam Zheng <famz at redhat.com>
---
 mods/testing.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/mods/testing.py b/mods/testing.py
index ccdd336..164f97d 100644
--- a/mods/testing.py
+++ b/mods/testing.py
@@ -107,13 +107,23 @@ class TestingModule(PatchewModule):
                       is_timeout="whether the test has timeout")
         register_handler("SetProperty", self.on_set_property)
         register_handler("ResultUpdate", self.on_result_update)
+        register_handler("TagsUpdate", self.on_tags_update)
+
+    def on_tags_update(self, evt, series, old, new):
+        def find_tag(tags, t):
+            for i in tags:
+                if i.lower().startswith(t.lower()):
+                    return i
+        old_base = find_tag(old, "Based-on:")
+        new_base = find_tag(new, "Based-on:")
+        if old_base != new_base:
+            self.clear_and_start_testing(series)
 
     def on_set_property(self, evt, obj, name, value, old_value):
-        if ((isinstance(obj, Message) and obj.is_series_head) \
-            or isinstance(obj, Project)) \
-            and name in ("git.tag", "git.repo") \
+        if name in ("git.tag", "git.repo") \
             and old_value is None \
             and obj.get_property("git.tag") and obj.get_property("git.repo"):
+                assert isinstance(obj, Project)
                 self.clear_and_start_testing(obj)
         elif isinstance(obj, Project) and name == "git.head" \
             and old_value != value:
@@ -130,7 +140,7 @@ class TestingModule(PatchewModule):
             and old_status != Result.SUCCESS \
             and result.status == result.SUCCESS \
             and result.data.get("tag") and result.data.get("repo"):
-                self.clear_and_start_testing(obj)
+                self.recalc_pending_tests(obj)
 
     def get_testing_results(self, obj, *args, **kwargs):
         return obj.results.filter(name__startswith='testing.', *args, **kwargs)
-- 
2.17.1




More information about the Patchew-devel mailing list