Skip to content

Commit

Permalink
Return exit code 4 if all test cases are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
psalz committed Nov 3, 2022
1 parent 1bb2aeb commit b2ddca6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/catch2/catch_session.cpp
Expand Up @@ -341,6 +341,11 @@ namespace Catch {
return 2;
}

if ( totals.testCases.total() > 0 &&
totals.testCases.total() == totals.testCases.skipped ) {
return 4;
}

// Note that on unices only the lower 8 bits are usually used, clamping
// the return value to 255 prevents false negative when some multiple
// of 256 tests has failed
Expand Down
17 changes: 17 additions & 0 deletions tests/ExtraTests/CMakeLists.txt
Expand Up @@ -487,15 +487,32 @@ set_tests_properties(TestSpecs::EmptySpecWithNoTestsFails
PROPERTIES
WILL_FAIL ON
)

add_test(
NAME TestSpecs::OverrideFailureWithEmptySpec
COMMAND $<TARGET_FILE:NoTests> --allow-running-no-tests
)

add_test(
NAME List::Listeners::WorksWithoutRegisteredListeners
COMMAND $<TARGET_FILE:NoTests> --list-listeners
)


add_executable(AllSkipped ${TESTS_DIR}/X93-AllSkipped.cpp)
target_link_libraries(AllSkipped PRIVATE Catch2::Catch2WithMain)

add_test(
NAME TestSpecs::SkippingAllTestsFails
COMMAND $<TARGET_FILE:AllSkipped>
)
set_tests_properties(TestSpecs::SkippingAllTestsFails
PROPERTIES
WILL_FAIL ON
)

set( EXTRA_TEST_BINARIES
AllSkipped
PrefixedMacros
DisabledMacros
DisabledExceptions-DefaultHandler
Expand Down
16 changes: 16 additions & 0 deletions tests/ExtraTests/X93-AllSkipped.cpp
@@ -0,0 +1,16 @@

// 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

#include <catch2/catch_test_macros.hpp>

TEST_CASE( "this test case is being skipped" ) { SKIP(); }

TEST_CASE( "all sections in this test case are being skipped" ) {
SECTION( "A" ) { SKIP(); }
SECTION( "B" ) { SKIP(); }
}

0 comments on commit b2ddca6

Please sign in to comment.