[llvm] r187850 - [lit] Add a --show-tests option.

Daniel Dunbar daniel at zuster.org
Tue Aug 6 20:11:42 PDT 2013


Author: ddunbar
Date: Tue Aug  6 22:11:42 2013
New Revision: 187850

URL: http://llvm.org/viewvc/llvm-project?rev=187850&view=rev
Log:
[lit] Add a --show-tests option.

Modified:
    llvm/trunk/utils/lit/lit/main.py

Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=187850&r1=187849&r2=187850&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Tue Aug  6 22:11:42 2013
@@ -242,6 +242,9 @@ def main(builtinParameters = {}):
     group.add_option("", "--show-suites", dest="showSuites",
                       help="Show discovered test suites",
                       action="store_true", default=False)
+    group.add_option("", "--show-tests", dest="showTests",
+                      help="Show all discovered tests",
+                      action="store_true", default=False)
     group.add_option("", "--repeat", dest="repeatTests", metavar="N",
                       help="Repeat tests N times (for timing)",
                       action="store", default=None, type=int)
@@ -288,21 +291,32 @@ def main(builtinParameters = {}):
 
     tests = lit.discovery.find_tests_for_inputs(litConfig, inputs)
 
-    if opts.showSuites:
+    if opts.showSuites or opts.showTests:
+        # Aggregate the tests by suite.
         suitesAndTests = {}
         for t in tests:
             if t.suite not in suitesAndTests:
                 suitesAndTests[t.suite] = []
             suitesAndTests[t.suite].append(t)
-
-        print '-- Test Suites --'
         suitesAndTests = suitesAndTests.items()
         suitesAndTests.sort(key = lambda (ts,_): ts.name)
-        for ts,ts_tests in suitesAndTests:
-            print '  %s - %d tests' %(ts.name, len(ts_tests))
-            print '    Source Root: %s' % ts.source_root
-            print '    Exec Root  : %s' % ts.exec_root
 
+        # Show the suites, if requested.
+        if opts.showSuites:
+            print '-- Test Suites --'
+            for ts,ts_tests in suitesAndTests:
+                print '  %s - %d tests' %(ts.name, len(ts_tests))
+                print '    Source Root: %s' % ts.source_root
+                print '    Exec Root  : %s' % ts.exec_root
+
+        # Show the tests, if requested.
+        if opts.showTests:
+            print '-- Available Tests --'
+            for ts,ts_tests in suitesAndTests:
+                ts_tests.sort(key = lambda test: test.path_in_suite)
+                for test in ts_tests:
+                    print '  %s' % (test.getFullName(),)
+        
     # Select and order the tests.
     numTotalTests = len(tests)
 





More information about the llvm-commits mailing list