[PATCH v2 19/24] binman: Hide the 'test' command unless test code is available
Simon Glass
sjg at chromium.org
Fri Feb 24 02:18:19 CET 2023
It doesn't make much sense to expose tests when dtoc is running
outside of the U-Boot git checkout. Hide the option in this case.
Fix a long line while we are here.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/binman/cmdline.py | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 986d6f1a315..ef6a05dac15 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -8,6 +8,11 @@
import argparse
from argparse import ArgumentParser
from binman import state
+import os
+import pathlib
+
+BINMAN_DIR = pathlib.Path(__file__).parent
+HAS_TESTS = (BINMAN_DIR / "ftest.py").exists()
def make_extract_parser(subparsers):
"""make_extract_parser: Make a subparser for the 'extract' command
@@ -163,23 +168,26 @@ controlled by a description in the board device tree.'''
replace_parser.add_argument('paths', type=str, nargs='*',
help='Paths within file to replace (wildcard)')
- test_parser = subparsers.add_parser('test', help='Run tests')
- test_parser.add_argument('-P', '--processes', type=int,
- help='set number of processes to use for running tests')
- test_parser.add_argument('-T', '--test-coverage', action='store_true',
- default=False, help='run tests and check for 100%% coverage')
- test_parser.add_argument('-X', '--test-preserve-dirs', action='store_true',
- help='Preserve and display test-created input directories; also '
- 'preserve the output directory if a single test is run (pass test '
- 'name at the end of the command line')
- test_parser.add_argument('tests', nargs='*',
- help='Test names to run (omit for all)')
+ if HAS_TESTS:
+ test_parser = subparsers.add_parser('test', help='Run tests')
+ test_parser.add_argument('-P', '--processes', type=int,
+ help='set number of processes to use for running tests')
+ test_parser.add_argument('-T', '--test-coverage', action='store_true',
+ default=False, help='run tests and check for 100%% coverage')
+ test_parser.add_argument(
+ '-X', '--test-preserve-dirs', action='store_true',
+ help='Preserve and display test-created input directories; also '
+ 'preserve the output directory if a single test is run (pass '
+ 'test name at the end of the command line')
+ test_parser.add_argument('tests', nargs='*',
+ help='Test names to run (omit for all)')
tool_parser = subparsers.add_parser('tool', help='Check bintools')
tool_parser.add_argument('-l', '--list', action='store_true',
help='List all known bintools')
- tool_parser.add_argument('-f', '--fetch', action='store_true',
- help='fetch a bintool from a known location (or: all/missing)')
+ tool_parser.add_argument(
+ '-f', '--fetch', action='store_true',
+ help='fetch a bintool from a known location (or: all/missing)')
tool_parser.add_argument('bintools', type=str, nargs='*')
return parser.parse_args(argv)
--
2.39.2.637.g21b0678d19-goog
More information about the U-Boot
mailing list