diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py index b8c9513603220e..0c4c986d456148 100755 --- a/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -96,17 +96,13 @@ def main(builtin_params={}): run_tests(selected_tests, lit_config, opts, len(discovered_tests)) elapsed = time.time() - start - # TODO(yln): eventually, all functions below should act on discovered_tests - executed_tests = [ - t for t in selected_tests if t.result.code != lit.Test.SKIPPED] - if opts.time_tests: print_histogram(discovered_tests) print_results(discovered_tests, elapsed, opts) for report in opts.reports: - report.write_results(executed_tests, elapsed) + report.write_results(discovered_tests, elapsed) if lit_config.numErrors: sys.stderr.write('\n%d error(s) in tests\n' % lit_config.numErrors) diff --git a/llvm/utils/lit/lit/reports.py b/llvm/utils/lit/lit/reports.py index 8499d2126be591..c23b4c7140900b 100755 --- a/llvm/utils/lit/lit/reports.py +++ b/llvm/utils/lit/lit/reports.py @@ -17,7 +17,8 @@ def __init__(self, output_file): self.output_file = output_file def write_results(self, tests, elapsed): - assert not any(t.result.code in {lit.Test.EXCLUDED, lit.Test.SKIPPED} for t in tests) + unexecuted_codes = {lit.Test.EXCLUDED, lit.Test.SKIPPED} + tests = [t for t in tests if t.result.code not in unexecuted_codes] # Construct the data we will write. data = {} # Encode the current lit version as a schema version. @@ -75,7 +76,6 @@ 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) tests.sort(key=by_suite_and_test_path) tests_by_suite = itertools.groupby(tests, lambda t: t.suite) @@ -136,4 +136,4 @@ def _get_skip_reason(self, test): features = test.getMissingRequiredFeatures() if features: return 'Missing required feature(s): ' + ', '.join(features) - return 'Skipping because of configuration' + return 'Unsupported configuration' diff --git a/llvm/utils/lit/tests/Inputs/xunit-output/dummy_format.py b/llvm/utils/lit/tests/Inputs/xunit-output/dummy_format.py index 93e48eeb83960a..94410d215d392e 100644 --- a/llvm/utils/lit/tests/Inputs/xunit-output/dummy_format.py +++ b/llvm/utils/lit/tests/Inputs/xunit-output/dummy_format.py @@ -23,6 +23,10 @@ def execute(self, test, lit_config): result = lit.Test.Result(getattr(lit.Test, result_code), result_output) + required_feature = cfg.get('global', 'required_feature', fallback=None) + if required_feature: + test.requires.append(required_feature) + # Load additional metrics. for key,value_str in cfg.items('results'): value = eval(value_str) diff --git a/llvm/utils/lit/tests/Inputs/xunit-output/excluded.ini b/llvm/utils/lit/tests/Inputs/xunit-output/excluded.ini new file mode 100644 index 00000000000000..f62ede446872a2 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/xunit-output/excluded.ini @@ -0,0 +1,5 @@ +[global] +result_code = EXCLUDED +result_output = not shown + +[results] diff --git a/llvm/utils/lit/tests/Inputs/xunit-output/missing_feature.ini b/llvm/utils/lit/tests/Inputs/xunit-output/missing_feature.ini new file mode 100644 index 00000000000000..09fb2a132929f2 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/xunit-output/missing_feature.ini @@ -0,0 +1,7 @@ +[global] +result_code = UNSUPPORTED +result_output = not shown + +required_feature = dummy_feature + +[results] diff --git a/llvm/utils/lit/tests/Inputs/xunit-output/pass.ini b/llvm/utils/lit/tests/Inputs/xunit-output/pass.ini new file mode 100644 index 00000000000000..c1e22415263981 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/xunit-output/pass.ini @@ -0,0 +1,5 @@ +[global] +result_code = PASS +result_output = not shown + +[results] diff --git a/llvm/utils/lit/tests/Inputs/xunit-output/unsupported.ini b/llvm/utils/lit/tests/Inputs/xunit-output/unsupported.ini new file mode 100644 index 00000000000000..0d567b35a0a4ba --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/xunit-output/unsupported.ini @@ -0,0 +1,5 @@ +[global] +result_code = UNSUPPORTED +result_output = not shown + +[results] diff --git a/llvm/utils/lit/tests/shtest-format.py b/llvm/utils/lit/tests/shtest-format.py index 8cc7c679268c77..2714e20e05f3f4 100644 --- a/llvm/utils/lit/tests/shtest-format.py +++ b/llvm/utils/lit/tests/shtest-format.py @@ -134,7 +134,7 @@ # XUNIT: # XUNIT: -# XUNIT-NEXT: +# XUNIT-NEXT: # XUNIT: # XUNIT-NEXT: @@ -142,7 +142,7 @@ # XUNIT-NEXT: # XUNIT: -# XUNIT-NEXT: +# XUNIT-NEXT: # XUNIT: diff --git a/llvm/utils/lit/tests/xunit-output.py b/llvm/utils/lit/tests/xunit-output.py index 9cfe2cb9aa68c2..32a35f82a9433b 100644 --- a/llvm/utils/lit/tests/xunit-output.py +++ b/llvm/utils/lit/tests/xunit-output.py @@ -7,10 +7,21 @@ # RUN: sh -c 'if command -v xmllint 2>/dev/null; then xmllint --noout %t.xunit.xml; fi' # RUN: FileCheck < %t.xunit.xml %s -# CHECK: -# CHECK: -# CHECK: -# CHECK: -# CHECK-NEXT: ]]]]> &"]]> -# CHECK: -# CHECK: +# CHECK: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: ]]]]> &"]]> +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: +# CHECK-NEXT: