[llvm] eb5ca29 - [lit] Cleanup printing of discovered suites and tests
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 10:39:53 PDT 2020
Author: Julian Lettner
Date: 2020-04-07T10:39:35-07:00
New Revision: eb5ca295d7eb9200dd4b4ebe1d1112d750d66714
URL: https://github.com/llvm/llvm-project/commit/eb5ca295d7eb9200dd4b4ebe1d1112d750d66714
DIFF: https://github.com/llvm/llvm-project/commit/eb5ca295d7eb9200dd4b4ebe1d1112d750d66714.diff
LOG: [lit] Cleanup printing of discovered suites and tests
Added:
Modified:
llvm/utils/lit/lit/cl_arguments.py
llvm/utils/lit/lit/main.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py
index 656a783d3dca..ee7527538adc 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -152,12 +152,10 @@ def parse_args():
help="Enable debugging (for 'lit' development)",
action="store_true")
debug_group.add_argument("--show-suites",
- dest="showSuites",
- help="Show discovered test suites",
+ help="Show discovered test suites and exit",
action="store_true")
debug_group.add_argument("--show-tests",
- dest="showTests",
- help="Show all discovered tests",
+ help="Show all discovered tests and exit",
action="store_true")
# LIT is special: environment variables override command line arguments.
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index fb45995a6280..3e5716f4a1ff 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -42,6 +42,10 @@ def main(builtin_params={}):
sys.stderr.write('error: did not discover any tests for provided path(s)\n')
sys.exit(2)
+ if opts.show_suites or opts.show_tests:
+ print_discovered(discovered_tests, opts.show_suites, opts.show_tests)
+ sys.exit(0)
+
# Command line overrides configuration for maxIndividualTestTime.
if opts.maxIndividualTestTime is not None: # `not None` is important (default: 0)
if opts.maxIndividualTestTime != lit_config.maxIndividualTestTime:
@@ -53,10 +57,6 @@ def main(builtin_params={}):
opts.maxIndividualTestTime))
lit_config.maxIndividualTestTime = opts.maxIndividualTestTime
- if opts.showSuites or opts.showTests:
- print_suites_or_tests(discovered_tests, opts)
- return
-
filtered_tests = [t for t in discovered_tests if
opts.filter.search(t.getFullName())]
if not filtered_tests:
@@ -119,34 +119,29 @@ def parse(p):
params.update([parse(p) for p in user_params])
return params
-def print_suites_or_tests(tests, opts):
- # Aggregate the tests by suite.
- suitesAndTests = {}
- for result_test in tests:
- if result_test.suite not in suitesAndTests:
- suitesAndTests[result_test.suite] = []
- suitesAndTests[result_test.suite].append(result_test)
- suitesAndTests = list(suitesAndTests.items())
- suitesAndTests.sort(key = lambda item: item[0].name)
-
- # Show the suites, if requested.
- if opts.showSuites:
+
+def print_discovered(tests, show_suites, show_tests):
+ # Suite names are not necessarily unique. Include object identity in sort
+ # key to avoid mixing tests of
diff erent suites.
+ tests.sort(key=lambda t: (t.suite.name, t.suite, t.path_in_suite))
+
+ if show_suites:
+ import itertools
+ tests_by_suite = itertools.groupby(tests, lambda t: t.suite)
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)
- if ts.config.available_features:
- print(' Available Features : %s' % ' '.join(
- sorted(ts.config.available_features)))
-
- # Show the tests, if requested.
- if opts.showTests:
+ for suite, suite_iter in tests_by_suite:
+ test_count = sum(1 for _ in suite_iter)
+ print(' %s - %d tests' % (suite.name, test_count))
+ print(' Source Root: %s' % suite.source_root)
+ print(' Exec Root : %s' % suite.exec_root)
+ if suite.config.available_features:
+ features = ' '.join(sorted(suite.config.available_features))
+ print(' Available Features : %s' % features)
+
+ if show_tests:
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(),))
+ for t in tests:
+ print(' %s' % t.getFullName())
def determine_order(tests, order):
More information about the llvm-commits
mailing list