mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Add ExtraTests infrastructure
This means * a new cmake option, `CATCH_BUILD_EXTRA_TESTS`, that conditionally includes the ExtraTests subfolder * building and running them on some of the Travis build images * An example configuration test In the future these should be extended to cover most of the configuration options in Catch2, but this is a start.
This commit is contained in:
parent
1a501fcb48
commit
f061dabbad
@ -219,7 +219,7 @@ matrix:
|
|||||||
apt:
|
apt:
|
||||||
sources: *all_sources
|
sources: *all_sources
|
||||||
packages: ['lcov', 'g++-7']
|
packages: ['lcov', 'g++-7']
|
||||||
env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1
|
env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
@ -229,7 +229,7 @@ matrix:
|
|||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty
|
- llvm-toolchain-trusty
|
||||||
env: COMPILER='clang++-3.8' EXAMPLES=1 COVERAGE=1
|
env: COMPILER='clang++-3.8' EXAMPLES=1 COVERAGE=1 EXTRAS=1
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
@ -242,7 +242,7 @@ matrix:
|
|||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode9.1
|
osx_image: xcode9.1
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1
|
env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||||
@ -263,7 +263,7 @@ before_script:
|
|||||||
- python scripts/generateSingleHeader.py
|
- python scripts/generateSingleHeader.py
|
||||||
|
|
||||||
# Use Debug builds for running Valgrind and building examples
|
# Use Debug builds for running Valgrind and building examples
|
||||||
- cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE}
|
- cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} -DCATCH_BUILD_EXTRA_TESTS=${EXTRAS}
|
||||||
# Don't bother with release build for coverage build
|
# Don't bother with release build for coverage build
|
||||||
- cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14}
|
- cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ include(CTest)
|
|||||||
option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
|
option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
|
||||||
option(CATCH_BUILD_TESTING "Build SelfTest project" ON)
|
option(CATCH_BUILD_TESTING "Build SelfTest project" ON)
|
||||||
option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF)
|
option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF)
|
||||||
|
option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF)
|
||||||
option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
|
option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF)
|
||||||
option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
|
option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
|
||||||
option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
|
option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
|
||||||
@ -48,6 +49,9 @@ if(CATCH_BUILD_EXAMPLES)
|
|||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CATCH_BUILD_EXTRA_TESTS)
|
||||||
|
add_subdirectory(projects/ExtraTests)
|
||||||
|
endif()
|
||||||
|
|
||||||
# add catch as a 'linkable' target
|
# add catch as a 'linkable' target
|
||||||
add_library(Catch2 INTERFACE)
|
add_library(Catch2 INTERFACE)
|
||||||
|
29
projects/ExtraTests/CMakeLists.txt
Normal file
29
projects/ExtraTests/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#
|
||||||
|
# Build extra tests.
|
||||||
|
#
|
||||||
|
# Requires CATCH_BUILD_EXTRA_TESTS to be defined 'true', see ../CMakeLists.txt.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required( VERSION 3.5 )
|
||||||
|
|
||||||
|
project( Catch2ExtraTests LANGUAGES CXX )
|
||||||
|
|
||||||
|
message( STATUS "Extra tests included" )
|
||||||
|
|
||||||
|
# define folders used:
|
||||||
|
|
||||||
|
set( TESTS_DIR ${CATCH_DIR}/projects/ExtraTests )
|
||||||
|
set( SINGLE_INCLUDE_PATH ${CATCH_DIR}/single_include )
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
|
||||||
|
add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
|
||||||
|
set_tests_properties(FallbackStringifier PROPERTIES PASS_REGULAR_EXPRESSION "foo{} for: { !!! }")
|
||||||
|
|
||||||
|
|
||||||
|
set_property( TARGET FallbackStringifier PROPERTY CXX_STANDARD 11 )
|
||||||
|
set_property( TARGET FallbackStringifier PROPERTY CXX_STANDARD_REQUIRED ON )
|
||||||
|
set_property( TARGET FallbackStringifier PROPERTY CXX_EXTENSIONS OFF )
|
||||||
|
|
||||||
|
target_include_directories( FallbackStringifier PRIVATE ${SINGLE_INCLUDE_PATH} )
|
||||||
|
target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
|
12
projects/ExtraTests/ToDo.txt
Normal file
12
projects/ExtraTests/ToDo.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Configuration options that are left default and thus are not properly tested
|
||||||
|
yet:
|
||||||
|
|
||||||
|
CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases
|
||||||
|
CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows
|
||||||
|
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
||||||
|
CATCH_CONFIG_DISABLE_MATCHERS // Do not compile Matchers in this compilation unit
|
||||||
|
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
||||||
|
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
||||||
|
CATCH_CONFIG_DISABLE_STRINGIFICATION // Disable stringifying the original expression
|
||||||
|
CATCH_CONFIG_DISABLE // Disables assertions and test case registration
|
||||||
|
CATCH_CONFIG_DEFAULT_REPORTER
|
23
projects/ExtraTests/X10-FallbackStringifier.cpp
Normal file
23
projects/ExtraTests/X10-FallbackStringifier.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// X10-FallbackStringifier.cpp
|
||||||
|
// Test that defining fallbackStringifier compiles
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// A catch-all stringifier
|
||||||
|
template <typename T>
|
||||||
|
std::string fallbackStringifier(T const&) {
|
||||||
|
return "{ !!! }";
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
struct foo {
|
||||||
|
explicit operator bool() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("aa") {
|
||||||
|
REQUIRE(foo{});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user