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:
Trevor Gamblin
2024-09-24 07:55:01 -04:00
committed by Richard Purdie
parent 18a65c77c0
commit 4c378fc895
8 changed files with 234 additions and 131 deletions

View File

@@ -22,7 +22,7 @@ sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
# Include patchtest library
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../meta/lib/patchtest'))
from data import PatchTestInput
from patchtest_parser import PatchtestParser
from repo import PatchTestRepo
logger = logging.getLogger("patchtest")
@@ -47,10 +47,10 @@ def getResult(patch, mergepatch, logfile=None):
def startTestRun(self):
# let's create the repo already, it can be used later on
repoargs = {
'repodir': PatchTestInput.repodir,
'commit' : PatchTestInput.basecommit,
'branch' : PatchTestInput.basebranch,
'patch' : patch,
"repodir": PatchtestParser.repodir,
"commit": PatchtestParser.basecommit,
"branch": PatchtestParser.basebranch,
"patch": patch,
}
self.repo_error = False
@@ -58,7 +58,7 @@ def getResult(patch, mergepatch, logfile=None):
self.test_failure = False
try:
self.repo = PatchTestInput.repo = PatchTestRepo(**repoargs)
self.repo = PatchtestParser.repo = PatchTestRepo(**repoargs)
except:
logger.error(traceback.print_exc())
self.repo_error = True
@@ -129,7 +129,11 @@ def _runner(resultklass, prefix=None):
loader.testMethodPrefix = prefix
# create the suite with discovered tests and the corresponding runner
suite = loader.discover(start_dir=PatchTestInput.testdir, pattern=PatchTestInput.pattern, top_level_dir=PatchTestInput.topdir)
suite = loader.discover(
start_dir=PatchtestParser.testdir,
pattern=PatchtestParser.pattern,
top_level_dir=PatchtestParser.topdir,
)
ntc = suite.countTestCases()
# if there are no test cases, just quit
@@ -173,12 +177,12 @@ def run(patch, logfile=None):
def main():
tmp_patch = False
patch_path = PatchTestInput.patch_path
log_results = PatchTestInput.log_results
patch_path = PatchtestParser.patch_path
log_results = PatchtestParser.log_results
log_path = None
patch_list = None
git_status = os.popen("(cd %s && git status)" % PatchTestInput.repodir).read()
git_status = os.popen("(cd %s && git status)" % PatchtestParser.repodir).read()
status_matches = ["Changes not staged for commit", "Changes to be committed"]
if any([match in git_status for match in status_matches]):
logger.error("patchtest: there are uncommitted changes in the target repo that would be overwritten. Please commit or restore them before running patchtest")
@@ -213,16 +217,16 @@ def main():
if __name__ == '__main__':
ret = 1
# Parse the command line arguments and store it on the PatchTestInput namespace
PatchTestInput.set_namespace()
# Parse the command line arguments and store it on the PatchtestParser namespace
PatchtestParser.set_namespace()
# set debugging level
if PatchTestInput.debug:
if PatchtestParser.debug:
logger.setLevel(logging.DEBUG)
# if topdir not define, default it to testdir
if not PatchTestInput.topdir:
PatchTestInput.topdir = PatchTestInput.testdir
if not PatchtestParser.topdir:
PatchtestParser.topdir = PatchtestParser.testdir
try:
ret = main()