summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-02-24 04:18:19 +0300
committerSimon Glass <sjg@chromium.org>2023-03-08 22:40:56 +0300
commit94bb5cd2f9960baa724976a44303067dd4654b2e (patch)
tree42108928938001549c1f2f1b56b31f2d197e6eca /tools
parent952a61adb4537843855e2c35a57646c25abc6128 (diff)
downloadu-boot-94bb5cd2f9960baa724976a44303067dd4654b2e.tar.xz
binman: Hide the 'test' command unless test code is available
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@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/cmdline.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 4eed3073dc..54926adb09 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -9,6 +9,11 @@ import argparse
from argparse import ArgumentParser
import os
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
@@ -167,23 +172,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)