Skip to content

Commit ba8565f

Browse files
authored
[LIT] Print discovered tests and percentages (llvm#66057)
This patch adds "nice-to-have" feature in lit. it prints the total number of discovered tests at the beginning. It is covenient to see the total number of tests and avoid scrolling up to the beginning of log. Further, this patch also prints %ge of tests. Reviewed By: RoboTux, jdenny-ornl Co-authored-by: Madhur A <[email protected]>
1 parent 49af650 commit ba8565f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

llvm/utils/lit/lit/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def print_histogram(tests):
311311

312312
def print_results(tests, elapsed, opts):
313313
tests_by_code = {code: [] for code in lit.Test.ResultCode.all_codes()}
314+
total_tests = len(tests)
314315
for test in tests:
315316
tests_by_code[test.result.code].append(test)
316317

@@ -321,7 +322,7 @@ def print_results(tests, elapsed, opts):
321322
opts.shown_codes,
322323
)
323324

324-
print_summary(tests_by_code, opts.quiet, elapsed)
325+
print_summary(total_tests, tests_by_code, opts.quiet, elapsed)
325326

326327

327328
def print_group(tests, code, shown_codes):
@@ -336,10 +337,11 @@ def print_group(tests, code, shown_codes):
336337
sys.stdout.write("\n")
337338

338339

339-
def print_summary(tests_by_code, quiet, elapsed):
340+
def print_summary(total_tests, tests_by_code, quiet, elapsed):
340341
if not quiet:
341342
print("\nTesting Time: %.2fs" % elapsed)
342343

344+
print("\nTotal Discovered Tests: %s" % (total_tests))
343345
codes = [c for c in lit.Test.ResultCode.all_codes() if not quiet or c.isFailure]
344346
groups = [(c.label, len(tests_by_code[c])) for c in codes]
345347
groups = [(label, count) for label, count in groups if count]
@@ -352,4 +354,4 @@ def print_summary(tests_by_code, quiet, elapsed):
352354
for (label, count) in groups:
353355
label = label.ljust(max_label_len)
354356
count = str(count).rjust(max_count_len)
355-
print(" %s: %s" % (label, count))
357+
print(" %s: %s (%.2f%%)" % (label, count, float(count) / total_tests * 100))

llvm/utils/lit/tests/discovery.py

100644100755
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
# CHECK-BASIC-OUT: top-level-suite :: test-one
2929
# CHECK-BASIC-OUT: top-level-suite :: test-two
3030

31+
# RUN: %{lit} %{inputs}/discovery \
32+
# RUN: -v > %t.out 2> %t.err
33+
# RUN: FileCheck --check-prefix=CHECK-PERCENTAGES-OUT < %/t.out %s
34+
#
35+
# CHECK-PERCENTAGES-OUT: Total Discovered Tests: {{[0-9]*}}
36+
# CHECK-PERCENTAGES-OUT: Passed: {{[0-9]*}} {{\([0-9]*\.[0-9]*%\)}}
37+
3138
# Check discovery when providing the special builtin 'config_map'
3239
# RUN: %{python} %{inputs}/config-map-discovery/driver.py \
3340
# RUN: %{inputs}/config-map-discovery/main-config/lit.cfg \

0 commit comments

Comments
 (0)