11import patchtest2 .patterns as patterns
22import pyparsing
33
4+
45class PatchtestResult :
56 def __init__ (self , patch , testname , result , reason ):
67 self .patch = patch
78 self .testname = testname
89 self .result = result
910 self .reason = reason
1011 self .pass_string = f"{ self .result } : { self .testname } on { self .patch } "
11- self .skip_or_fail_string = f"{ self .result } : { self .testname } on { self .patch } ({ self .reason } )"
12+ self .skip_or_fail_string = (
13+ f"{ self .result } : { self .testname } on { self .patch } ({ self .reason } )"
14+ )
1215
1316 def __str__ (self ):
1417 if self .result == "PASS" :
1518 return self .pass_string
1619 else :
1720 return self .skip_or_fail_string
1821
22+
1923class PatchtestResults :
2024 def __init__ (self , target_repo , series ):
2125 self .target_repo = target_repo
2226 self .series = series
2327 self .mbox_results = dict (
24- [
25- ('signed_off_by' , [test_mbox_signed_off_by_presence (patch ) for
26- patch in self .series .patchdata ]),
27- ('shortlog_format' , [test_mbox_shortlog_format (patch ) for patch
28- in self .series .patchdata ]),
29- ('commit_message_presence' ,
30- [test_mbox_commit_message_presence (patch ) for patch in
31- self .series .patchdata ]),
32- ]
33- )
28+ [
29+ (
30+ "signed_off_by" ,
31+ [
32+ test_mbox_signed_off_by_presence (patch )
33+ for patch in self .series .patchdata
34+ ],
35+ ),
36+ (
37+ "shortlog_format" ,
38+ [
39+ test_mbox_shortlog_format (patch )
40+ for patch in self .series .patchdata
41+ ],
42+ ),
43+ (
44+ "commit_message_presence" ,
45+ [
46+ test_mbox_commit_message_presence (patch )
47+ for patch in self .series .patchdata
48+ ],
49+ ),
50+ ]
51+ )
3452
3553 def print_mbox_results (self , tag ):
3654 for testresult in self .mbox_results [tag ]:
3755 print (testresult )
3856
57+
3958# test_for_pattern()
4059# @pattern: a pyparsing regex object
4160# @string: a string (patch subject, commit message, author, etc. to
@@ -46,15 +65,13 @@ def test_for_pattern(pattern, string):
4665 else :
4766 return "FAIL"
4867
68+
4969def test_mbox_signed_off_by_presence (target ):
5070 test_name = "test_mbox_signed_off_by_presence"
51- result = test_for_pattern (patterns .signed_off_by ,
52- target .commit_message )
71+ result = test_for_pattern (patterns .signed_off_by , target .commit_message )
5372 reason = "mbox was missing a signed-off-by tag"
54- return PatchtestResult (target .subject ,
55- test_name ,
56- result ,
57- reason )
73+ return PatchtestResult (target .subject , test_name , result , reason )
74+
5875
5976def test_mbox_shortlog_format (target ):
6077 test_name = "test_mbox_shortlog_format"
@@ -74,10 +91,8 @@ def test_mbox_shortlog_format(target):
7491 result = "FAIL"
7592 reason = 'Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"'
7693
77- return PatchtestResult (target .subject ,
78- test_name ,
79- result ,
80- reason )
94+ return PatchtestResult (target .subject , test_name , result , reason )
95+
8196
8297def test_mbox_commit_message_presence (target ):
8398 test_name = "test_mbox_commit_message_presence"
@@ -86,10 +101,7 @@ def test_mbox_commit_message_presence(target):
86101
87102 # Check to see if there is content before the signoff
88103 match = patterns .endcommit_messages_regex .search (target .commit_message )
89- if not target .commit_message [:match .start ()]:
104+ if not target .commit_message [: match .start ()]:
90105 result = "FAIL"
91106
92- return PatchtestResult (target .subject ,
93- test_name ,
94- result ,
95- reason )
107+ return PatchtestResult (target .subject , test_name , result , reason )
0 commit comments