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

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-12-29 23:53:59 +0100
committerMartin Hořeňovský2022-01-01 14:11:49 +0100
commit22547a3c5f6e2f7b67b74a420fd06ef077678c04 (patch)
tree16ab45237a567313b7338c957f212aad8df3679a /tests
parent8baf9c05a3ab8ba2de400678539d0256ec60b4b4 (diff)
downloadcatch3-22547a3c5f6e2f7b67b74a420fd06ef077678c04.tar.gz
Add test for stdout pass-through behaviour in MultiReporter
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 02e02747..5f0996e0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -418,6 +418,39 @@ set_tests_properties("ErrorHandling::InvalidTestSpecExitsEarly"
FAIL_REGULAR_EXPRESSION "No tests ran"
)
+if (MSVC)
+ set(_NullFile "NUL")
+else()
+ set(_NullFile "/dev/null")
+endif()
+
+# This test checks that there is nothing written out from the process,
+# but if CMake is running the tests under Valgrind or similar tool, then
+# that will write its own output to stdout and the test would fail.
+if (NOT MEMORYCHECK_COMMAND)
+ add_test(NAME "MultiReporter::CapturingReportersDontPropagateStdOut"
+ COMMAND
+ $<TARGET_FILE:SelfTest> "Sends stuff to stdout and stderr"
+ --reporter xml::${_NullFile}
+ --reporter junit::${_NullFile}
+ )
+ set_tests_properties("MultiReporter::CapturingReportersDontPropagateStdOut"
+ PROPERTIES
+ FAIL_REGULAR_EXPRESSION ".+"
+ )
+endif()
+
+add_test(NAME "MultiReporter::NonCapturingReportersPropagateStdout"
+ COMMAND
+ $<TARGET_FILE:SelfTest> "Sends stuff to stdout and stderr"
+ --reporter xml::${_NullFile}
+ --reporter console::${_NullFile}
+)
+set_tests_properties("MultiReporter::NonCapturingReportersPropagateStdout"
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "A string sent to stderr via clog"
+)
+
if (CATCH_USE_VALGRIND)
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)