diff options
author | Trevor Gamblin <tgamblin@baylibre.com> | 2024-09-24 07:54:58 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-09-30 17:00:50 +0100 |
commit | bb0f1625d7655d04c6df3c144e488f676ff2f762 (patch) | |
tree | 3e3a07f71c4e1950f5e7cc47dbdd1605888d0d16 /meta/lib/patchtest/tests/test_mbox.py | |
parent | dd3a73961b49b508771a8cd579ebf1004f786f12 (diff) | |
download | poky-bb0f1625d7655d04c6df3c144e488f676ff2f762.tar.gz |
patchtest: patterns: add module, refactor
Currently, patchtest has a lot of spread-out definitions for patterns
used in various setup and test functions. Organize these by putting them
all into a new patterns.py module. This allows the tests/pyparsing
directory to be removed, as it is now redundant. Also remove some
definitions where they were duplicated or unused, and perform some
renames to improve readability and avoid collisions. Many of these
variables are composed from others, so the file is only partially
sorted.
(From OE-Core rev: 1ab55d495957918be532a36224b5598c9955a44d)
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/patchtest/tests/test_mbox.py')
-rw-r--r-- | meta/lib/patchtest/tests/test_mbox.py | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/meta/lib/patchtest/tests/test_mbox.py b/meta/lib/patchtest/tests/test_mbox.py index cd76e58a71..e6b8ad21f8 100644 --- a/meta/lib/patchtest/tests/test_mbox.py +++ b/meta/lib/patchtest/tests/test_mbox.py | |||
@@ -6,8 +6,7 @@ | |||
6 | 6 | ||
7 | import base | 7 | import base |
8 | import collections | 8 | import collections |
9 | import parse_shortlog | 9 | import patterns |
10 | import parse_signed_off_by | ||
11 | import pyparsing | 10 | import pyparsing |
12 | import re | 11 | import re |
13 | import subprocess | 12 | import subprocess |
@@ -23,19 +22,6 @@ def headlog(): | |||
23 | 22 | ||
24 | class TestMbox(base.Base): | 23 | class TestMbox(base.Base): |
25 | 24 | ||
26 | auh_email = 'auh@yoctoproject.org' | ||
27 | |||
28 | invalids = [pyparsing.Regex("^Upgrade Helper.+"), | ||
29 | pyparsing.Regex(auh_email), | ||
30 | pyparsing.Regex("uh@not\.set"), | ||
31 | pyparsing.Regex("\S+@example\.com")] | ||
32 | |||
33 | rexp_detect = pyparsing.Regex('\[\s?YOCTO.*\]') | ||
34 | rexp_validation = pyparsing.Regex('\[(\s?YOCTO\s?#\s?(\d+)\s?,?)+\]') | ||
35 | signoff_prog = parse_signed_off_by.signed_off_by | ||
36 | revert_shortlog_regex = pyparsing.Regex('Revert\s+".*"') | ||
37 | maxlength = 90 | ||
38 | |||
39 | # base paths of main yocto project sub-projects | 25 | # base paths of main yocto project sub-projects |
40 | paths = { | 26 | paths = { |
41 | 'oe-core': ['meta-selftest', 'meta-skeleton', 'meta', 'scripts'], | 27 | 'oe-core': ['meta-selftest', 'meta-skeleton', 'meta', 'scripts'], |
@@ -59,9 +45,9 @@ class TestMbox(base.Base): | |||
59 | def test_signed_off_by_presence(self): | 45 | def test_signed_off_by_presence(self): |
60 | for commit in TestMbox.commits: | 46 | for commit in TestMbox.commits: |
61 | # skip those patches that revert older commits, these do not required the tag presence | 47 | # skip those patches that revert older commits, these do not required the tag presence |
62 | if self.revert_shortlog_regex.search_string(commit.shortlog): | 48 | if patterns.mbox_revert_shortlog_regex.search_string(commit.shortlog): |
63 | continue | 49 | continue |
64 | if not self.signoff_prog.search_string(commit.payload): | 50 | if not patterns.signed_off_by.search_string(commit.payload): |
65 | self.fail('Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"', | 51 | self.fail('Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"', |
66 | commit=commit) | 52 | commit=commit) |
67 | 53 | ||
@@ -75,7 +61,7 @@ class TestMbox(base.Base): | |||
75 | if shortlog.startswith('Revert "'): | 61 | if shortlog.startswith('Revert "'): |
76 | continue | 62 | continue |
77 | try: | 63 | try: |
78 | parse_shortlog.shortlog.parseString(shortlog) | 64 | patterns.shortlog.parseString(shortlog) |
79 | except pyparsing.ParseException as pe: | 65 | except pyparsing.ParseException as pe: |
80 | self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"', | 66 | self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"', |
81 | commit=commit) | 67 | commit=commit) |
@@ -87,8 +73,8 @@ class TestMbox(base.Base): | |||
87 | if shortlog.startswith('Revert "'): | 73 | if shortlog.startswith('Revert "'): |
88 | continue | 74 | continue |
89 | l = len(shortlog) | 75 | l = len(shortlog) |
90 | if l > self.maxlength: | 76 | if l > patterns.mbox_shortlog_maxlength: |
91 | self.fail('Edit shortlog so that it is %d characters or less (currently %d characters)' % (self.maxlength, l), | 77 | self.fail('Edit shortlog so that it is %d characters or less (currently %d characters)' % (patterns.mbox_shortlog_maxlength, l), |
92 | commit=commit) | 78 | commit=commit) |
93 | 79 | ||
94 | def test_series_merge_on_head(self): | 80 | def test_series_merge_on_head(self): |
@@ -142,18 +128,18 @@ class TestMbox(base.Base): | |||
142 | 128 | ||
143 | def test_bugzilla_entry_format(self): | 129 | def test_bugzilla_entry_format(self): |
144 | for commit in TestMbox.commits: | 130 | for commit in TestMbox.commits: |
145 | if not self.rexp_detect.search_string(commit.commit_message): | 131 | if not patterns.mbox_bugzilla.search_string(commit.commit_message): |
146 | self.skip("No bug ID found") | 132 | self.skip("No bug ID found") |
147 | elif not self.rexp_validation.search_string(commit.commit_message): | 133 | elif not patterns.mbox_bugzilla_validation.search_string(commit.commit_message): |
148 | self.fail('Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"', commit=commit) | 134 | self.fail('Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"', commit=commit) |
149 | 135 | ||
150 | def test_author_valid(self): | 136 | def test_author_valid(self): |
151 | for commit in self.commits: | 137 | for commit in self.commits: |
152 | for invalid in self.invalids: | 138 | for invalid in patterns.invalid_submitters: |
153 | if invalid.search_string(commit.author): | 139 | if invalid.search_string(commit.author): |
154 | self.fail('Invalid author %s. Resend the series with a valid patch author' % commit.author, commit=commit) | 140 | self.fail('Invalid author %s. Resend the series with a valid patch author' % commit.author, commit=commit) |
155 | 141 | ||
156 | def test_non_auh_upgrade(self): | 142 | def test_non_auh_upgrade(self): |
157 | for commit in self.commits: | 143 | for commit in self.commits: |
158 | if self.auh_email in commit.commit_message: | 144 | if patterns.auh_email in commit.commit_message: |
159 | self.fail('Invalid author %s. Resend the series with a valid patch author' % self.auh_email, commit=commit) | 145 | self.fail('Invalid author %s. Resend the series with a valid patch author' % patterns.auh_email, commit=commit) |