diff options
author | Trevor Gamblin <tgamblin@baylibre.com> | 2024-09-24 07:55:01 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-09-30 17:00:50 +0100 |
commit | 4c378fc89566a329d0974bbcfefc7405779bc919 (patch) | |
tree | 4175c6d63b024e39dc9a7f02a77f1ff3cab8088f /scripts/patchtest | |
parent | 18a65c77c0e729dd1835852336e57ff4922f2674 (diff) | |
download | poky-4c378fc89566a329d0974bbcfefc7405779bc919.tar.gz |
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>
Diffstat (limited to 'scripts/patchtest')
-rwxr-xr-x | scripts/patchtest | 34 |
1 files changed, 19 insertions, 15 deletions
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__))) | |||
22 | # Include patchtest library | 22 | # Include patchtest library |
23 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../meta/lib/patchtest')) | 23 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '../meta/lib/patchtest')) |
24 | 24 | ||
25 | from data import PatchTestInput | 25 | from patchtest_parser import PatchtestParser |
26 | from repo import PatchTestRepo | 26 | from repo import PatchTestRepo |
27 | 27 | ||
28 | logger = logging.getLogger("patchtest") | 28 | logger = logging.getLogger("patchtest") |
@@ -47,10 +47,10 @@ def getResult(patch, mergepatch, logfile=None): | |||
47 | def startTestRun(self): | 47 | def startTestRun(self): |
48 | # let's create the repo already, it can be used later on | 48 | # let's create the repo already, it can be used later on |
49 | repoargs = { | 49 | repoargs = { |
50 | 'repodir': PatchTestInput.repodir, | 50 | "repodir": PatchtestParser.repodir, |
51 | 'commit' : PatchTestInput.basecommit, | 51 | "commit": PatchtestParser.basecommit, |
52 | 'branch' : PatchTestInput.basebranch, | 52 | "branch": PatchtestParser.basebranch, |
53 | 'patch' : patch, | 53 | "patch": patch, |
54 | } | 54 | } |
55 | 55 | ||
56 | self.repo_error = False | 56 | self.repo_error = False |
@@ -58,7 +58,7 @@ def getResult(patch, mergepatch, logfile=None): | |||
58 | self.test_failure = False | 58 | self.test_failure = False |
59 | 59 | ||
60 | try: | 60 | try: |
61 | self.repo = PatchTestInput.repo = PatchTestRepo(**repoargs) | 61 | self.repo = PatchtestParser.repo = PatchTestRepo(**repoargs) |
62 | except: | 62 | except: |
63 | logger.error(traceback.print_exc()) | 63 | logger.error(traceback.print_exc()) |
64 | self.repo_error = True | 64 | self.repo_error = True |
@@ -129,7 +129,11 @@ def _runner(resultklass, prefix=None): | |||
129 | loader.testMethodPrefix = prefix | 129 | loader.testMethodPrefix = prefix |
130 | 130 | ||
131 | # create the suite with discovered tests and the corresponding runner | 131 | # create the suite with discovered tests and the corresponding runner |
132 | suite = loader.discover(start_dir=PatchTestInput.testdir, pattern=PatchTestInput.pattern, top_level_dir=PatchTestInput.topdir) | 132 | suite = loader.discover( |
133 | start_dir=PatchtestParser.testdir, | ||
134 | pattern=PatchtestParser.pattern, | ||
135 | top_level_dir=PatchtestParser.topdir, | ||
136 | ) | ||
133 | ntc = suite.countTestCases() | 137 | ntc = suite.countTestCases() |
134 | 138 | ||
135 | # if there are no test cases, just quit | 139 | # if there are no test cases, just quit |
@@ -173,12 +177,12 @@ def run(patch, logfile=None): | |||
173 | 177 | ||
174 | def main(): | 178 | def main(): |
175 | tmp_patch = False | 179 | tmp_patch = False |
176 | patch_path = PatchTestInput.patch_path | 180 | patch_path = PatchtestParser.patch_path |
177 | log_results = PatchTestInput.log_results | 181 | log_results = PatchtestParser.log_results |
178 | log_path = None | 182 | log_path = None |
179 | patch_list = None | 183 | patch_list = None |
180 | 184 | ||
181 | git_status = os.popen("(cd %s && git status)" % PatchTestInput.repodir).read() | 185 | git_status = os.popen("(cd %s && git status)" % PatchtestParser.repodir).read() |
182 | status_matches = ["Changes not staged for commit", "Changes to be committed"] | 186 | status_matches = ["Changes not staged for commit", "Changes to be committed"] |
183 | if any([match in git_status for match in status_matches]): | 187 | if any([match in git_status for match in status_matches]): |
184 | logger.error("patchtest: there are uncommitted changes in the target repo that would be overwritten. Please commit or restore them before running patchtest") | 188 | 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(): | |||
213 | if __name__ == '__main__': | 217 | if __name__ == '__main__': |
214 | ret = 1 | 218 | ret = 1 |
215 | 219 | ||
216 | # Parse the command line arguments and store it on the PatchTestInput namespace | 220 | # Parse the command line arguments and store it on the PatchtestParser namespace |
217 | PatchTestInput.set_namespace() | 221 | PatchtestParser.set_namespace() |
218 | 222 | ||
219 | # set debugging level | 223 | # set debugging level |
220 | if PatchTestInput.debug: | 224 | if PatchtestParser.debug: |
221 | logger.setLevel(logging.DEBUG) | 225 | logger.setLevel(logging.DEBUG) |
222 | 226 | ||
223 | # if topdir not define, default it to testdir | 227 | # if topdir not define, default it to testdir |
224 | if not PatchTestInput.topdir: | 228 | if not PatchtestParser.topdir: |
225 | PatchTestInput.topdir = PatchTestInput.testdir | 229 | PatchtestParser.topdir = PatchtestParser.testdir |
226 | 230 | ||
227 | try: | 231 | try: |
228 | ret = main() | 232 | ret = main() |