From 4c378fc89566a329d0974bbcfefc7405779bc919 Mon Sep 17 00:00:00 2001 From: Trevor Gamblin Date: Tue, 24 Sep 2024 07:55:01 -0400 Subject: 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 Signed-off-by: Richard Purdie --- scripts/patchtest | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'scripts/patchtest') diff --git a/scripts/patchtest b/scripts/patchtest index 3ca8c6e48f..278fc4e6e0 100755 --- a/scripts/patchtest +++ b/scripts/patchtest @@ -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() -- cgit v1.2.3-54-g00ecf