如果 3 次重试中有 1 次通过,Bazel 通过片状测试
Bazel pass flaky test if 1 out of 3 retries pass
我有一个基于 Java 的测试套件 运行 Bazel 4.2.2,我的目标是收集代码覆盖率,而不考虑测试的脆弱性。我尝试添加这些选项:
bazel coverage ... --runs_per_test=3 --cache_test_results=no ...
但看起来如果其中 1/3 失败,则测试失败,并且不会为失败的测试收集覆盖率数据。
Bazel 是否有任何标志来获取第一个通过的结果,并且只在失败时重试?
我试过的完整命令是
bazel coverage --jobs=6 --runs_per_test=3 --cache_test_results=no --combined_report=lcov --coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" -- //$TARGET/... 2>&1
谢谢!
回答我的问题(还不能接受):我在文档中找到了一个选项
https://docs.bazel.build/versions/0.25.0/command-line-reference.html
--flaky_test_attempts=<a positive integer, the string "default", or test_regex@attempts. This flag may be passed more than once> multiple uses are accumulated
Each test will be retried up to the specified number of times in case of any test failure. Tests that required more than one attempt to pass would be marked as 'FLAKY' in the test summary. If this option is set, it should specify an int N or the string 'default'. If it's an int, then all tests will be run up to N times. If it is not specified or its value is ' default', then only a single test attempt will be made for regular tests and three for tests marked explicitly as flaky by their rule (flaky=1 attribute).
另一种选择是在您的测试规则中使用 flaky attribute 来进行有问题的测试。这将 运行 它们最多 3 次,即使是正常 bazel test
,也不需要任何标志。
我有一个基于 Java 的测试套件 运行 Bazel 4.2.2,我的目标是收集代码覆盖率,而不考虑测试的脆弱性。我尝试添加这些选项:
bazel coverage ... --runs_per_test=3 --cache_test_results=no ...
但看起来如果其中 1/3 失败,则测试失败,并且不会为失败的测试收集覆盖率数据。
Bazel 是否有任何标志来获取第一个通过的结果,并且只在失败时重试?
我试过的完整命令是
bazel coverage --jobs=6 --runs_per_test=3 --cache_test_results=no --combined_report=lcov --coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" -- //$TARGET/... 2>&1
谢谢!
回答我的问题(还不能接受):我在文档中找到了一个选项 https://docs.bazel.build/versions/0.25.0/command-line-reference.html
--flaky_test_attempts=<a positive integer, the string "default", or test_regex@attempts. This flag may be passed more than once> multiple uses are accumulated
Each test will be retried up to the specified number of times in case of any test failure. Tests that required more than one attempt to pass would be marked as 'FLAKY' in the test summary. If this option is set, it should specify an int N or the string 'default'. If it's an int, then all tests will be run up to N times. If it is not specified or its value is ' default', then only a single test attempt will be made for regular tests and three for tests marked explicitly as flaky by their rule (flaky=1 attribute).
另一种选择是在您的测试规则中使用 flaky attribute 来进行有问题的测试。这将 运行 它们最多 3 次,即使是正常 bazel test
,也不需要任何标志。