@@ -42,6 +42,10 @@ def main(builtin_params={}):
42
42
sys .stderr .write ('error: did not discover any tests for provided path(s)\n ' )
43
43
sys .exit (2 )
44
44
45
+ if opts .show_suites or opts .show_tests :
46
+ print_discovered (discovered_tests , opts .show_suites , opts .show_tests )
47
+ sys .exit (0 )
48
+
45
49
# Command line overrides configuration for maxIndividualTestTime.
46
50
if opts .maxIndividualTestTime is not None : # `not None` is important (default: 0)
47
51
if opts .maxIndividualTestTime != lit_config .maxIndividualTestTime :
@@ -53,10 +57,6 @@ def main(builtin_params={}):
53
57
opts .maxIndividualTestTime ))
54
58
lit_config .maxIndividualTestTime = opts .maxIndividualTestTime
55
59
56
- if opts .showSuites or opts .showTests :
57
- print_suites_or_tests (discovered_tests , opts )
58
- return
59
-
60
60
filtered_tests = [t for t in discovered_tests if
61
61
opts .filter .search (t .getFullName ())]
62
62
if not filtered_tests :
@@ -119,34 +119,29 @@ def parse(p):
119
119
params .update ([parse (p ) for p in user_params ])
120
120
return params
121
121
122
- def print_suites_or_tests (tests , opts ):
123
- # Aggregate the tests by suite.
124
- suitesAndTests = {}
125
- for result_test in tests :
126
- if result_test .suite not in suitesAndTests :
127
- suitesAndTests [result_test .suite ] = []
128
- suitesAndTests [result_test .suite ].append (result_test )
129
- suitesAndTests = list (suitesAndTests .items ())
130
- suitesAndTests .sort (key = lambda item : item [0 ].name )
131
-
132
- # Show the suites, if requested.
133
- if opts .showSuites :
122
+
123
+ def print_discovered (tests , show_suites , show_tests ):
124
+ # Suite names are not necessarily unique. Include object identity in sort
125
+ # key to avoid mixing tests of different suites.
126
+ tests .sort (key = lambda t : (t .suite .name , t .suite , t .path_in_suite ))
127
+
128
+ if show_suites :
129
+ import itertools
130
+ tests_by_suite = itertools .groupby (tests , lambda t : t .suite )
134
131
print ('-- Test Suites --' )
135
- for ts , ts_tests in suitesAndTests :
136
- print ( ' %s - %d tests' % ( ts . name , len ( ts_tests )) )
137
- print (' Source Root: %s ' % ts . source_root )
138
- print (' Exec Root : %s' % ts . exec_root )
139
- if ts . config . available_features :
140
- print ( ' Available Features : %s' % ' ' . join (
141
- sorted (ts .config .available_features ) ))
142
-
143
- # Show the tests, if requested.
144
- if opts . showTests :
132
+ for suite , suite_iter in tests_by_suite :
133
+ test_count = sum ( 1 for _ in suite_iter )
134
+ print (' %s - %d tests ' % ( suite . name , test_count ) )
135
+ print (' Source Root: %s' % suite . source_root )
136
+ print ( ' Exec Root : %s' % suite . exec_root )
137
+ if suite . config . available_features :
138
+ features = ' ' . join ( sorted (suite .config .available_features ))
139
+ print ( ' Available Features : %s' % features )
140
+
141
+ if show_tests :
145
142
print ('-- Available Tests --' )
146
- for ts ,ts_tests in suitesAndTests :
147
- ts_tests .sort (key = lambda test : test .path_in_suite )
148
- for test in ts_tests :
149
- print (' %s' % (test .getFullName (),))
143
+ for t in tests :
144
+ print (' %s' % t .getFullName ())
150
145
151
146
152
147
def determine_order (tests , order ):
0 commit comments