Skip to content

Commit e933d82

Browse files
committed
patchtest2/tests: add test_mbox_shortlog_length, run black
Signed-off-by: Trevor Gamblin <[email protected]>
1 parent 6fa7974 commit e933d82

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/patchtest2/tests/core.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def __init__(self, target_repo, series):
3636
"shortlog_format",
3737
self._results(test_mbox_shortlog_format),
3838
),
39+
(
40+
"shortlog_length",
41+
self._results(test_mbox_shortlog_length),
42+
),
3943
(
4044
"has_commit_message",
4145
self._results(test_mbox_has_commit_message),
@@ -111,6 +115,24 @@ def test_mbox_shortlog_format(target):
111115
return PatchtestResult(target.subject, test_name, result, reason)
112116

113117

118+
def test_mbox_shortlog_length(target):
119+
shortlog = re.sub("^(\[.*?\])+ ", "", target.shortlog)
120+
shortlog_len = len(shortlog)
121+
test_name = "test_mbox_shortlog_length"
122+
result = "PASS"
123+
reason = f"Edit shortlog so that it is {patterns.mbox_shortlog_maxlength} characters or less (currently {shortlog_len} characters)"
124+
125+
print(target.shortlog)
126+
if shortlog.startswith('Revert "'):
127+
result = "SKIP"
128+
reason = "No need to test revert patches"
129+
else:
130+
if shortlog_len > patterns.mbox_shortlog_maxlength:
131+
result = "FAIL"
132+
133+
return PatchtestResult(target.subject, test_name, result, reason)
134+
135+
114136
def test_mbox_has_commit_message(target):
115137
test_name = "test_mbox_has_commit_message"
116138
result = "PASS"
@@ -129,10 +151,11 @@ def test_mbox_has_commit_message(target):
129151

130152
return PatchtestResult(target.subject, test_name, result, reason)
131153

154+
132155
def test_mbox_unidiff_parse_error(target):
133156
test_name = "test_mbox_unidiff_parse_error"
134157
result = "PASS"
135-
reason = f"Patch \"{target.shortlog}\" contains malformed diff lines."
158+
reason = f'Patch "{target.shortlog}" contains malformed diff lines.'
136159

137160
try:
138161
diff = unidiff.PatchSet.from_string(target.data.as_string())

0 commit comments

Comments
 (0)