Patchwork [bitbake-devel,2/4] bitbake-selftest: enable specifying tests to run on command line

login
register
mail settings
Submitter Paul Eggleton
Date Feb. 24, 2014, 6:50 p.m.
Message ID <d78973c4f2cde514a9b246992c9ac42960b6759e.1393267755.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/67331/
State New
Headers show

Comments

Paul Eggleton - Feb. 24, 2014, 6:50 p.m.
If you are just trying to fix one test at a time, it can be useful to be
able to specify an individual test(s) rather than running them all:

 bitbake-selftest bb.tests.codeparser bb.tests.cow

You can even specify the test class or function to run, e.g.:

 bitbake-selftest bb.tests.fetch.URITest
 bitbake-selftest bb.tests.fetch.FetcherNetworkTest.test_fetch

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 bin/bitbake-selftest | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Patch

diff --git a/bin/bitbake-selftest b/bin/bitbake-selftest
index 48a58fe..8c55f7b 100755
--- a/bin/bitbake-selftest
+++ b/bin/bitbake-selftest
@@ -25,13 +25,24 @@  try:
 except RuntimeError as exc:
     sys.exit(str(exc))
 
-tests = ["bb.tests.codeparser", 
-         "bb.tests.cow",
-         "bb.tests.data",
-         "bb.tests.fetch",
-         "bb.tests.utils"]
+def usage():
+    print('usage: %s [testname1 [testname2]...]')
+
+if len(sys.argv) > 1:
+    if '--help' in sys.argv[1:]:
+        usage()
+        sys.exit(0)
+
+    tests = sys.argv[1:]
+else:
+    tests = ["bb.tests.codeparser",
+             "bb.tests.cow",
+             "bb.tests.data",
+             "bb.tests.fetch",
+             "bb.tests.utils"]
 
 for t in tests:
+    t = '.'.join(t.split('.')[:3])
     __import__(t)
 
 unittest.main(argv=["bitbake-selftest"] + tests)