[llvm] 840bc47 - [lit] Extract by_suite_and_test_path sort key function
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 17:04:09 PDT 2020
Author: Julian Lettner
Date: 2020-05-01T17:03:55-07:00
New Revision: 840bc47f8b0c2768ec6c0d7819c79c867bcbcec1
URL: https://github.com/llvm/llvm-project/commit/840bc47f8b0c2768ec6c0d7819c79c867bcbcec1
DIFF: https://github.com/llvm/llvm-project/commit/840bc47f8b0c2768ec6c0d7819c79c867bcbcec1.diff
LOG: [lit] Extract by_suite_and_test_path sort key function
Added:
Modified:
llvm/utils/lit/lit/main.py
llvm/utils/lit/lit/reports.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index c6f798d35eaf..f9b54805d70c 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -13,6 +13,7 @@
import lit.discovery
import lit.display
import lit.LitConfig
+import lit.reports
import lit.run
import lit.Test
import lit.util
@@ -123,16 +124,14 @@ def parse(p):
def print_discovered(tests, show_suites, show_tests):
- # Suite names are not necessarily unique. Include object identity in sort
- # key to avoid mixing tests of
diff erent suites.
- tests.sort(key=lambda t: (t.suite.name, t.suite, t.path_in_suite))
+ tests.sort(key=lit.reports.by_suite_and_test_path)
if show_suites:
import itertools
tests_by_suite = itertools.groupby(tests, lambda t: t.suite)
print('-- Test Suites --')
- for suite, suite_iter in tests_by_suite:
- test_count = sum(1 for _ in suite_iter)
+ for suite, test_iter in tests_by_suite:
+ test_count = sum(1 for _ in test_iter)
print(' %s - %d tests' % (suite.name, test_count))
print(' Source Root: %s' % suite.source_root)
print(' Exec Root : %s' % suite.exec_root)
diff --git a/llvm/utils/lit/lit/reports.py b/llvm/utils/lit/lit/reports.py
index de5a22d10016..8165d8cf54fd 100755
--- a/llvm/utils/lit/lit/reports.py
+++ b/llvm/utils/lit/lit/reports.py
@@ -6,6 +6,12 @@
import lit.Test
+def by_suite_and_test_path(test):
+ # Suite names are not necessarily unique. Include object identity in sort
+ # key to avoid mixing tests of
diff erent suites.
+ return (test.suite.name, id(test.suite), test.path_in_suite)
+
+
class JsonReport(object):
def __init__(self, output_file):
self.output_file = output_file
@@ -70,9 +76,7 @@ def __init__(self, output_file):
# TODO(yln): elapsed unused, put it somewhere?
def write_results(self, tests, elapsed):
assert not any(t.result.code in {lit.Test.EXCLUDED, lit.Test.SKIPPED} for t in tests)
- # Suite names are not necessarily unique. Include object identity in
- # sort key to avoid mixing tests of
diff erent suites.
- tests.sort(key=lambda t: (t.suite.name, id(t.suite), t.path_in_suite))
+ tests.sort(key=by_suite_and_test_path)
tests_by_suite = itertools.groupby(tests, lambda t: t.suite)
with open(self.output_file, 'w') as file:
More information about the llvm-commits
mailing list