mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-28 15:25:39 +02:00
WIP: support bazel random seed env var
This commit is contained in:
@@ -253,6 +253,21 @@ namespace Catch {
|
|||||||
if (bazelExitGuardFile) {
|
if (bazelExitGuardFile) {
|
||||||
m_data.prematureExitGuardFilePath = bazelExitGuardFile;
|
m_data.prematureExitGuardFilePath = bazelExitGuardFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto bazelRandomSeed = Detail::getEnv( "TEST_RANDOM_SEED" );
|
||||||
|
if ( bazelRandomSeed ) {
|
||||||
|
auto parsedSeed = parseUInt( bazelRandomSeed, 0 );
|
||||||
|
if ( !parsedSeed ) {
|
||||||
|
// Currently we handle issues with parsing other Bazel Env
|
||||||
|
// options by warning and ignoring the issue. So we do the
|
||||||
|
// same for random seed option.
|
||||||
|
Catch::cerr()
|
||||||
|
<< "Warning: could not parse 'TEST_RANDOM_SEED' ('"
|
||||||
|
<< bazelRandomSeed << "') as proper seed.\n";
|
||||||
|
} else {
|
||||||
|
m_data.rngSeed = *parsedSeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@@ -662,5 +662,26 @@ foreach(reporterName # "Automake" - the simple .trs format does not support any
|
|||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
add_test(NAME "Bazel::RngSeedEnvVar"
|
||||||
|
COMMAND
|
||||||
|
$<TARGET_FILE:SelfTest> "Factorials are computed"
|
||||||
|
)
|
||||||
|
set_tests_properties("Bazel::RngSeedEnvVar"
|
||||||
|
PROPERTIES
|
||||||
|
ENVIRONMENT "BAZEL_TEST=1;TEST_RANDOM_SEED=18181818"
|
||||||
|
PASS_REGULAR_EXPRESSION "Randomness seeded to: 18181818"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_test(NAME "Bazel::RngSeedEnvVarPriorityOverCLI"
|
||||||
|
COMMAND
|
||||||
|
$<TARGET_FILE:SelfTest> "Factorials are computed"
|
||||||
|
--rng-seed 17171717
|
||||||
|
)
|
||||||
|
set_tests_properties("Bazel::RngSeedEnvVarPriorityOverCLI"
|
||||||
|
PROPERTIES
|
||||||
|
ENVIRONMENT "BAZEL_TEST=1;TEST_RANDOM_SEED=18181818"
|
||||||
|
PASS_REGULAR_EXPRESSION "Randomness seeded to: 18181818"
|
||||||
|
)
|
||||||
|
|
||||||
list(APPEND CATCH_TEST_TARGETS SelfTest)
|
list(APPEND CATCH_TEST_TARGETS SelfTest)
|
||||||
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)
|
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)
|
||||||
|
Reference in New Issue
Block a user