[lit] Add a flag to disable lit time tests (#98270)
LLVM lit assumes control of the test parallelism when running a test suite. This style of testing doesn't play nicely with build systems like Buck or Bazel since it prefers finer grained actions on a per-test level. In order for external build systems to control the test parallelism, add an option to disable `.lit_test_times.txt` under the `--skip-test-time-recording` flag, thus allowing other build systems to determine the parallelism and avoid race conditions when writing to that file. I went for `--skip-test-time-recording` instead of `--time-tests` in order to preserve the original functionality of writing to `.lit_test_times.txt` as the default behavior and only opt-in for those who do _not_ want `.lit_test_times.txt` file.
This commit is contained in:
parent
c2019a37bd
commit
867ff2d426
@ -151,6 +151,10 @@ EXECUTION OPTIONS
|
||||
feature that can be used to conditionally disable (or expect failure in)
|
||||
certain tests.
|
||||
|
||||
.. option:: --skip-test-time-recording
|
||||
|
||||
Disable tracking the wall time individual tests take to execute.
|
||||
|
||||
.. option:: --time-tests
|
||||
|
||||
Track the wall time individual tests take to execute and includes the results
|
||||
|
@ -154,11 +154,6 @@ def parse_args():
|
||||
action="append",
|
||||
default=[],
|
||||
)
|
||||
execution_group.add_argument(
|
||||
"--time-tests",
|
||||
help="Track elapsed wall time for each test",
|
||||
action="store_true",
|
||||
)
|
||||
execution_group.add_argument(
|
||||
"--no-execute",
|
||||
dest="noExecute",
|
||||
@ -209,6 +204,17 @@ def parse_args():
|
||||
action="store_true",
|
||||
help="Exit with status zero even if some tests fail",
|
||||
)
|
||||
execution_test_time_group = execution_group.add_mutually_exclusive_group()
|
||||
execution_test_time_group.add_argument(
|
||||
"--skip-test-time-recording",
|
||||
help="Do not track elapsed wall time for each test",
|
||||
action="store_true",
|
||||
)
|
||||
execution_test_time_group.add_argument(
|
||||
"--time-tests",
|
||||
help="Track elapsed wall time for each test printed in a histogram",
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
selection_group = parser.add_argument_group("Test Selection")
|
||||
selection_group.add_argument(
|
||||
|
@ -124,6 +124,7 @@ def main(builtin_params={}):
|
||||
run_tests(selected_tests, lit_config, opts, len(discovered_tests))
|
||||
elapsed = time.time() - start
|
||||
|
||||
if not opts.skip_test_time_recording:
|
||||
record_test_times(selected_tests, lit_config)
|
||||
|
||||
selected_tests, discovered_tests = GoogleTest.post_process_shard_results(
|
||||
|
1
llvm/utils/lit/tests/Inputs/time-tests/a.txt
Normal file
1
llvm/utils/lit/tests/Inputs/time-tests/a.txt
Normal file
@ -0,0 +1 @@
|
||||
# RUN: true
|
7
llvm/utils/lit/tests/Inputs/time-tests/lit.cfg
Normal file
7
llvm/utils/lit/tests/Inputs/time-tests/lit.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
import lit.formats
|
||||
|
||||
config.name = "time-tests"
|
||||
config.suffixes = [".txt"]
|
||||
config.test_format = lit.formats.ShTest()
|
||||
config.test_source_root = None
|
||||
config.test_exec_root = None
|
15
llvm/utils/lit/tests/time-tests.py
Normal file
15
llvm/utils/lit/tests/time-tests.py
Normal file
@ -0,0 +1,15 @@
|
||||
## Check that --skip-test-time-recording skips .lit_test_times.txt recording.
|
||||
|
||||
# RUN: %{lit-no-order-opt} --skip-test-time-recording %{inputs}/time-tests
|
||||
# RUN: not ls %{inputs}/time-tests/.lit_test_times.txt
|
||||
|
||||
## Check that --time-tests generates a printed histogram.
|
||||
|
||||
# RUN: %{lit-no-order-opt} --time-tests %{inputs}/time-tests > %t.out
|
||||
# RUN: FileCheck < %t.out %s
|
||||
# RUN: rm %{inputs}/time-tests/.lit_test_times.txt
|
||||
|
||||
# CHECK: Tests Times:
|
||||
# CHECK-NEXT: --------------------------------------------------------------------------
|
||||
# CHECK-NEXT: [ Range ] :: [ Percentage ] :: [Count]
|
||||
# CHECK-NEXT: --------------------------------------------------------------------------
|
Loading…
x
Reference in New Issue
Block a user