diff options
| author | Martin Hořeňovský | 2025-09-27 23:20:52 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2025-09-28 10:48:08 +0200 |
| commit | 91b3b3bf4057e2a7e41bf1edd3e2c68b31bb3747 (patch) | |
| tree | d266f60fdf0d2c092e198ff498557d31b674b704 /src/catch2/catch_config.cpp | |
| parent | a00d6544375e92ccedec786aaee47ac392ea4900 (diff) | |
| download | catch3-91b3b3bf4057e2a7e41bf1edd3e2c68b31bb3747.tar.gz | |
Support Bazel's TEST_RANDOM_SEED
As with other Bazel env vars, it overrides the corresponding CLI
parameter if both are set.
Closes #3021
Closes #3024
Diffstat (limited to 'src/catch2/catch_config.cpp')
| -rw-r--r-- | src/catch2/catch_config.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 978bcfd7..fef03d7d 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -253,6 +253,21 @@ namespace Catch { if (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 |