ctest: Make test attempt number available to the test when using --repeat
When using ctest --repeat until-pass:<n>
, it can be useful for the test to know the run attempt number. One scenario is where you want to have more verbose output for subsequent runs if the first run fails. This came up in discussions within the Qt project for how to get more useful info in CI logs without having to always have full test output turned on.
ctest should be able to set an environment variable like CTEST_RUN_ATTEMPT
when running each test for any of the --repeat
scenarios. Even without that command line option, we could always set CTEST_RUN_ATTEMPT
(it would then always be 1 for the normal non-repeat case). That should be enough to allow the tests to adapt their behavior as needed.
Edited by Brad King