diff mbox series

[patchtest-oe] test_mbox_signed_off_by: fix test

Message ID 20230612173114.994426-1-tgamblin@baylibre.com
State New
Headers show
Series [patchtest-oe] test_mbox_signed_off_by: fix test | expand

Commit Message

Trevor Gamblin June 12, 2023, 5:31 p.m. UTC
This fixes a consistent issue with false failures being reported when
testing for authors' signed-off-bys in mboxes. Instead of manually
compiling a regex pattern, use pyparsing's AtLineStart to check for the
signature's presence at the beginning of the line.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 tests/pyparsing/parse_signed_off_by.py | 4 ++--
 tests/test_mbox_signed_off_by.py       | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/tests/pyparsing/parse_signed_off_by.py b/tests/pyparsing/parse_signed_off_by.py
index fc39a6c..9338c49 100644
--- a/tests/pyparsing/parse_signed_off_by.py
+++ b/tests/pyparsing/parse_signed_off_by.py
@@ -30,5 +30,5 @@  email = pyparsing.Regex(r"(?P<user>[A-Za-z0-9._%+-]+)@(?P<hostname>[A-Za-z0-9.-]
 
 email_enclosed = common.lessthan + email + common.greaterthan
 
-signed_off_by_mark = pyparsing.Literal("Signed-off-by")
-signed_off_by = common.start + signed_off_by_mark + common.colon + name + email_enclosed + common.end
+signed_off_by_mark = pyparsing.Literal("Signed-off-by:")
+signed_off_by = pyparsing.AtLineStart(signed_off_by_mark + name + email_enclosed)
diff --git a/tests/test_mbox_signed_off_by.py b/tests/test_mbox_signed_off_by.py
index e50bb8e..eae2816 100644
--- a/tests/test_mbox_signed_off_by.py
+++ b/tests/test_mbox_signed_off_by.py
@@ -28,15 +28,14 @@  class SignedOffBy(base.Base):
     @classmethod
     def setUpClassLocal(cls):
         # match self.mark with no '+' preceding it
-        cls.mark = str(parse_signed_off_by.signed_off_by_mark).strip('"')
-        cls.prog = re.compile("(?<!\+)%s" % cls.mark)
+        cls.prog = parse_signed_off_by.signed_off_by
 
     def test_signed_off_by_presence(self):
         for commit in SignedOffBy.commits:
             # skip those patches that revert older commits, these do not required the tag presence
             if self.revert_shortlog_regex.match(commit.shortlog):
                 continue
-            if not SignedOffBy.prog.search(commit.payload):
+            if not SignedOffBy.prog.search_string(commit.payload):
                 self.fail('Patch is missing Signed-off-by',
                           'Sign off the patch (either manually or with "git commit --amend -s")',
                           commit)