Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LIT] Print discovered tests and percentages #66057

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llvm/utils/lit/lit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def print_histogram(tests):

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

Expand All @@ -320,7 +321,7 @@ def print_results(tests, elapsed, opts):
opts.shown_codes,
)

print_summary(tests_by_code, opts.quiet, elapsed)
print_summary(total_tests, tests_by_code, opts.quiet, elapsed)


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


def print_summary(tests_by_code, quiet, elapsed):
def print_summary(total_tests, tests_by_code, quiet, elapsed):
if not quiet:
print("\nTesting Time: %.2fs" % elapsed)

print("\nTotal Discovered Tests: %s" % (total_tests))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("\nTotal Discovered Tests: %s" % (total_tests))
print(f"\nTotal Discovered Tests: {total_tests}")

codes = [c for c in lit.Test.ResultCode.all_codes() if not quiet or c.isFailure]
groups = [(c.label, len(tests_by_code[c])) for c in codes]
groups = [(label, count) for label, count in groups if count]
Expand All @@ -351,4 +353,4 @@ def print_summary(tests_by_code, quiet, elapsed):
for (label, count) in groups:
label = label.ljust(max_label_len)
count = str(count).rjust(max_count_len)
print(" %s: %s" % (label, count))
print(" %s: %s (%.2f%%)" % (label, count, float(count) / total_tests * 100))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wishlist: this can probably also be converted to a f-string or if not to use .format() while you are at it. Since this pre-existing I don't mind if you leave it untouched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will take it in a separate patch.

7 changes: 7 additions & 0 deletions llvm/utils/lit/tests/discovery.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
# CHECK-BASIC-OUT: top-level-suite :: test-one
# CHECK-BASIC-OUT: top-level-suite :: test-two

# RUN: %{lit} %{inputs}/discovery \
# RUN: -v > %t.out 2> %t.err
# RUN: FileCheck --check-prefix=CHECK-PERCENTAGES-OUT < %/t.out %s
#
# CHECK-PERCENTAGES-OUT: Total Discovered Tests: {{[0-9]*}}
# CHECK-PERCENTAGES-OUT: Passed: {{[0-9]*}} {{\([0-9]*\.[0-9]*%\)}}

# Check discovery when providing the special builtin 'config_map'
# RUN: %{python} %{inputs}/config-map-discovery/driver.py \
# RUN: %{inputs}/config-map-discovery/main-config/lit.cfg \
Expand Down