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

Conversation

madhur13490
Copy link
Contributor

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.

Differential Revision: https://reviews.llvm.org/D159081

@llvmbot
Copy link
Member

llvmbot commented Sep 12, 2023

@llvm/pr-subscribers-testing-tools

Changes

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.

Differential Revision: https://reviews.llvm.org/D159081

Full diff: https://github.com/llvm/llvm-project/pull/66057.diff

1 Files Affected:

  • (modified) llvm/utils/lit/lit/main.py (+5-3)
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 6858961752a66f1..70230eda48af86f 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -311,6 +311,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)
 
@@ -321,7 +322,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):
@@ -336,10 +337,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))
     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]
@@ -352,4 +354,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

@RoboTux RoboTux left a comment

Choose a reason for hiding this comment

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

Nit: could you write percentage instead of shortening it to %ge? LGTM otherwise.

@aleks-tmb aleks-tmb requested review from annamthomas and removed request for annamthomas September 12, 2023 10:18
@jdenny-ornl
Copy link
Collaborator

Thanks for the nice feature. Please extend lit's test suite to help lit developers avoid breaking it in the future.

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
@madhur13490
Copy link
Contributor Author

@RoboTux @jdenny-ornl Thanks for taking a look at it. I have addressed the review comments in the latest patch.

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}")

@@ -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.

@madhur13490
Copy link
Contributor Author

@jdenny-ornl @RoboTux Can I please get approval on this? Would like to land soon.

Copy link
Contributor

@RoboTux RoboTux left a comment

Choose a reason for hiding this comment

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

LGTM

@madhur13490 madhur13490 merged commit ba8565f into llvm:main Oct 20, 2023
madhur13490 added a commit to madhur13490/llvm-project that referenced this pull request Oct 20, 2023
madhur13490 added a commit that referenced this pull request Oct 20, 2023
@muiez
Copy link
Member

muiez commented Oct 20, 2023

Hi, I think the following tests need to be updated as well to avoid breakages:

ignore-fail.py
shtest-define.py
shtest-env.py
shtest-not.py
shtest-pushd-popd.py

madhur13490 added a commit to madhur13490/llvm-project that referenced this pull request Oct 22, 2023
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.

This patch fixes tests pointed by previous attempt of landing this
patch.

Reviewed By: RoboTux, jdenny-ornl

Co-authored-by: Madhur A <[email protected]>
madhur13490 added a commit that referenced this pull request Oct 22, 2023
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.

This patch fixes tests pointed by previous attempt of landing this
patch.

Reviewed By: RoboTux, jdenny-ornl

Co-authored-by: Madhur A <[email protected]>
Guzhu-AMD pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Oct 26, 2023
Local branch amd-gfx ee21db2 Merged main:b99f7e695469 into amd-gfx:a485974c4c95
Remote branch main ba8565f [LIT] Print discovered tests and percentages (llvm#66057)
Guzhu-AMD pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Oct 26, 2023
Local branch amd-gfx 950d1a3 Merged main:00c8da615923 into amd-gfx:1a36b82bb390
Remote branch main 0b7ae41 [LIT] Print discovered tests and percentages (llvm#66057) (llvm#69831)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants