mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 05:15:39 +02:00
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.
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
11
tests/ExtraTests/X92-NoTests.cpp
Normal file
11
tests/ExtraTests/X92-NoTests.cpp
Normal file
@@ -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
|
||||
*/
|
Reference in New Issue
Block a user