diff mbox series

[05/11] patchtest: fix branch applicability reporting

Message ID 20260514194207.1958325-6-tgamblin@baylibre.com
State New
Headers show
Series patchtest: improve testing coverage | expand

Commit Message

Trevor Gamblin May 14, 2026, 7:42 p.m. UTC
There are two issues with how patchtest reports results for testing a
patch series:

1. When a target branch mismatch is detected, it reports (for example)
   "scarthgap 50/71" as the target branch instead of just "scarthgap";
2. It doesn't report the full shortlog for a commit which fails to
   apply, as expected.

Fix both issues, but make sure that we only print shortlogs for patches
which fail to apply if there's more than one actual commit being tested,
as otherwise the patch failing to merge is obvious.

AI-Generated: Uses Claude Code

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 meta/lib/patchtest/mbox.py            | 5 ++++-
 meta/lib/patchtest/tests/test_mbox.py | 2 +-
 scripts/patchtest                     | 5 ++++-
 3 files changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/patchtest/mbox.py b/meta/lib/patchtest/mbox.py
index 400d73f19f..2342fbda65 100644
--- a/meta/lib/patchtest/mbox.py
+++ b/meta/lib/patchtest/mbox.py
@@ -70,7 +70,10 @@  class PatchSeries:
         # Parse each [tag] in the subject individually
         tags = re.findall(r'\[([^\[\]]*)\]', self.patches[0].subject)
         valid_branches = [t.strip() for t in tags if PatchSeries.valid_branch(t.strip())]
-        return valid_branches[0] if valid_branches else None
+        if not valid_branches:
+            return None
+        # Strip trailing series position, e.g. "scarthgap 50/71" -> "scarthgap"
+        return re.sub(r'\s+\d+/\d+$', '', valid_branches[0])
 
     @staticmethod
     def valid_branch(branch):
diff --git a/meta/lib/patchtest/tests/test_mbox.py b/meta/lib/patchtest/tests/test_mbox.py
index f158f4472c..a216028250 100644
--- a/meta/lib/patchtest/tests/test_mbox.py
+++ b/meta/lib/patchtest/tests/test_mbox.py
@@ -89,7 +89,7 @@  class TestMbox(base.Base):
         if failures:
             self.fail(
                 'One or more patches in the series do not apply cleanly',
-                data=[('Patch', subject) for subject, _ in failures],
+                data=[('Patch', subject) for subject, _ in failures] if len(results) > 1 else None,
             )
 
     def test_target_mailing_list(self):
diff --git a/scripts/patchtest b/scripts/patchtest
index 435610b54f..f359a6a96d 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -90,8 +90,11 @@  def make_result_class(patch, mergepatch, logfile=None):
         def addFailure(self, test, err):
             self.test_failure = True
             desc = _format_test_description(test)
-            issue = json.loads(str(err[1]))["issue"]
+            parsed = json.loads(str(err[1]))
+            issue = parsed["issue"]
             _emit('{}: {}: {} ({})'.format(self.fail, desc, issue, test.id()), logfile)
+            for key, val in parsed.get('data') or []:
+                _emit('    {}: {}'.format(key, val), logfile)
 
         def addSuccess(self, test):
             desc = _format_test_description(test)