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 /meta/lib/patchtest/data.py | |
| 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 'meta/lib/patchtest/data.py')
| -rw-r--r-- | meta/lib/patchtest/data.py | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/meta/lib/patchtest/data.py b/meta/lib/patchtest/data.py deleted file mode 100644 index 356259921d..0000000000 --- a/meta/lib/patchtest/data.py +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | # | ||
| 4 | # patchtestdata: module used to share command line arguments between | ||
| 5 | # patchtest & test suite and a data store between test cases | ||
| 6 | # | ||
| 7 | # Copyright (C) 2016 Intel Corporation | ||
| 8 | # | ||
| 9 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 10 | # | ||
| 11 | # NOTE: Strictly speaking, unit test should be isolated from outside, | ||
| 12 | # but patchtest test suites uses command line input data and | ||
| 13 | # pretest and test test cases may use the datastore defined | ||
| 14 | # on this module | ||
| 15 | |||
| 16 | import os | ||
| 17 | import argparse | ||
| 18 | import collections | ||
| 19 | import logging | ||
| 20 | |||
| 21 | logger=logging.getLogger('patchtest') | ||
| 22 | info=logger.info | ||
| 23 | |||
| 24 | default_testdir = os.path.abspath(os.path.dirname(__file__) + "/tests") | ||
| 25 | default_repodir = os.path.abspath(os.path.dirname(__file__) + "/../../..") | ||
| 26 | |||
| 27 | # Data store commonly used to share values between pre and post-merge tests | ||
| 28 | PatchTestDataStore = collections.defaultdict(str) | ||
| 29 | |||
| 30 | class PatchTestInput(object): | ||
| 31 | """Abstract the patchtest argument parser""" | ||
| 32 | |||
| 33 | @classmethod | ||
| 34 | def set_namespace(cls): | ||
| 35 | parser = cls.get_parser() | ||
| 36 | parser.parse_args(namespace=cls) | ||
| 37 | |||
| 38 | @classmethod | ||
| 39 | def get_parser(cls): | ||
| 40 | parser = argparse.ArgumentParser() | ||
| 41 | |||
| 42 | target_patch_group = parser.add_mutually_exclusive_group(required=True) | ||
| 43 | |||
| 44 | target_patch_group.add_argument('--patch', metavar='PATCH', dest='patch_path', | ||
| 45 | help='The patch to be tested') | ||
| 46 | |||
| 47 | target_patch_group.add_argument('--directory', metavar='DIRECTORY', dest='patch_path', | ||
| 48 | help='The directory containing patches to be tested') | ||
| 49 | |||
| 50 | parser.add_argument('--repodir', metavar='REPO', | ||
| 51 | default=default_repodir, | ||
| 52 | help="Name of the repository where patch is merged") | ||
| 53 | |||
| 54 | parser.add_argument('--testdir', metavar='TESTDIR', | ||
| 55 | default=default_testdir, | ||
| 56 | help="Directory where test cases are located") | ||
| 57 | |||
| 58 | parser.add_argument('--top-level-directory', '-t', | ||
| 59 | dest='topdir', | ||
| 60 | default=None, | ||
| 61 | help="Top level directory of project (defaults to start directory)") | ||
| 62 | |||
| 63 | parser.add_argument('--pattern', '-p', | ||
| 64 | dest='pattern', | ||
| 65 | default='test*.py', | ||
| 66 | help="Pattern to match test files") | ||
| 67 | |||
| 68 | parser.add_argument('--base-branch', '-b', | ||
| 69 | dest='basebranch', | ||
| 70 | help="Branch name used by patchtest to branch from. By default, it uses the current one.") | ||
| 71 | |||
| 72 | parser.add_argument('--base-commit', '-c', | ||
| 73 | dest='basecommit', | ||
| 74 | help="Commit ID used by patchtest to branch from. By default, it uses HEAD.") | ||
| 75 | |||
| 76 | parser.add_argument('--debug', '-d', | ||
| 77 | action='store_true', | ||
| 78 | help='Enable debug output') | ||
| 79 | |||
| 80 | parser.add_argument('--log-results', | ||
| 81 | action='store_true', | ||
| 82 | help='Enable logging to a file matching the target patch name with ".testresult" appended') | ||
| 83 | |||
| 84 | |||
| 85 | return parser | ||
| 86 | |||
