diff mbox series

[v5,09/13] buildman: Make use of test_util

Message ID 20220122050728.v5.9.I1431105e24e0092261503db116522570c95021a6@changeid
State Accepted
Commit d10dc4028373a177b006283b93d5c245428fe774
Delegated to: Tom Rini
Headers show
Series kconfig: Add some new macros | expand

Commit Message

Simon Glass Jan. 22, 2022, 12:07 p.m. UTC
Use test_util to run the tests, with the ability to select a single test
to run, if desired.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/buildman/main.py | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

Comments

Tom Rini Feb. 9, 2022, 4:38 p.m. UTC | #1
On Sat, Jan 22, 2022 at 05:07:30AM -0700, Simon Glass wrote:

> Use test_util to run the tests, with the ability to select a single test
> to run, if desired.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 04698ce9e50..c6af311a69b 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -27,30 +27,26 @@  from buildman import toolchain
 from patman import patchstream
 from patman import gitutil
 from patman import terminal
+from patman import test_util
 
-def RunTests(skip_net_tests):
+def RunTests(skip_net_tests, verboose, args):
     import func_test
     import test
     import doctest
 
     result = unittest.TestResult()
-    for module in ['buildman.toolchain', 'patman.gitutil']:
-        suite = doctest.DocTestSuite(module)
-        suite.run(result)
-
-    sys.argv = [sys.argv[0]]
+    test_name = args and args[0] or None
     if skip_net_tests:
         test.use_network = False
-    for module in (test.TestBuild, func_test.TestFunctional):
-        suite = unittest.TestLoader().loadTestsFromTestCase(module)
-        suite.run(result)
 
-    print(result)
-    for test, err in result.errors:
-        print(err)
-    for test, err in result.failures:
-        print(err)
+    # Run the entry tests first ,since these need to be the first to import the
+    # 'entry' module.
+    test_util.RunTestSuites(
+        result, False, verboose, False, None, test_name, [],
+        [test.TestBuild, func_test.TestFunctional,
+         'buildman.toolchain', 'patman.gitutil'])
 
+    return test_util.ReportResult('buildman', test_name, result)
 
 options, args = cmdline.ParseArgs()
 
@@ -59,7 +55,7 @@  if not options.debug:
 
 # Run our meagre tests
 if options.test:
-    RunTests(options.skip_net_tests)
+    RunTests(options.skip_net_tests, options.verbose, args)
 
 # Build selected commits for selected boards
 else: