Skip to content

Commit a17a89b

Browse files
committed
[LIT] Print discovered tests and percentages
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 percentages of tests. Differential Revision: https://reviews.llvm.org/D159081
1 parent 37b93f0 commit a17a89b

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
@@ -310,6 +310,7 @@ def print_histogram(tests):
310310

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

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

323-
print_summary(tests_by_code, opts.quiet, elapsed)
324+
print_summary(total_tests, tests_by_code, opts.quiet, elapsed)
324325

325326

326327
def print_group(tests, code, shown_codes):
@@ -335,10 +336,11 @@ def print_group(tests, code, shown_codes):
335336
sys.stdout.write("\n")
336337

337338

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

343+
print("\nTotal Discovered Tests: %s" % (total_tests))
342344
codes = [c for c in lit.Test.ResultCode.all_codes() if not quiet or c.isFailure]
343345
groups = [(c.label, len(tests_by_code[c])) for c in codes]
344346
groups = [(label, count) for label, count in groups if count]
@@ -351,4 +353,4 @@ def print_summary(tests_by_code, quiet, elapsed):
351353
for (label, count) in groups:
352354
label = label.ljust(max_label_len)
353355
count = str(count).rjust(max_count_len)
354-
print(" %s: %s" % (label, count))
356+
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)