mirror of
https://git.yoctoproject.org/poky
synced 2026-07-17 04:07:06 +00:00
patchtest: simplify, rename modules
- simplify base.py, data.py - move some leftover regex patterns to patterns.py - remove pyparsing path logic, since this is no longer needed - rename PatchTestInput class to PatchtestParser - data.py: rename to patchtest_parser.py - patterns.py: rename to patchtest_patterns.py - move PatchTestDataStore to test_metadata.py since that's the only place it's used - remove unused logger code (From OE-Core rev: 1e971b05b036b0b1eb0bdbd9b26b54d06e74294c) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
18a65c77c0
commit
4c378fc895
@@ -6,15 +6,15 @@
|
||||
|
||||
import base
|
||||
import collections
|
||||
import patterns
|
||||
import patchtest_patterns
|
||||
import pyparsing
|
||||
import re
|
||||
import subprocess
|
||||
from data import PatchTestInput
|
||||
from patchtest_parser import PatchtestParser
|
||||
|
||||
def headlog():
|
||||
output = subprocess.check_output(
|
||||
"cd %s; git log --pretty='%%h#%%aN#%%cD:#%%s' -1" % PatchTestInput.repodir,
|
||||
"cd %s; git log --pretty='%%h#%%aN#%%cD:#%%s' -1" % PatchtestParser.repodir,
|
||||
universal_newlines=True,
|
||||
shell=True
|
||||
)
|
||||
@@ -45,11 +45,13 @@ class TestMbox(base.Base):
|
||||
def test_signed_off_by_presence(self):
|
||||
for commit in self.commits:
|
||||
# skip those patches that revert older commits, these do not required the tag presence
|
||||
if patterns.mbox_revert_shortlog_regex.search_string(commit.shortlog):
|
||||
if patchtest_patterns.mbox_revert_shortlog_regex.search_string(commit.shortlog):
|
||||
continue
|
||||
if not patterns.signed_off_by.search_string(commit.payload):
|
||||
self.fail('Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"',
|
||||
commit=commit)
|
||||
if not patchtest_patterns.signed_off_by.search_string(commit.payload):
|
||||
self.fail(
|
||||
'Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"',
|
||||
commit=commit,
|
||||
)
|
||||
|
||||
def test_shortlog_format(self):
|
||||
for commit in self.commits:
|
||||
@@ -61,7 +63,7 @@ class TestMbox(base.Base):
|
||||
if shortlog.startswith('Revert "'):
|
||||
continue
|
||||
try:
|
||||
patterns.shortlog.parseString(shortlog)
|
||||
patchtest_patterns.shortlog.parseString(shortlog)
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"',
|
||||
commit=commit)
|
||||
@@ -73,22 +75,34 @@ class TestMbox(base.Base):
|
||||
if shortlog.startswith('Revert "'):
|
||||
continue
|
||||
l = len(shortlog)
|
||||
if l > patterns.mbox_shortlog_maxlength:
|
||||
self.fail('Edit shortlog so that it is %d characters or less (currently %d characters)' % (patterns.mbox_shortlog_maxlength, l),
|
||||
commit=commit)
|
||||
if l > patchtest_patterns.mbox_shortlog_maxlength:
|
||||
self.fail(
|
||||
"Edit shortlog so that it is %d characters or less (currently %d characters)"
|
||||
% (patchtest_patterns.mbox_shortlog_maxlength, l),
|
||||
commit=commit,
|
||||
)
|
||||
|
||||
def test_series_merge_on_head(self):
|
||||
self.skip("Merge test is disabled for now")
|
||||
if PatchTestInput.repo.patch.branch != "master":
|
||||
if PatchtestParser.repo.patch.branch != "master":
|
||||
self.skip(
|
||||
"Skipping merge test since patch is not intended"
|
||||
" for master branch. Target detected is %s"
|
||||
% PatchTestInput.repo.patch.branch
|
||||
% PatchtestParser.repo.patch.branch
|
||||
)
|
||||
if not PatchTestInput.repo.canbemerged:
|
||||
if not PatchtestParser.repo.canbemerged:
|
||||
commithash, author, date, shortlog = headlog()
|
||||
self.fail('Series does not apply on top of target branch %s' % PatchTestInput.repo.branch,
|
||||
data=[('Targeted branch', '%s (currently at %s)' % (PatchTestInput.repo.branch, commithash))])
|
||||
self.fail(
|
||||
"Series does not apply on top of target branch %s"
|
||||
% PatchtestParser.repo.patch.branch,
|
||||
data=[
|
||||
(
|
||||
"Targeted branch",
|
||||
"%s (currently at %s)"
|
||||
% (PatchtestParser.repo.patch.branch, commithash),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
def test_target_mailing_list(self):
|
||||
"""Check for other targeted projects"""
|
||||
@@ -129,19 +143,28 @@ class TestMbox(base.Base):
|
||||
self.fail('Please include a commit message on your patch explaining the change', commit=commit)
|
||||
|
||||
def test_bugzilla_entry_format(self):
|
||||
for commit in TestMbox.commits:
|
||||
if not patterns.mbox_bugzilla.search_string(commit.commit_message):
|
||||
for commit in self.commits:
|
||||
if not patchtest_patterns.mbox_bugzilla.search_string(commit.commit_message):
|
||||
self.skip("No bug ID found")
|
||||
elif not patterns.mbox_bugzilla_validation.search_string(commit.commit_message):
|
||||
self.fail('Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"', commit=commit)
|
||||
elif not patchtest_patterns.mbox_bugzilla_validation.search_string(
|
||||
commit.commit_message
|
||||
):
|
||||
self.fail(
|
||||
'Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"',
|
||||
commit=commit,
|
||||
)
|
||||
|
||||
def test_author_valid(self):
|
||||
for commit in self.commits:
|
||||
for invalid in patterns.invalid_submitters:
|
||||
for invalid in patchtest_patterns.invalid_submitters:
|
||||
if invalid.search_string(commit.author):
|
||||
self.fail('Invalid author %s. Resend the series with a valid patch author' % commit.author, commit=commit)
|
||||
|
||||
def test_non_auh_upgrade(self):
|
||||
for commit in self.commits:
|
||||
if patterns.auh_email in commit.commit_message:
|
||||
self.fail('Invalid author %s. Resend the series with a valid patch author' % patterns.auh_email, commit=commit)
|
||||
if patchtest_patterns.auh_email in commit.commit_message:
|
||||
self.fail(
|
||||
"Invalid author %s. Resend the series with a valid patch author"
|
||||
% patchtest_patterns.auh_email,
|
||||
commit=commit,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user