summaryrefslogtreecommitdiffstats
path: root/meta/lib/patchtest/tests/test_mbox.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/patchtest/tests/test_mbox.py')
-rw-r--r--meta/lib/patchtest/tests/test_mbox.py69
1 files changed, 46 insertions, 23 deletions
diff --git a/meta/lib/patchtest/tests/test_mbox.py b/meta/lib/patchtest/tests/test_mbox.py
index 895ffde42b..c0f9970686 100644
--- a/meta/lib/patchtest/tests/test_mbox.py
+++ b/meta/lib/patchtest/tests/test_mbox.py
@@ -6,15 +6,15 @@
6 6
7import base 7import base
8import collections 8import collections
9import patterns 9import patchtest_patterns
10import pyparsing 10import pyparsing
11import re 11import re
12import subprocess 12import subprocess
13from data import PatchTestInput 13from patchtest_parser import PatchtestParser
14 14
15def headlog(): 15def headlog():
16 output = subprocess.check_output( 16 output = subprocess.check_output(
17 "cd %s; git log --pretty='%%h#%%aN#%%cD:#%%s' -1" % PatchTestInput.repodir, 17 "cd %s; git log --pretty='%%h#%%aN#%%cD:#%%s' -1" % PatchtestParser.repodir,
18 universal_newlines=True, 18 universal_newlines=True,
19 shell=True 19 shell=True
20 ) 20 )
@@ -45,11 +45,13 @@ class TestMbox(base.Base):
45 def test_signed_off_by_presence(self): 45 def test_signed_off_by_presence(self):
46 for commit in self.commits: 46 for commit in self.commits:
47 # 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
48 if patterns.mbox_revert_shortlog_regex.search_string(commit.shortlog): 48 if patchtest_patterns.mbox_revert_shortlog_regex.search_string(commit.shortlog):
49 continue 49 continue
50 if not patterns.signed_off_by.search_string(commit.payload): 50 if not patchtest_patterns.signed_off_by.search_string(commit.payload):
51 self.fail('Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"', 51 self.fail(
52 commit=commit) 52 'Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"',
53 commit=commit,
54 )
53 55
54 def test_shortlog_format(self): 56 def test_shortlog_format(self):
55 for commit in self.commits: 57 for commit in self.commits:
@@ -61,7 +63,7 @@ class TestMbox(base.Base):
61 if shortlog.startswith('Revert "'): 63 if shortlog.startswith('Revert "'):
62 continue 64 continue
63 try: 65 try:
64 patterns.shortlog.parseString(shortlog) 66 patchtest_patterns.shortlog.parseString(shortlog)
65 except pyparsing.ParseException as pe: 67 except pyparsing.ParseException as pe:
66 self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"', 68 self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"',
67 commit=commit) 69 commit=commit)
@@ -73,22 +75,34 @@ class TestMbox(base.Base):
73 if shortlog.startswith('Revert "'): 75 if shortlog.startswith('Revert "'):
74 continue 76 continue
75 l = len(shortlog) 77 l = len(shortlog)
76 if l > patterns.mbox_shortlog_maxlength: 78 if l > patchtest_patterns.mbox_shortlog_maxlength:
77 self.fail('Edit shortlog so that it is %d characters or less (currently %d characters)' % (patterns.mbox_shortlog_maxlength, l), 79 self.fail(
78 commit=commit) 80 "Edit shortlog so that it is %d characters or less (currently %d characters)"
81 % (patchtest_patterns.mbox_shortlog_maxlength, l),
82 commit=commit,
83 )
79 84
80 def test_series_merge_on_head(self): 85 def test_series_merge_on_head(self):
81 self.skip("Merge test is disabled for now") 86 self.skip("Merge test is disabled for now")
82 if PatchTestInput.repo.patch.branch != "master": 87 if PatchtestParser.repo.patch.branch != "master":
83 self.skip( 88 self.skip(
84 "Skipping merge test since patch is not intended" 89 "Skipping merge test since patch is not intended"
85 " for master branch. Target detected is %s" 90 " for master branch. Target detected is %s"
86 % PatchTestInput.repo.patch.branch 91 % PatchtestParser.repo.patch.branch
87 ) 92 )
88 if not PatchTestInput.repo.canbemerged: 93 if not PatchtestParser.repo.canbemerged:
89 commithash, author, date, shortlog = headlog() 94 commithash, author, date, shortlog = headlog()
90 self.fail('Series does not apply on top of target branch %s' % PatchTestInput.repo.branch, 95 self.fail(
91 data=[('Targeted branch', '%s (currently at %s)' % (PatchTestInput.repo.branch, commithash))]) 96 "Series does not apply on top of target branch %s"
97 % PatchtestParser.repo.patch.branch,
98 data=[
99 (
100 "Targeted branch",
101 "%s (currently at %s)"
102 % (PatchtestParser.repo.patch.branch, commithash),
103 )
104 ],
105 )
92 106
93 def test_target_mailing_list(self): 107 def test_target_mailing_list(self):
94 """Check for other targeted projects""" 108 """Check for other targeted projects"""
@@ -129,19 +143,28 @@ class TestMbox(base.Base):
129 self.fail('Please include a commit message on your patch explaining the change', commit=commit) 143 self.fail('Please include a commit message on your patch explaining the change', commit=commit)
130 144
131 def test_bugzilla_entry_format(self): 145 def test_bugzilla_entry_format(self):
132 for commit in TestMbox.commits: 146 for commit in self.commits:
133 if not patterns.mbox_bugzilla.search_string(commit.commit_message): 147 if not patchtest_patterns.mbox_bugzilla.search_string(commit.commit_message):
134 self.skip("No bug ID found") 148 self.skip("No bug ID found")
135 elif not patterns.mbox_bugzilla_validation.search_string(commit.commit_message): 149 elif not patchtest_patterns.mbox_bugzilla_validation.search_string(
136 self.fail('Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"', commit=commit) 150 commit.commit_message
151 ):
152 self.fail(
153 'Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"',
154 commit=commit,
155 )
137 156
138 def test_author_valid(self): 157 def test_author_valid(self):
139 for commit in self.commits: 158 for commit in self.commits:
140 for invalid in patterns.invalid_submitters: 159 for invalid in patchtest_patterns.invalid_submitters:
141 if invalid.search_string(commit.author): 160 if invalid.search_string(commit.author):
142 self.fail('Invalid author %s. Resend the series with a valid patch author' % commit.author, commit=commit) 161 self.fail('Invalid author %s. Resend the series with a valid patch author' % commit.author, commit=commit)
143 162
144 def test_non_auh_upgrade(self): 163 def test_non_auh_upgrade(self):
145 for commit in self.commits: 164 for commit in self.commits:
146 if patterns.auh_email in commit.commit_message: 165 if patchtest_patterns.auh_email in commit.commit_message:
147 self.fail('Invalid author %s. Resend the series with a valid patch author' % patterns.auh_email, commit=commit) 166 self.fail(
167 "Invalid author %s. Resend the series with a valid patch author"
168 % patchtest_patterns.auh_email,
169 commit=commit,
170 )