summaryrefslogtreecommitdiffstats
path: root/meta/lib/patchtest/patchtest_parser.py
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2024-09-24 07:55:01 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-09-30 17:00:50 +0100
commit4c378fc89566a329d0974bbcfefc7405779bc919 (patch)
tree4175c6d63b024e39dc9a7f02a77f1ff3cab8088f /meta/lib/patchtest/patchtest_parser.py
parent18a65c77c0e729dd1835852336e57ff4922f2674 (diff)
downloadpoky-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/patchtest_parser.py')
-rw-r--r--meta/lib/patchtest/patchtest_parser.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/meta/lib/patchtest/patchtest_parser.py b/meta/lib/patchtest/patchtest_parser.py
new file mode 100644
index 0000000000..2a11cb76c2
--- /dev/null
+++ b/meta/lib/patchtest/patchtest_parser.py
@@ -0,0 +1,78 @@
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
16import os
17import argparse
18
19default_testdir = os.path.abspath(os.path.dirname(__file__) + "/tests")
20default_repodir = os.path.abspath(os.path.dirname(__file__) + "/../../..")
21
22class PatchtestParser(object):
23 """Abstract the patchtest argument parser"""
24
25 @classmethod
26 def set_namespace(cls):
27 parser = cls.get_parser()
28 parser.parse_args(namespace=cls)
29
30 @classmethod
31 def get_parser(cls):
32 parser = argparse.ArgumentParser()
33
34 target_patch_group = parser.add_mutually_exclusive_group(required=True)
35
36 target_patch_group.add_argument('--patch', metavar='PATCH', dest='patch_path',
37 help='The patch to be tested')
38
39 target_patch_group.add_argument('--directory', metavar='DIRECTORY', dest='patch_path',
40 help='The directory containing patches to be tested')
41
42 parser.add_argument('--repodir', metavar='REPO',
43 default=default_repodir,
44 help="Name of the repository where patch is merged")
45
46 parser.add_argument('--testdir', metavar='TESTDIR',
47 default=default_testdir,
48 help="Directory where test cases are located")
49
50 parser.add_argument('--top-level-directory', '-t',
51 dest='topdir',
52 default=None,
53 help="Top level directory of project (defaults to start directory)")
54
55 parser.add_argument('--pattern', '-p',
56 dest='pattern',
57 default='test*.py',
58 help="Pattern to match test files")
59
60 parser.add_argument('--base-branch', '-b',
61 dest='basebranch',
62 help="Branch name used by patchtest to branch from. By default, it uses the current one.")
63
64 parser.add_argument('--base-commit', '-c',
65 dest='basecommit',
66 help="Commit ID used by patchtest to branch from. By default, it uses HEAD.")
67
68 parser.add_argument('--debug', '-d',
69 action='store_true',
70 help='Enable debug output')
71
72 parser.add_argument('--log-results',
73 action='store_true',
74 help='Enable logging to a file matching the target patch name with ".testresult" appended')
75
76
77 return parser
78