Skip to content

Commit 6d8c258

Browse files
committed
core.py: add more mbox tests
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent 54f5ee5 commit 6d8c258

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

src/patchtest2/tests/core.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,102 @@ def test_mbox_unidiff_parse_error(target):
8282
result = "FAIL"
8383

8484
return target.subject, result, reason
85+
86+
@patchtest_result
87+
def test_mbox_commit_message_user_tags(target):
88+
"""Test for GitHub-style username tags (@username) in commit messages"""
89+
result = "PASS"
90+
reason = "Mbox includes one or more GitHub-style username tags. Ensure that any '@' symbols are stripped out of usernames"
91+
92+
if patterns.mbox_github_username.search_string(target.commit_message):
93+
result = "FAIL"
94+
95+
return target.subject, result, reason
96+
97+
@patchtest_result
98+
def test_mbox_bugzilla_entry_format(target):
99+
"""Test for proper Bugzilla entry format in commit messages"""
100+
result = "PASS"
101+
reason = None
102+
103+
# Check if there's any bugzilla reference
104+
if not patterns.mbox_bugzilla.search_string(target.commit_message):
105+
result = "SKIP"
106+
reason = "No bug ID found"
107+
elif not patterns.mbox_bugzilla_validation.search_string(target.commit_message):
108+
result = "FAIL"
109+
reason = 'Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"'
110+
111+
return target.subject, result, reason
112+
113+
@patchtest_result
114+
def test_mbox_author_valid(target):
115+
"""Test for valid patch author"""
116+
result = "PASS"
117+
reason = f'Invalid author {target.author}. Resend the series with a valid patch author'
118+
119+
for invalid in patterns.invalid_submitters:
120+
if invalid.search_string(target.author):
121+
result = "FAIL"
122+
break
123+
124+
return target.subject, result, reason
125+
126+
@patchtest_result
127+
def test_mbox_non_auh_upgrade(target):
128+
"""Test that patch is not from AUH (Auto Upgrade Helper)"""
129+
result = "PASS"
130+
reason = f"Invalid author {patterns.auh_email}. Resend the series with a valid patch author"
131+
132+
if patterns.auh_email in target.commit_message:
133+
result = "FAIL"
134+
135+
return target.subject, result, reason
136+
137+
@patchtest_result
138+
def test_mbox_target_mailing_list_meta_project(target):
139+
"""Check for meta-* project tags in subject line"""
140+
result = "PASS"
141+
reason = "Series sent to the wrong mailing list or some patches from the series correspond to different mailing lists"
142+
143+
# Check for meta-* project indicators in subject
144+
project_regex = pyparsing.Regex(r"\[(?P<project>meta-.+)\]")
145+
if project_regex.search_string(target.subject):
146+
result = "FAIL"
147+
148+
return target.subject, result, reason
149+
150+
@patchtest_result
151+
def test_mbox_revert_signed_off_by_exception(target):
152+
"""Skip signed-off-by test for revert commits"""
153+
result = "PASS"
154+
reason = None
155+
156+
# This is a special case that modifies the signed-off-by test behavior
157+
# In the original, revert commits skip the signed-off-by requirement
158+
if patterns.mbox_revert_shortlog_regex.search_string(target.shortlog):
159+
result = "SKIP"
160+
reason = "Revert commits do not require Signed-off-by tags"
161+
elif not patterns.signed_off_by.search_string(target.commit_message):
162+
result = "FAIL"
163+
reason = 'Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"'
164+
165+
return target.subject, result, reason
166+
167+
# Additional helper test that might be useful
168+
@patchtest_result
169+
def test_mbox_shortlog_revert_format(target):
170+
"""Test revert commit shortlog format"""
171+
result = "PASS"
172+
reason = None
173+
174+
if target.shortlog.startswith('Revert "'):
175+
# Could add specific revert format validation here if needed
176+
if not target.shortlog.endswith('"'):
177+
result = "FAIL"
178+
reason = 'Revert commit shortlog should be in format: Revert "original shortlog"'
179+
else:
180+
result = "SKIP"
181+
reason = "Not a revert commit"
182+
183+
return target.subject, result, reason

0 commit comments

Comments
 (0)