I have an unit test which tests some code that is multi-threaded. While I was writing this code I used the following command many times
bazel test //xyz:my_test --runs_per_test 1000
This exposed some concurrency issues which I have now fixed. I want to add this --runs_per_test
value to my test definition in my BUILD file, so that the night build (jenkins) runs this test multiple times. How do I do so?
Here is a better hack.
As my tests are C++ google tests; google tests accept a flag --gtest_repeat
for repeatedly running the test; I could pass this flag to the test from the bazel BUILD file, in the args
attribute
cc_test(
size = "small",
name = "my_test",
srcs = [".."],
deps = [".."],
args = ["--gtest_repeat=10"],
)
The problem with this approach is bazel would treat all the runs as a single test, so the run time would be cumulative of all runs. If this becomes more than the time limit for the test size (small
in this example), then bazel would terminate the test and show its result as timed-out
!