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:
Martin Hořeňovský
2018-08-28 09:44:47 +02:00
parent 1a501fcb48
commit f061dabbad
5 changed files with 72 additions and 4 deletions

View 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 )

View 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

View 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{});
}