summaryrefslogtreecommitdiff
path: root/tools/buildman/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/buildman/main.py')
-rwxr-xr-xtools/buildman/main.py71
1 files changed, 50 insertions, 21 deletions
diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 5e1f68d8235..5f42a58ddbb 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -6,62 +6,91 @@
"""See README for more information"""
-import doctest
-import multiprocessing
+try:
+ from importlib.resources import files
+except ImportError:
+ # for Python 3.6
+ import importlib_resources
import os
-import re
import sys
# Bring in the patman libraries
+# pylint: disable=C0413
our_path = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(1, os.path.join(our_path, '..'))
# Our modules
-from buildman import board
from buildman import bsettings
-from buildman import builder
from buildman import cmdline
from buildman import control
-from buildman import toolchain
-from patman import patchstream
-from patman import gitutil
-from u_boot_pylib import terminal
from u_boot_pylib import test_util
+from u_boot_pylib import tools
-def RunTests(skip_net_tests, verboose, args):
+def run_tests(skip_net_tests, debug, verbose, args):
+ """Run the buildman tests
+
+ Args:
+ skip_net_tests (bool): True to skip tests which need the network
+ debug (bool): True to run in debugging mode (full traceback)
+ verbosity (int): Verbosity level to use (0-4)
+ args (list of str): List of tests to run, empty to run all
+ """
+ # These imports are here since tests are not available when buildman is
+ # installed as a Python module
+ # pylint: disable=C0415
from buildman import func_test
from buildman import test
- import doctest
- test_name = args and args[0] or None
+ test_name = args.terms and args.terms[0] or None
if skip_net_tests:
test.use_network = False
# Run the entry tests first ,since these need to be the first to import the
# 'entry' module.
result = test_util.run_test_suites(
- 'buildman', False, verboose, False, None, test_name, [],
+ 'buildman', debug, verbose, False, args.threads, test_name, [],
[test.TestBuild, func_test.TestFunctional,
'buildman.toolchain', 'patman.gitutil'])
return (0 if result.wasSuccessful() else 1)
+def run_test_coverage():
+ """Run the tests and check that we get 100% coverage"""
+ test_util.run_test_coverage(
+ 'tools/buildman/buildman', None,
+ ['tools/patman/*.py', 'tools/u_boot_pylib/*', '*test_fdt.py',
+ 'tools/buildman/kconfiglib.py', 'tools/buildman/*test*.py',
+ 'tools/buildman/main.py'],
+ '/tmp/b', single_thread='-T1')
+
+
def run_buildman():
- options, args = cmdline.ParseArgs()
+ """Run bulidman
- if not options.debug:
+ This is the main program. It collects arguments and runs either the tests or
+ the control module.
+ """
+ args = cmdline.parse_args()
+
+ if not args.debug:
sys.tracebacklimit = 0
# Run our meagre tests
- if cmdline.HAS_TESTS and options.test:
- RunTests(options.skip_net_tests, options.verbose, args)
+ if cmdline.HAS_TESTS and args.test:
+ return run_tests(args.skip_net_tests, args.debug, args.verbose, args)
+
+ elif cmdline.HAS_TESTS and args.coverage:
+ run_test_coverage()
+
+ elif args.full_help:
+ tools.print_full_help(str(files('buildman').joinpath('README.rst')))
# Build selected commits for selected boards
else:
- bsettings.Setup(options.config_file)
- ret_code = control.DoBuildman(options, args)
- sys.exit(ret_code)
+ bsettings.setup(args.config_file)
+ ret_code = control.do_buildman(args)
+ return ret_code
if __name__ == "__main__":
- run_buildman()
+ sys.exit(run_buildman())