Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-09-27 23:20:52 +0200
committerMartin Hořeňovský2025-09-28 10:48:08 +0200
commit91b3b3bf4057e2a7e41bf1edd3e2c68b31bb3747 (patch)
treed266f60fdf0d2c092e198ff498557d31b674b704 /tests
parenta00d6544375e92ccedec786aaee47ac392ea4900 (diff)
downloadcatch3-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 'tests')
-rw-r--r--tests/CMakeLists.txt33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8f8a3755..651ac835 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -662,5 +662,38 @@ foreach(reporterName # "Automake" - the simple .trs format does not support any
)
endforeach()
+add_test(NAME "Bazel::RngSeedEnvVar::JustEnv"
+ COMMAND
+ $<TARGET_FILE:SelfTest> "Factorials are computed"
+)
+set_tests_properties("Bazel::RngSeedEnvVar::JustEnv"
+ PROPERTIES
+ ENVIRONMENT "BAZEL_TEST=1;TEST_RANDOM_SEED=18181818"
+ PASS_REGULAR_EXPRESSION "Randomness seeded to: 18181818"
+)
+
+add_test(NAME "Bazel::RngSeedEnvVar::EnvHasPriorityOverCLI"
+ COMMAND
+ $<TARGET_FILE:SelfTest> "Factorials are computed"
+ --rng-seed 17171717
+)
+set_tests_properties("Bazel::RngSeedEnvVar::EnvHasPriorityOverCLI"
+ PROPERTIES
+ ENVIRONMENT "BAZEL_TEST=1;TEST_RANDOM_SEED=18181818"
+ PASS_REGULAR_EXPRESSION "Randomness seeded to: 18181818"
+)
+
+add_test(NAME "Bazel::RngSeedEnvVar::MalformedValueIsIgnored"
+ COMMAND
+ $<TARGET_FILE:SelfTest> "Factorials are computed"
+ --rng-seed 17171717
+)
+set_tests_properties("Bazel::RngSeedEnvVar::MalformedValueIsIgnored"
+ PROPERTIES
+ ENVIRONMENT "BAZEL_TEST=1;TEST_RANDOM_SEED=XOXOXOXO"
+ PASS_REGULAR_EXPRESSION "Randomness seeded to: 17171717"
+)
+
+
list(APPEND CATCH_TEST_TARGETS SelfTest)
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)