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

summaryrefslogtreecommitdiffhomepage
path: root/tests/ExtraTests
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-12-13 15:15:23 +0100
committerMartin Hořeňovský2021-12-18 20:50:00 +0100
commit9f2dca5384a6a8f9f37a7dc2d998cac616545592 (patch)
tree181d46f4eb905903e08af58a8a35108f87a24505 /tests/ExtraTests
parent602e484f027ccdfb59cfde852e20283ad1635f81 (diff)
downloadcatch3-9f2dca5384a6a8f9f37a7dc2d998cac616545592.tar.gz
Exit with non-0 return code if no tests were run
A new flag, `--allow-running-no-tests` was added to override this behaviour if exit code of 0 was desired. This change also made `-w NoTests` obsolete, and so it has been removed.
Diffstat (limited to 'tests/ExtraTests')
-rw-r--r--tests/ExtraTests/CMakeLists.txt17
-rw-r--r--tests/ExtraTests/X92-NoTests.cpp11
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt
index f7e9ec18..b3b8dbec 100644
--- a/tests/ExtraTests/CMakeLists.txt
+++ b/tests/ExtraTests/CMakeLists.txt
@@ -299,6 +299,22 @@ set_tests_properties(
# PASS_REGULAR_EXPRESSION "Pretty please, break into debugger"
#)
+add_executable(NoTests ${TESTS_DIR}/X92-NoTests.cpp)
+target_link_libraries(NoTests PRIVATE Catch2::Catch2WithMain)
+
+add_test(
+ NAME TestSpecs::EmptySpecWithNoTestsFails
+ COMMAND $<TARGET_FILE:NoTests>
+)
+set_tests_properties(TestSpecs::EmptySpecWithNoTestsFails
+ PROPERTIES
+ WILL_FAIL ON
+)
+add_test(
+ NAME TestSpecs::OverrideFailureWithEmptySpec
+ COMMAND $<TARGET_FILE:NoTests> --allow-running-no-tests
+)
+
set( EXTRA_TEST_BINARIES
PrefixedMacros
DisabledMacros
@@ -310,6 +326,7 @@ set( EXTRA_TEST_BINARIES
DuplicatedTestCases-SameNameAndTags
DuplicatedTestCases-SameNameDifferentTags
DuplicatedTestCases-DuplicatedTestCaseMethods
+ NoTests
# DebugBreakMacros
)
diff --git a/tests/ExtraTests/X92-NoTests.cpp b/tests/ExtraTests/X92-NoTests.cpp
new file mode 100644
index 00000000..fc6bf597
--- /dev/null
+++ b/tests/ExtraTests/X92-NoTests.cpp
@@ -0,0 +1,11 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+/**\file
+ * Links into executable with no tests which should fail when run
+ */