forked from catchorg/Catch2
Compare commits
104 Commits
add_cstdin
...
v3.2.1
Author | SHA1 | Date | |
---|---|---|---|
ab6c7375be | |||
24607694cb | |||
28e651f152 | |||
2d7be1f7de | |||
1f3b51e903 | |||
a20200be7e | |||
291c502f66 | |||
ae1644e7e9 | |||
65cc7fd2ae | |||
c276b530ee | |||
8beb74da8a | |||
e932bcf7a3 | |||
6aa56c70e2 | |||
1cd86c09a2 | |||
b980d408b1 | |||
41990e0fe6 | |||
b65c0e27e9 | |||
6e77e16ea8 | |||
943c6e3dee | |||
066cc51ce6 | |||
b7f4a2efb8 | |||
f8006aa6d4 | |||
fdea5a52c2 | |||
297a17593f | |||
d1ef461471 | |||
0c75caf77b | |||
3b139ae51a | |||
5f9d4ef331 | |||
ec59cd8736 | |||
d7f8c36e4c | |||
b3dbd83da2 | |||
0a1b0ae9d1 | |||
272bed081e | |||
82cec69e93 | |||
b56c474260 | |||
12b4390169 | |||
3b40cf13eb | |||
223d8d6382 | |||
f1084fb309 | |||
d41da10c54 | |||
d2294ad9b6 | |||
e19ed221bd | |||
c6dfeb5e7d | |||
17fac854ae | |||
ffa152095c | |||
0ce8c25566 | |||
6185d0cc0a | |||
8ce92d2c72 | |||
a43f67962e | |||
f1361ef624 | |||
d1e7544e9f | |||
3fed2307e7 | |||
2d0dcc36e8 | |||
80d58a791d | |||
d7341b5dc1 | |||
38d926090a | |||
9d08689845 | |||
afc017ef52 | |||
fb68bb0bd5 | |||
77f7c0104d | |||
be060cde44 | |||
5df88da16e | |||
5cd8938905 | |||
6a422bae0b | |||
a07ac3f935 | |||
d8619f076b | |||
95cd95e591 | |||
eb7397544c | |||
d1394a7064 | |||
e94976ec9c | |||
0c962d11b3 | |||
bdf30834eb | |||
728de353be | |||
0e139b73e4 | |||
97313f9033 | |||
6a9bf2e0af | |||
980c20694e | |||
4db8b50aab | |||
4a7cefe601 | |||
243cf71608 | |||
4bb7e02a9c | |||
97d0b1e00e | |||
c0e582e659 | |||
0de60d8e7e | |||
d6bbd3fdef | |||
98d37da03e | |||
4b3defe4af | |||
c75430834d | |||
359542d53e | |||
dea1a6abd9 | |||
32eae0ecce | |||
4adf010549 | |||
686468d185 | |||
7b2e7d623b | |||
3ca5cf32e5 | |||
dc001fa935 | |||
33e70194d3 | |||
9bb206fc61 | |||
ab04e599e7 | |||
47d56f28a9 | |||
a118799631 | |||
997a7d4165 | |||
2b0fd854e2 | |||
a7dc85dd49 |
8
.bazelrc
8
.bazelrc
@ -1,4 +1,10 @@
|
||||
build --enable_platform_specific_config
|
||||
|
||||
build:gcc9 --cxxopt=-std=c++2a
|
||||
build:gcc11 --cxxopt=-std=c++2a
|
||||
build:clang13 --cxxopt=-std=c++17
|
||||
build:vs2019 --cxxopt=/std:c++17
|
||||
build:vs2022 --cxxopt=/std:c++17
|
||||
build:vs2022 --cxxopt=/std:c++17
|
||||
|
||||
build:windows --config=vs2022
|
||||
build:linux --config=gcc11
|
||||
|
@ -1,4 +1,26 @@
|
||||
---
|
||||
Language: Cpp
|
||||
Standard: c++14
|
||||
|
||||
# Note that we cannot use IncludeIsMainRegex functionality, because it
|
||||
# does not support includes in angle brackets (<>)
|
||||
SortIncludes: True
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '<catch2/.*\.hpp>'
|
||||
Priority: 1
|
||||
- Regex: '<.*/.*\.hpp>'
|
||||
Priority: 2
|
||||
- Regex: '<.*>'
|
||||
Priority: 3
|
||||
|
||||
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
|
||||
AccessModifierOffset: '-4'
|
||||
AlignEscapedNewlines: Left
|
||||
AllowAllConstructorInitializersOnNextLine: 'true'
|
||||
@ -8,17 +30,14 @@ BreakConstructorInitializers: AfterColon
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
|
||||
DerivePointerAlignment: 'false'
|
||||
FixNamespaceComments: 'true'
|
||||
IncludeBlocks: Regroup
|
||||
IndentCaseLabels: 'false'
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: '4'
|
||||
Language: Cpp
|
||||
NamespaceIndentation: All
|
||||
PointerAlignment: Left
|
||||
SpaceBeforeCtorInitializerColon: 'false'
|
||||
SpaceInEmptyParentheses: 'false'
|
||||
SpacesInParentheses: 'true'
|
||||
Standard: Cpp11
|
||||
TabWidth: '4'
|
||||
UseTab: Never
|
||||
|
||||
|
24
.github/workflows/linux-bazel-builds.yml
vendored
Normal file
24
.github/workflows/linux-bazel-builds.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: Bazel build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_and_test_ubuntu:
|
||||
name: Linux Ubuntu 22.04 Bazel build <GCC 11.2.0>
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
compilation_mode: [fastbuild, dbg, opt]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Mount bazel cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: "/home/runner/.cache/bazel"
|
||||
key: bazel-ubuntu22-gcc11
|
||||
|
||||
- name: Build Catch2
|
||||
run: |
|
||||
bazelisk build --compilation_mode=${{matrix.compilation_mode}} //...
|
43
.github/workflows/linux-meson-builds.yml
vendored
Normal file
43
.github/workflows/linux-meson-builds.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: Linux builds (meson)
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: meson ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}}
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
cxx:
|
||||
- g++-11
|
||||
- clang++-11
|
||||
build_type: [debug, release]
|
||||
std: [14, 17]
|
||||
include:
|
||||
- cxx: clang++-11
|
||||
other_pkgs: clang-11
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Prepare environment
|
||||
run: sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}}
|
||||
|
||||
- name: Configure build
|
||||
env:
|
||||
CXX: ${{matrix.cxx}}
|
||||
CXXFLAGS: -std=c++${{matrix.std}} ${{matrix.cxxflags}}
|
||||
# Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}.
|
||||
# This is important
|
||||
run: |
|
||||
meson -Dbuildtype=${{matrix.build_type}} ${{runner.workspace}}/meson-build
|
||||
|
||||
- name: Build tests + lib
|
||||
working-directory: ${{runner.workspace}}/meson-build
|
||||
run: ninja
|
||||
|
||||
- name: Run tests
|
||||
working-directory: ${{runner.workspace}}/meson-build
|
||||
# Hardcode 2 cores we know are there
|
||||
run: |
|
||||
meson test --verbose
|
1
.github/workflows/linux-other-builds.yml
vendored
1
.github/workflows/linux-other-builds.yml
vendored
@ -86,6 +86,7 @@ jobs:
|
||||
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||
-DCATCH_DEVELOPMENT_BUILD=ON \
|
||||
${{matrix.cmake_configurations}} \
|
||||
|
33
.github/workflows/linux-simple-builds.yml
vendored
33
.github/workflows/linux-simple-builds.yml
vendored
@ -9,7 +9,8 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
cxx:
|
||||
# - g++-6
|
||||
- g++-5
|
||||
- g++-6
|
||||
- g++-7
|
||||
- g++-8
|
||||
- g++-9
|
||||
@ -22,9 +23,10 @@ jobs:
|
||||
build_type: [Debug, Release]
|
||||
std: [14]
|
||||
include:
|
||||
# cannot be installed on ubuntu-20.04 be default?
|
||||
# - cxx: g++-6
|
||||
# other_pkgs: g++-6
|
||||
- cxx: g++-5
|
||||
other_pkgs: g++-5
|
||||
- cxx: g++-6
|
||||
other_pkgs: g++-6
|
||||
- cxx: g++-7
|
||||
other_pkgs: g++-7
|
||||
- cxx: g++-8
|
||||
@ -63,10 +65,32 @@ jobs:
|
||||
build_type: Release
|
||||
std: 17
|
||||
other_pkgs: clang-10
|
||||
- cxx: clang++-10
|
||||
build_type: Debug
|
||||
std: 20
|
||||
other_pkgs: clang-10
|
||||
- cxx: clang++-10
|
||||
build_type: Release
|
||||
std: 20
|
||||
other_pkgs: clang-10
|
||||
- cxx: g++-10
|
||||
build_type: Debug
|
||||
std: 20
|
||||
other_pkgs: g++-10
|
||||
- cxx: g++-10
|
||||
build_type: Release
|
||||
std: 20
|
||||
other_pkgs: g++-10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Add repositories for older GCC
|
||||
run: |
|
||||
sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic main'
|
||||
sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic universe'
|
||||
if: ${{ matrix.cxx == 'g++-5' || matrix.cxx == 'g++-6' }}
|
||||
|
||||
- name: Prepare environment
|
||||
run: sudo apt-get install -y ninja-build ${{matrix.other_pkgs}}
|
||||
|
||||
@ -81,6 +105,7 @@ jobs:
|
||||
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||
-DCATCH_DEVELOPMENT_BUILD=ON \
|
||||
-G Ninja
|
||||
|
15
.github/workflows/mac-builds.yml
vendored
15
.github/workflows/mac-builds.yml
vendored
@ -4,11 +4,15 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-10.15
|
||||
# macos-12 updated to a toolchain that crashes when linking the
|
||||
# test binary. This seems to be a known bug in that version,
|
||||
# and will eventually get fixed in an update. After that, we can go
|
||||
# back to newer macos images.
|
||||
runs-on: macos-11
|
||||
strategy:
|
||||
matrix:
|
||||
cxx:
|
||||
- g++-9
|
||||
- g++-11
|
||||
- clang++
|
||||
build_type: [Debug, Release]
|
||||
std: [14, 17]
|
||||
@ -29,8 +33,11 @@ jobs:
|
||||
# This is important
|
||||
run: |
|
||||
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||
-DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||
-DCATCH_DEVELOPMENT_BUILD=ON \
|
||||
-DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \
|
||||
-DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}}
|
||||
|
||||
- name: Build tests + lib
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
*.build
|
||||
!meson.build
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.ncb
|
||||
|
15
BUILD.bazel
15
BUILD.bazel
@ -1,14 +1,13 @@
|
||||
# Load the cc_library rule.
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
|
||||
|
||||
expand_template(
|
||||
name = "catch_user_config",
|
||||
out = "catch2/catch_user_config.hpp",
|
||||
substitutions = {
|
||||
"@CATCH_CONFIG_CONSOLE_WIDTH@": "80",
|
||||
"@CATCH_CONFIG_DEFAULT_REPORTER@": "console",
|
||||
"#cmakedefine CATCH_CONFIG_ANDROID_LOGWRITE": "",
|
||||
"#cmakedefine CATCH_CONFIG_BAZEL_SUPPORT": "#define CATCH_CONFIG_BAZEL_SUPPORT",
|
||||
"#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "",
|
||||
"#cmakedefine CATCH_CONFIG_COLOUR_WIN32": "",
|
||||
"#cmakedefine CATCH_CONFIG_COUNTER": "",
|
||||
"#cmakedefine CATCH_CONFIG_CPP11_TO_STRING": "",
|
||||
@ -29,7 +28,10 @@ expand_template(
|
||||
"#cmakedefine CATCH_CONFIG_EXPERIMENTAL_REDIRECT": "",
|
||||
"#cmakedefine CATCH_CONFIG_FALLBACK_STRINGIFIER @CATCH_CONFIG_FALLBACK_STRINGIFIER@": "",
|
||||
"#cmakedefine CATCH_CONFIG_FAST_COMPILE": "",
|
||||
"#cmakedefine CATCH_CONFIG_GETENV": "",
|
||||
"#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_COUNTER": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_CPP11_TO_STRING": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_BYTE": "",
|
||||
@ -37,6 +39,7 @@ expand_template(
|
||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_GETENV": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "",
|
||||
@ -45,13 +48,11 @@ expand_template(
|
||||
"#cmakedefine CATCH_CONFIG_NOSTDOUT": "",
|
||||
"#cmakedefine CATCH_CONFIG_POSIX_SIGNALS": "",
|
||||
"#cmakedefine CATCH_CONFIG_PREFIX_ALL": "",
|
||||
"#cmakedefine CATCH_CONFIG_SHARED_LIBRARY": "",
|
||||
"#cmakedefine CATCH_CONFIG_USE_ASYNC": "",
|
||||
"#cmakedefine CATCH_CONFIG_WCHAR": "",
|
||||
"#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG": "",
|
||||
"#cmakedefine CATCH_CONFIG_WINDOWS_SEH": "",
|
||||
"#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "",
|
||||
"@CATCH_CONFIG_DEFAULT_REPORTER@": "console",
|
||||
"@CATCH_CONFIG_CONSOLE_WIDTH@": "80",
|
||||
},
|
||||
template = "src/catch2/catch_user_config.hpp.in",
|
||||
)
|
||||
@ -88,4 +89,4 @@ cc_library(
|
||||
linkstatic = True,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":catch2"],
|
||||
)
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
# Copyright Catch2 Authors
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# (See accompanying file LICENSE.txt or copy at
|
||||
# https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
@ -40,6 +40,7 @@ set(_OverridableOptions
|
||||
"USE_ASYNC"
|
||||
"WCHAR"
|
||||
"WINDOWS_SEH"
|
||||
"GETENV"
|
||||
)
|
||||
|
||||
foreach(OptionName ${_OverridableOptions})
|
||||
@ -67,6 +68,7 @@ set(_OtherConfigOptions
|
||||
foreach(OptionName ${_OtherConfigOptions})
|
||||
AddConfigOption(${OptionName})
|
||||
endforeach()
|
||||
set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||
|
||||
set(CATCH_CONFIG_DEFAULT_REPORTER "console" CACHE STRING "Read docs/configuration.md for details. The name of the reporter should be without quotes.")
|
||||
set(CATCH_CONFIG_CONSOLE_WIDTH "80" CACHE STRING "Read docs/configuration.md for details. Must form a valid integer literal.")
|
||||
|
@ -1,18 +1,19 @@
|
||||
|
||||
# Copyright Catch2 Authors
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# (See accompanying file LICENSE.txt or copy at
|
||||
# https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
function(add_cxx_flag_if_supported_to_targets flagname targets)
|
||||
check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flagname})
|
||||
string(MAKE_C_IDENTIFIER ${flagname} flag_identifier )
|
||||
check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flag_identifier})
|
||||
|
||||
if (HAVE_FLAG_${flagname})
|
||||
if (HAVE_FLAG_${flag_identifier})
|
||||
foreach(target ${targets})
|
||||
target_compile_options(${target} PUBLIC ${flagname})
|
||||
target_compile_options(${target} PRIVATE ${flagname})
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
@ -112,9 +113,8 @@ endfunction()
|
||||
# Adds flags required for reproducible build to the target
|
||||
# Currently only supports GCC and Clang
|
||||
function(add_build_reproducibility_settings target)
|
||||
# Make the build reproducible on versions of g++ and clang that supports -ffile-prefix-map
|
||||
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 8) OR
|
||||
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 10))
|
||||
target_compile_options(${target} PRIVATE "-ffile-prefix-map=${CATCH_DIR}=.")
|
||||
# Make the build reproducible on versions of g++ and clang that supports -ffile-prefix-map
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
add_cxx_flag_if_supported_to_targets("-ffile-prefix-map=${CATCH_DIR}/=" "${target}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# detect if Catch is being bundled,
|
||||
# disable testsuite in that case
|
||||
@ -30,14 +30,8 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.8)
|
||||
# Enable IPO for CMake versions that support it
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
|
||||
|
||||
project(Catch2
|
||||
VERSION 3.1.0 # CML version placeholder, don't delete
|
||||
VERSION 3.2.1 # CML version placeholder, don't delete
|
||||
LANGUAGES CXX
|
||||
# HOMEPAGE_URL is not supported until CMake version 3.12, which
|
||||
# we do not target yet.
|
||||
|
69
README.md
69
README.md
@ -1,5 +1,5 @@
|
||||
<a id="top"></a>
|
||||

|
||||

|
||||
|
||||
[](https://github.com/catchorg/catch2/releases)
|
||||
[](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml)
|
||||
@ -11,31 +11,78 @@
|
||||
[](https://discord.gg/4CWS9zD)
|
||||
|
||||
|
||||
## What's the Catch2?
|
||||
## What is Catch2?
|
||||
|
||||
Catch2 is mainly a unit testing framework for C++, but it also
|
||||
provides basic micro-benchmarking features, and simple BDD macros.
|
||||
|
||||
Catch2's main advantage is that using it is both simple and natural.
|
||||
Tests autoregister themselves and do not have to be named with valid
|
||||
identifiers, assertions look like normal C++ code, and sections provide
|
||||
a nice way to share set-up and tear-down code in tests.
|
||||
Test names do not have to be valid identifiers, assertions look like
|
||||
normal C++ boolean expressions, and sections provide a nice and local way
|
||||
to share set-up and tear-down code in tests.
|
||||
|
||||
**Example unit test**
|
||||
```cpp
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
## Catch2 v3 is being developed!
|
||||
#include <cstdint>
|
||||
|
||||
You are on the `devel` branch, where the next major version, v3, of
|
||||
Catch2 is being developed. As it is a significant rework, you will
|
||||
find that parts of this documentation are likely still stuck on v2.
|
||||
uint32_t factorial( uint32_t number ) {
|
||||
return number <= 1 ? number : factorial(number-1) * number;
|
||||
}
|
||||
|
||||
For stable (and documentation-matching) version of Catch2, [go to the
|
||||
`v2.x` branch](https://github.com/catchorg/Catch2/tree/v2.x).
|
||||
TEST_CASE( "Factorials are computed", "[factorial]" ) {
|
||||
REQUIRE( factorial( 1) == 1 );
|
||||
REQUIRE( factorial( 2) == 2 );
|
||||
REQUIRE( factorial( 3) == 6 );
|
||||
REQUIRE( factorial(10) == 3'628'800 );
|
||||
}
|
||||
```
|
||||
|
||||
**Example microbenchmark**
|
||||
```cpp
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/benchmark/catch_benchmark.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
uint64_t fibonacci(uint64_t number) {
|
||||
return number < 2 ? 1 : fibonacci(number - 1) + fibonacci(number - 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Benchmark Fibonacci", "[!benchmark]") {
|
||||
REQUIRE(Fibonacci(5) == 5);
|
||||
|
||||
REQUIRE(Fibonacci(20) == 6'765);
|
||||
BENCHMARK("Fibonacci 20") {
|
||||
return Fibonacci(20);
|
||||
};
|
||||
|
||||
REQUIRE(Fibonacci(25) == 75'025);
|
||||
BENCHMARK("Fibonacci 25") {
|
||||
return Fibonacci(25);
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Catch2 v3 has been released!
|
||||
|
||||
You are on the `devel` branch, where the v3 version is being developed.
|
||||
v3 brings a bunch of significant changes, the big one being that Catch2
|
||||
is no longer a single-header library. Catch2 now behaves as a normal
|
||||
library, with multiple headers and separately compiled implementation.
|
||||
|
||||
The documentation is slowly being updated to take these changes into
|
||||
account, but this work is currently still ongoing.
|
||||
|
||||
For migrating from the v2 releases to v3, you should look at [our
|
||||
documentation](docs/migrate-v2-to-v3.md#top). It provides a simple
|
||||
guidelines on getting started, and collects most common migration
|
||||
problems.
|
||||
|
||||
For the previous major version of Catch2 [look into the `v2.x` branch
|
||||
here on GitHub](https://github.com/catchorg/Catch2/tree/v2.x).
|
||||
|
||||
|
||||
## How to use it
|
||||
This documentation comprises these three parts:
|
||||
|
14
WORKSPACE
14
WORKSPACE
@ -1,14 +0,0 @@
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
strip_prefix = "bazel-skylib-2a87d4a62af886fb320883aba102255aba87275e",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/bazel-skylib/archive/2a87d4a62af886fb320883aba102255aba87275e.tar.gz",
|
||||
],
|
||||
sha256 = "d847b08d6702d2779e9eb399b54ff8920fa7521dc45e3e53572d1d8907767de7",
|
||||
)
|
||||
|
||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
|
||||
bazel_skylib_workspace()
|
15
WORKSPACE.bazel
Normal file
15
WORKSPACE.bazel
Normal file
@ -0,0 +1,15 @@
|
||||
workspace(name = "catch2")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
|
||||
],
|
||||
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
|
||||
)
|
||||
|
||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
bazel_skylib_workspace()
|
BIN
data/artwork/catch2-logo-small-with-background.png
Normal file
BIN
data/artwork/catch2-logo-small-with-background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -4,34 +4,35 @@
|
||||
To get the most out of Catch2, start with the [tutorial](tutorial.md#top).
|
||||
Once you're up and running consider the following reference material.
|
||||
|
||||
Writing tests:
|
||||
**Writing tests:**
|
||||
* [Assertion macros](assertions.md#top)
|
||||
* [Matchers](matchers.md#top)
|
||||
* [Matchers (asserting complex properties)](matchers.md#top)
|
||||
* [Comparing floating point numbers](comparing-floating-point-numbers.md#top)
|
||||
* [Logging macros](logging.md#top)
|
||||
* [Test cases and sections](test-cases-and-sections.md#top)
|
||||
* [Test fixtures](test-fixtures.md#top)
|
||||
* [Reporters](reporters.md#top)
|
||||
* [Reporters (output customization)](reporters.md#top)
|
||||
* [Event Listeners](event-listeners.md#top)
|
||||
* [Data Generators](generators.md#top)
|
||||
* [Data Generators (value parameterized tests)](generators.md#top)
|
||||
* [Other macros](other-macros.md#top)
|
||||
* [Micro benchmarking](benchmarks.md#top)
|
||||
|
||||
Fine tuning:
|
||||
**Fine tuning:**
|
||||
* [Supplying your own main()](own-main.md#top)
|
||||
* [Compile-time configuration](configuration.md#top)
|
||||
* [String Conversions](tostring.md#top)
|
||||
|
||||
Running:
|
||||
**Running:**
|
||||
* [Command line](command-line.md#top)
|
||||
|
||||
Odds and ends:
|
||||
**Odds and ends:**
|
||||
* [Frequently Asked Questions (FAQ)](faq.md#top)
|
||||
* [Best practices and other tips](usage-tips.md#top)
|
||||
* [CMake integration](cmake-integration.md#top)
|
||||
* [CI and other miscellaneous pieces](ci-and-misc.md#top)
|
||||
* [Tooling integration (CI, test runners, other)](ci-and-misc.md#top)
|
||||
* [Known limitations](limitations.md#top)
|
||||
|
||||
Other:
|
||||
|
||||
**Other:**
|
||||
* [Why Catch2?](why-catch.md#top)
|
||||
* [Migrating from v2 to v3](migrate-v2-to-v3.md#top)
|
||||
* [Open Source Projects using Catch2](opensource-users.md#top)
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
**Contents**<br>
|
||||
[Natural Expressions](#natural-expressions)<br>
|
||||
[Floating point comparisons](#floating-point-comparisons)<br>
|
||||
[Exceptions](#exceptions)<br>
|
||||
[Matcher expressions](#matcher-expressions)<br>
|
||||
[Thread Safety](#thread-safety)<br>
|
||||
@ -19,7 +20,7 @@ Most of these macros come in two forms:
|
||||
The ```REQUIRE``` family of macros tests an expression and aborts the test case if it fails.
|
||||
The ```CHECK``` family are equivalent but execution continues in the same test case even if the assertion fails. This is useful if you have a series of essentially orthogonal assertions and it is useful to see all the results rather than stopping at the first failure.
|
||||
|
||||
* **REQUIRE(** _expression_ **)** and
|
||||
* **REQUIRE(** _expression_ **)** and
|
||||
* **CHECK(** _expression_ **)**
|
||||
|
||||
Evaluates the expression and records the result. If an exception is thrown, it is caught, reported, and counted as a failure. These are the macros you will use most of the time.
|
||||
@ -31,98 +32,78 @@ CHECK( thisReturnsTrue() );
|
||||
REQUIRE( i == 42 );
|
||||
```
|
||||
|
||||
* **REQUIRE_FALSE(** _expression_ **)** and
|
||||
Expressions prefixed with `!` cannot be decomposed. If you have a type
|
||||
that is convertible to bool and you want to assert that it evaluates to
|
||||
false, use the two forms below:
|
||||
|
||||
|
||||
* **REQUIRE_FALSE(** _expression_ **)** and
|
||||
* **CHECK_FALSE(** _expression_ **)**
|
||||
|
||||
Evaluates the expression and records the _logical NOT_ of the result. If an exception is thrown it is caught, reported, and counted as a failure.
|
||||
(these forms exist as a workaround for the fact that ! prefixed expressions cannot be decomposed).
|
||||
Note that there is no reason to use these forms for plain bool variables,
|
||||
because there is no added value in decomposing them.
|
||||
|
||||
Example:
|
||||
```
|
||||
REQUIRE_FALSE( thisReturnsFalse() );
|
||||
```
|
||||
|
||||
Do note that "overly complex" expressions cannot be decomposed and thus will not compile. This is done partly for practical reasons (to keep the underlying expression template machinery to minimum) and partly for philosophical reasons (assertions should be simple and deterministic).
|
||||
|
||||
Examples:
|
||||
* `CHECK(a == 1 && b == 2);`
|
||||
This expression is too complex because of the `&&` operator. If you want to check that 2 or more properties hold, you can either put the expression into parenthesis, which stops decomposition from working, or you need to decompose the expression into two assertions: `CHECK( a == 1 ); CHECK( b == 2);`
|
||||
* `CHECK( a == 2 || b == 1 );`
|
||||
This expression is too complex because of the `||` operator. If you want to check that one of several properties hold, you can put the expression into parenthesis (unlike with `&&`, expression decomposition into several `CHECK`s is not possible).
|
||||
|
||||
|
||||
### Floating point comparisons
|
||||
|
||||
When comparing floating point numbers - especially if at least one of them has been computed - great care must be taken to allow for rounding errors and inexact representations.
|
||||
|
||||
Catch provides a way to perform tolerant comparisons of floating point values through use of a wrapper class called `Approx`. `Approx` can be used on either side of a comparison expression. It overloads the comparisons operators to take a tolerance into account. Here's a simple example:
|
||||
|
||||
```cpp
|
||||
REQUIRE( performComputation() == Approx( 2.1 ) );
|
||||
Status ret = someFunction();
|
||||
REQUIRE_FALSE(ret); // ret must evaluate to false, and Catch2 will print
|
||||
// out the value of ret if possibly
|
||||
```
|
||||
|
||||
Catch also provides a user-defined literal for `Approx`; `_a`. It resides in
|
||||
the `Catch::literals` namespace and can be used like so:
|
||||
```cpp
|
||||
using namespace Catch::literals;
|
||||
REQUIRE( performComputation() == 2.1_a );
|
||||
```
|
||||
|
||||
`Approx` is constructed with defaults that should cover most simple cases.
|
||||
For the more complex cases, `Approx` provides 3 customization points:
|
||||
### Other limitations
|
||||
|
||||
* __epsilon__ - epsilon serves to set the coefficient by which a result
|
||||
can differ from `Approx`'s value before it is rejected.
|
||||
_By default set to `std::numeric_limits<float>::epsilon()*100`._
|
||||
* __margin__ - margin serves to set the the absolute value by which
|
||||
a result can differ from `Approx`'s value before it is rejected.
|
||||
_By default set to `0.0`._
|
||||
* __scale__ - scale is used to change the magnitude of `Approx` for relative check.
|
||||
_By default set to `0.0`._
|
||||
Note that expressions containing either of the binary logical operators,
|
||||
`&&` or `||`, cannot be decomposed and will not compile. The reason behind
|
||||
this is that it is impossible to overload `&&` and `||` in a way that
|
||||
keeps their short-circuiting semantics, and expression decomposition
|
||||
relies on overloaded operators to work.
|
||||
|
||||
#### epsilon example
|
||||
```cpp
|
||||
Approx target = Approx(100).epsilon(0.01);
|
||||
100.0 == target; // Obviously true
|
||||
200.0 == target; // Obviously still false
|
||||
100.5 == target; // True, because we set target to allow up to 1% difference
|
||||
```
|
||||
Simple example of an issue with overloading binary logical operators
|
||||
is a common pointer idiom, `p && p->foo == 2`. Using the built-in `&&`
|
||||
operator, `p` is only dereferenced if it is not null. With overloaded
|
||||
`&&`, `p` is always dereferenced, thus causing a segfault if
|
||||
`p == nullptr`.
|
||||
|
||||
#### margin example
|
||||
```cpp
|
||||
Approx target = Approx(100).margin(5);
|
||||
100.0 == target; // Obviously true
|
||||
200.0 == target; // Obviously still false
|
||||
104.0 == target; // True, because we set target to allow absolute difference of at most 5
|
||||
```
|
||||
If you want to test expression that contains `&&` or `||`, you have two
|
||||
options.
|
||||
|
||||
#### scale
|
||||
Scale can be useful if the computation leading to the result worked
|
||||
on different scale than is used by the results. Since allowed difference
|
||||
between Approx's value and compared value is based primarily on Approx's value
|
||||
(the allowed difference is computed as
|
||||
`(Approx::scale + Approx::value) * epsilon`), the resulting comparison could
|
||||
need rescaling to be correct.
|
||||
1) Enclose it in parentheses. Parentheses force evaluation of the expression
|
||||
before the expression decomposition can touch it, and thus it cannot
|
||||
be used.
|
||||
|
||||
2) Rewrite the expression. `REQUIRE(a == 1 && b == 2)` can always be split
|
||||
into `REQUIRE(a == 1); REQUIRE(b == 2);`. Alternatively, if this is a
|
||||
common pattern in your tests, think about using [Matchers](#matcher-expressions).
|
||||
instead. There is no simple rewrite rule for `||`, but I generally
|
||||
believe that if you have `||` in your test expression, you should rethink
|
||||
your tests.
|
||||
|
||||
|
||||
## Floating point comparisons
|
||||
|
||||
Comparing floating point numbers is complex, and [so it has its own
|
||||
documentation page](comparing-floating-point-numbers.md#top).
|
||||
|
||||
|
||||
## Exceptions
|
||||
|
||||
* **REQUIRE_NOTHROW(** _expression_ **)** and
|
||||
* **REQUIRE_NOTHROW(** _expression_ **)** and
|
||||
* **CHECK_NOTHROW(** _expression_ **)**
|
||||
|
||||
Expects that no exception is thrown during evaluation of the expression.
|
||||
|
||||
* **REQUIRE_THROWS(** _expression_ **)** and
|
||||
* **REQUIRE_THROWS(** _expression_ **)** and
|
||||
* **CHECK_THROWS(** _expression_ **)**
|
||||
|
||||
Expects that an exception (of any type) is be thrown during evaluation of the expression.
|
||||
|
||||
* **REQUIRE_THROWS_AS(** _expression_, _exception type_ **)** and
|
||||
* **REQUIRE_THROWS_AS(** _expression_, _exception type_ **)** and
|
||||
* **CHECK_THROWS_AS(** _expression_, _exception type_ **)**
|
||||
|
||||
Expects that an exception of the _specified type_ is thrown during evaluation of the expression. Note that the _exception type_ is extended with `const&` and you should not include it yourself.
|
||||
|
||||
* **REQUIRE_THROWS_WITH(** _expression_, _string or string matcher_ **)** and
|
||||
* **REQUIRE_THROWS_WITH(** _expression_, _string or string matcher_ **)** and
|
||||
* **CHECK_THROWS_WITH(** _expression_, _string or string matcher_ **)**
|
||||
|
||||
Expects that an exception is thrown that, when converted to a string, matches the _string_ or _string matcher_ provided (see next section for Matchers).
|
||||
@ -158,8 +139,8 @@ REQUIRE_NOTHROW([&](){
|
||||
|
||||
To support Matchers a slightly different form is used. Matchers have [their own documentation](matchers.md#top).
|
||||
|
||||
* **REQUIRE_THAT(** _lhs_, _matcher expression_ **)** and
|
||||
* **CHECK_THAT(** _lhs_, _matcher expression_ **)**
|
||||
* **REQUIRE_THAT(** _lhs_, _matcher expression_ **)** and
|
||||
* **CHECK_THAT(** _lhs_, _matcher expression_ **)**
|
||||
|
||||
Matchers can be composed using `&&`, `||` and `!` operators.
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
<a id="top"></a>
|
||||
# CI and other odd pieces
|
||||
# Tooling integration (CI, test runners and so on)
|
||||
|
||||
**Contents**<br>
|
||||
[Continuous Integration systems](#continuous-integration-systems)<br>
|
||||
[Other reporters](#other-reporters)<br>
|
||||
[Bazel test runner integration](#bazel-test-runner-integration)<br>
|
||||
[Low-level tools](#low-level-tools)<br>
|
||||
[CMake](#cmake)<br>
|
||||
|
||||
This page talks about how Catch integrates with Continuous Integration
|
||||
Build Systems may refer to low-level tools, like CMake, or larger systems that run on servers, like Jenkins or TeamCity. This page will talk about both.
|
||||
This page talks about Catch2's integration with other related tooling,
|
||||
like Continuous Integration and 3rd party test runners.
|
||||
|
||||
|
||||
## Continuous Integration systems
|
||||
|
||||
@ -17,9 +18,9 @@ Probably the most important aspect to using Catch with a build server is the use
|
||||
Two of these reporters are built in (XML and JUnit) and the third (TeamCity) is included as a separate header. It's possible that the other two may be split out in the future too - as that would make the core of Catch smaller for those that don't need them.
|
||||
|
||||
### XML Reporter
|
||||
```-r xml```
|
||||
```-r xml```
|
||||
|
||||
The XML Reporter writes in an XML format that is specific to Catch.
|
||||
The XML Reporter writes in an XML format that is specific to Catch.
|
||||
|
||||
The advantage of this format is that it corresponds well to the way Catch works (especially the more unusual features, such as nested sections) and is a fully streaming format - that is it writes output as it goes, without having to store up all its results before it can start writing.
|
||||
|
||||
@ -34,19 +35,6 @@ The advantage of this format is that the JUnit Ant schema is widely understood b
|
||||
|
||||
The disadvantage is that this schema was designed to correspond to how JUnit works - and there is a significant mismatch with how Catch works. Additionally the format is not streamable (because opening elements hold counts of failed and passing tests as attributes) - so the whole test run must complete before it can be written.
|
||||
|
||||
## Other reporters
|
||||
Other reporters are not part of the single-header distribution and need
|
||||
to be downloaded and included separately. All reporters are stored in
|
||||
`single_include` directory in the git repository, and are named
|
||||
`catch_reporter_*.hpp`. For example, to use the TeamCity reporter you
|
||||
need to download `single_include/catch_reporter_teamcity.hpp` and include
|
||||
it after Catch itself.
|
||||
|
||||
```cpp
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
#include "catch_reporter_teamcity.hpp"
|
||||
```
|
||||
|
||||
### TeamCity Reporter
|
||||
```-r teamcity```
|
||||
@ -69,19 +57,29 @@ Because of the incremental nature of Catch's test suites and ability to run spec
|
||||
```-r sonarqube```
|
||||
[SonarQube Generic Test Data](https://docs.sonarqube.org/latest/analysis/generic-test/) XML format for tests metrics.
|
||||
|
||||
|
||||
## Bazel test runner integration
|
||||
|
||||
Catch2 understands some of the environment variables Bazel uses to control
|
||||
test execution. Specifically it understands
|
||||
|
||||
* JUnit output path via `XML_OUTPUT_FILE`
|
||||
* Test filtering via `TESTBRIDGE_TEST_ONLY`
|
||||
* Test sharding via `TEST_SHARD_INDEX`, `TEST_TOTAL_SHARDS`, and `TEST_SHARD_STATUS_FILE`
|
||||
|
||||
> Support for `XML_OUTPUT_FILE` was [introduced](https://github.com/catchorg/Catch2/pull/2399) in Catch2 3.0.1
|
||||
|
||||
> Support for `TESTBRIDGE_TEST_ONLY` and sharding was introduced in Catch2 3.2.0
|
||||
|
||||
This integration is enabled via either a [compile time configuration
|
||||
option](configuration.md#bazel-support), or via `BAZEL_TEST` environment
|
||||
variable set to "1".
|
||||
|
||||
> Support for `BAZEL_TEST` was [introduced](https://github.com/catchorg/Catch2/pull/2459) in Catch2 3.1.0
|
||||
|
||||
|
||||
## Low-level tools
|
||||
|
||||
### Precompiled headers (PCHs)
|
||||
|
||||
Catch offers prototypal support for being included in precompiled headers, but because of its single-header nature it does need some actions by the user:
|
||||
* The precompiled header needs to define `CATCH_CONFIG_ALL_PARTS`
|
||||
* The implementation file needs to
|
||||
* undefine `TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED`
|
||||
* define `CATCH_CONFIG_IMPL_ONLY`
|
||||
* define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`
|
||||
* include "catch.hpp" again
|
||||
|
||||
|
||||
### CodeCoverage module (GCOV, LCOV...)
|
||||
|
||||
If you are using GCOV tool to get testing coverage of your code, and are not sure how to integrate it with CMake and Catch, there should be an external example over at https://github.com/fkromer/catch_cmake_coverage
|
||||
|
@ -112,7 +112,7 @@ catch_discover_tests()
|
||||
```
|
||||
|
||||
#### Customization
|
||||
`catch_discover_tests` can be given several extra argumets:
|
||||
`catch_discover_tests` can be given several extra arguments:
|
||||
```cmake
|
||||
catch_discover_tests(target
|
||||
[TEST_SPEC arg1...]
|
||||
|
@ -284,7 +284,7 @@ This option transforms tabs and newline characters into ```\t``` and ```\n``` re
|
||||
<pre>-w, --warn <warning name></pre>
|
||||
|
||||
You can think of Catch2's warnings as the equivalent of `-Werror` (`/WX`)
|
||||
flag for C++ compilers. It turns some suspicious occurences, like a section
|
||||
flag for C++ compilers. It turns some suspicious occurrences, like a section
|
||||
without assertions, into errors. Because these might be intended, warnings
|
||||
are not enabled by default, but user can opt in.
|
||||
|
||||
@ -313,7 +313,7 @@ When set to ```yes``` Catch will report the duration of each test case, in milli
|
||||
> `--min-duration` was [introduced](https://github.com/catchorg/Catch2/pull/1910) in Catch2 2.13.0
|
||||
|
||||
When set, Catch will report the duration of each test case that took more
|
||||
than <value> seconds, in milliseconds. This option is overriden by both
|
||||
than <value> seconds, in milliseconds. This option is overridden by both
|
||||
`-d yes` and `-d no`, so that either all durations are reported, or none
|
||||
are.
|
||||
|
||||
@ -339,8 +339,8 @@ Test cases are ordered one of three ways:
|
||||
|
||||
### decl
|
||||
Declaration order (this is the default order if no --order argument is provided).
|
||||
Tests in the same TU are sorted using their declaration orders, different
|
||||
TUs are in an implementation (linking) dependent order.
|
||||
Tests in the same translation unit are sorted using their declaration orders,
|
||||
different TUs are sorted in an implementation (linking) dependent order.
|
||||
|
||||
|
||||
### lex
|
||||
@ -548,7 +548,8 @@ starting at 0. The tests in the set given by
|
||||
`--shard-index <#shard index to run>` will be executed. The default shard
|
||||
count is `1`, and the default index to run is `0`.
|
||||
|
||||
_It is an error to specify a shard index greater than the number of shards._
|
||||
_Shard index must be less than number of shards. As the name suggests,
|
||||
it is treated as an index of the shard to run._
|
||||
|
||||
Sharding is useful when you want to split test execution across multiple
|
||||
processes, as is done with the [Bazel test sharding](https://docs.bazel.build/versions/main/test-encyclopedia.html#test-sharding).
|
||||
@ -570,7 +571,7 @@ tests still returns 0.
|
||||
-v, --verbosity <quiet|normal|high>
|
||||
```
|
||||
|
||||
Changing verbosity might change how much details Catch2's reporters output.
|
||||
Changing verbosity might change how many details Catch2's reporters output.
|
||||
However, you should consider changing the verbosity level as a _suggestion_.
|
||||
Not all reporters support all verbosity levels, e.g. because the reporter's
|
||||
format cannot meaningfully change. In that case, the verbosity level is
|
||||
|
@ -6,7 +6,7 @@ some of them that are willing to share this information.
|
||||
|
||||
If you want to add your organisation, please check that there is no issue
|
||||
with you sharing this fact.
|
||||
|
||||
|
||||
- Bloomberg
|
||||
- [Bloomlife](https://bloomlife.com)
|
||||
- [Inscopix Inc.](https://www.inscopix.com/)
|
||||
@ -16,7 +16,7 @@ with you sharing this fact.
|
||||
- [Nexus Software Systems](https://nexwebsites.com)
|
||||
- [UX3D](https://ux3d.io)
|
||||
- [King](https://king.com)
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
192
docs/comparing-floating-point-numbers.md
Normal file
192
docs/comparing-floating-point-numbers.md
Normal file
@ -0,0 +1,192 @@
|
||||
<a id="top"></a>
|
||||
# Comparing floating point numbers with Catch2
|
||||
|
||||
If you are not deeply familiar with them, floating point numbers can be
|
||||
unintuitive. This also applies to comparing floating point numbers for
|
||||
(in)equality.
|
||||
|
||||
This page assumes that you have some understanding of both FP, and the
|
||||
meaning of different kinds of comparisons, and only goes over what
|
||||
functionality Catch2 provides to help you with comparing floating point
|
||||
numbers. If you do not have this understanding, we recommend that you first
|
||||
study up on floating point numbers and their comparisons, e.g. by [reading
|
||||
this blog post](https://codingnest.com/the-little-things-comparing-floating-point-numbers/).
|
||||
|
||||
|
||||
## Floating point matchers
|
||||
|
||||
```
|
||||
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||
```
|
||||
|
||||
[Matchers](matchers.md#top) are the preferred way of comparing floating
|
||||
point numbers in Catch2. We provide 3 of them:
|
||||
|
||||
* `WithinAbs(double target, double margin)`,
|
||||
* `WithinRel(FloatingPoint target, FloatingPoint eps)`, and
|
||||
* `WithinULP(FloatingPoint target, uint64_t maxUlpDiff)`.
|
||||
|
||||
> `WithinRel` matcher was introduced in Catch2 2.10.0
|
||||
|
||||
As with all matchers, you can combine multiple floating point matchers
|
||||
in a single assertion. For example, to check that some computation matches
|
||||
a known good value within 0.1% or is close enough (no different to 5
|
||||
decimal places) to zero, we would write this assertion:
|
||||
|
||||
```cpp
|
||||
REQUIRE_THAT( computation(input),
|
||||
Catch::Matchers::WithinRel(expected, 0.001)
|
||||
|| Catch::Matchers::WithinAbs(0, 0.000001) );
|
||||
```
|
||||
|
||||
|
||||
### WithinAbs
|
||||
|
||||
`WithinAbs` creates a matcher that accepts floating point numbers whose
|
||||
difference with `target` is less-or-equal to the `margin`. Since `float`
|
||||
can be converted to `double` without losing precision, only `double`
|
||||
overload exists.
|
||||
|
||||
```cpp
|
||||
REQUIRE_THAT(1.0, WithinAbs(1.2, 0.2));
|
||||
REQUIRE_THAT(0.f, !WithinAbs(1.0, 0.5));
|
||||
// Notice that infinity == infinity for WithinAbs
|
||||
REQUIRE_THAT(INFINITY, WithinAbs(INFINITY, 0));
|
||||
```
|
||||
|
||||
|
||||
### WithinRel
|
||||
|
||||
`WithinRel` creates a matcher that accepts floating point numbers that
|
||||
are _approximately equal_ to the `target` with a tolerance of `eps.`
|
||||
Specifically, it matches if
|
||||
`|arg - target| <= eps * max(|arg|, |target|)` holds. If you do not
|
||||
specify `eps`, `std::numeric_limits<FloatingPoint>::epsilon * 100`
|
||||
is used as the default.
|
||||
|
||||
```cpp
|
||||
// Notice that WithinRel comparison is symmetric, unlike Approx's.
|
||||
REQUIRE_THAT(1.0, WithinRel(1.1, 0.1));
|
||||
REQUIRE_THAT(1.1, WithinRel(1.0, 0.1));
|
||||
// Notice that inifnity == infinity for WithinRel
|
||||
REQUIRE_THAT(INFINITY, WithinRel(INFINITY));
|
||||
```
|
||||
|
||||
|
||||
### WithinULP
|
||||
|
||||
`WithinULP` creates a matcher that accepts floating point numbers that
|
||||
are no more than `maxUlpDiff`
|
||||
[ULPs](https://en.wikipedia.org/wiki/Unit_in_the_last_place)
|
||||
away from the `target` value. The short version of what this means
|
||||
is that there is no more than `maxUlpDiff - 1` representable floating
|
||||
point numbers between the argument for matching and the `target` value.
|
||||
|
||||
When using the ULP matcher in Catch2, it is important to keep in mind
|
||||
that Catch2 interprets ULP distance slightly differently than
|
||||
e.g. `std::nextafter` does.
|
||||
|
||||
Catch2's ULP calculation obeys these relations:
|
||||
* `ulpDistance(-x, x) == 2 * ulpDistance(x, 0)`
|
||||
* `ulpDistance(-0, 0) == 0` (due to the above)
|
||||
* `ulpDistance(DBL_MAX, INFINITY) == 1`
|
||||
* `ulpDistancE(NaN, x) == infinity`
|
||||
|
||||
|
||||
**Important**: The WithinULP matcher requires the platform to use the
|
||||
[IEEE-754](https://en.wikipedia.org/wiki/IEEE_754) representation for
|
||||
floating point numbers.
|
||||
|
||||
```cpp
|
||||
REQUIRE_THAT( -0.f, WithinULP( 0.f, 0 ) );
|
||||
```
|
||||
|
||||
|
||||
## `Approx`
|
||||
|
||||
```
|
||||
#include <catch2/catch_approx.hpp>
|
||||
```
|
||||
|
||||
**We strongly recommend against using `Approx` when writing new code.**
|
||||
You should be using floating point matchers instead.
|
||||
|
||||
Catch2 provides one more way to handle floating point comparisons. It is
|
||||
`Approx`, a special type with overloaded comparison operators, that can
|
||||
be used in standard assertions, e.g.
|
||||
|
||||
```cpp
|
||||
REQUIRE(0.99999 == Catch::Approx(1));
|
||||
```
|
||||
|
||||
`Approx` supports four comparison operators, `==`, `!=`, `<=`, `>=`, and can
|
||||
also be used with strong typedefs over `double`s. It can be used for both
|
||||
relative and margin comparisons by using its three customization points.
|
||||
Note that the semantics of this is always that of an _or_, so if either
|
||||
the relative or absolute margin comparison passes, then the whole comparison
|
||||
passes.
|
||||
|
||||
The downside to `Approx` is that it has a couple of issues that we cannot
|
||||
fix without breaking backwards compatibility. Because Catch2 also provides
|
||||
complete set of matchers that implement different floating point comparison
|
||||
methods, `Approx` is left as-is, is considered deprecated, and should
|
||||
not be used in new code.
|
||||
|
||||
The issues are
|
||||
* All internal computation is done in `double`s, leading to slightly
|
||||
different results if the inputs were floats.
|
||||
* `Approx`'s relative margin comparison is not symmetric. This means
|
||||
that `Approx( 10 ).epsilon(0.1) != 11.1` but `Approx( 11.1 ).epsilon(0.1) == 10`.
|
||||
* By default, `Approx` only uses relative margin comparison. This means
|
||||
that `Approx(0) == X` only passes for `X == 0`.
|
||||
|
||||
|
||||
### Approx details
|
||||
|
||||
If you still want/need to know more about `Approx`, read on.
|
||||
|
||||
Catch2 provides a UDL for `Approx`; `_a`. It resides in the `Catch::literals`
|
||||
namespace, and can be used like this:
|
||||
|
||||
```cpp
|
||||
using namespace Catch::literals;
|
||||
REQUIRE( performComputation() == 2.1_a );
|
||||
```
|
||||
|
||||
`Approx` has three customization points for the comparison:
|
||||
|
||||
* **epsilon** - epsilon sets the coefficient by which a result
|
||||
can differ from `Approx`'s value before it is rejected.
|
||||
_Defaults to `std::numeric_limits<float>::epsilon()*100`._
|
||||
|
||||
```cpp
|
||||
Approx target = Approx(100).epsilon(0.01);
|
||||
100.0 == target; // Obviously true
|
||||
200.0 == target; // Obviously still false
|
||||
100.5 == target; // True, because we set target to allow up to 1% difference
|
||||
```
|
||||
|
||||
|
||||
* **margin** - margin sets the absolute value by which
|
||||
a result can differ from `Approx`'s value before it is rejected.
|
||||
_Defaults to `0.0`._
|
||||
|
||||
```cpp
|
||||
Approx target = Approx(100).margin(5);
|
||||
100.0 == target; // Obviously true
|
||||
200.0 == target; // Obviously still false
|
||||
104.0 == target; // True, because we set target to allow absolute difference of at most 5
|
||||
```
|
||||
|
||||
* **scale** - scale is used to change the magnitude of `Approx` for the relative check.
|
||||
_By default, set to `0.0`._
|
||||
|
||||
Scale could be useful if the computation leading to the result worked
|
||||
on a different scale than is used by the results. Approx's scale is added
|
||||
to Approx's value when computing the allowed relative margin from the
|
||||
Approx's value.
|
||||
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md#top)
|
@ -19,7 +19,7 @@
|
||||
Catch2 is designed to "just work" as much as possible, and most of the
|
||||
configuration options below are changed automatically during compilation,
|
||||
according to the detected environment. However, this detection can also
|
||||
be overriden by users, using macros documented below, and/or CMake options
|
||||
be overridden by users, using macros documented below, and/or CMake options
|
||||
with the same name.
|
||||
|
||||
|
||||
@ -98,13 +98,19 @@ is equivalent with the out-of-the-box experience.
|
||||
|
||||
|
||||
## Bazel support
|
||||
When `CATCH_CONFIG_BAZEL_SUPPORT` is defined or when `BAZEL_TEST=1` (which is set by the Bazel inside of a test environment),
|
||||
Catch2 will register a `JUnit` reporter writing to a path pointed by `XML_OUTPUT_FILE` provided by Bazel.
|
||||
|
||||
Compiling Catch2 with `CATCH_CONFIG_BAZEL_SUPPORT` force-enables Catch2's
|
||||
support for Bazel's environment variables (normally Catch2 looks for
|
||||
`BAZEL_TEST=1` env var first).
|
||||
|
||||
This can be useful if you are using older versions of Bazel, that do not
|
||||
yet have `BAZEL_TEST` env var support.
|
||||
|
||||
> `CATCH_CONFIG_BAZEL_SUPPORT` was [introduced](https://github.com/catchorg/Catch2/pull/2399) in Catch2 3.0.1.
|
||||
|
||||
> `CATCH_CONFIG_BAZEL_SUPPORT` was [deprecated](https://github.com/catchorg/Catch2/pull/2459) in Catch2 3.1.0.
|
||||
|
||||
|
||||
## C++11 toggles
|
||||
|
||||
CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string`
|
||||
@ -149,13 +155,20 @@ by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`.
|
||||
CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
|
||||
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
|
||||
CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter
|
||||
CATCH_CONFIG_GETENV // System has a working `getenv`
|
||||
|
||||
> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch2 2.10.0
|
||||
|
||||
> `CATCH_CONFIG_GETENV` was [introduced](https://github.com/catchorg/Catch2/pull/2562) in Catch2 3.2.0
|
||||
|
||||
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
||||
|
||||
`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`).
|
||||
|
||||
`CATCH_CONFIG_GETENV` is on by default, except when Catch2 is compiled for
|
||||
platforms that lacks working `std::getenv` (currently Windows UWP and
|
||||
Playstation).
|
||||
|
||||
`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's
|
||||
CRT is used to check for memory leaks, and displays them after the tests
|
||||
finish running. This option only works when linking against the default
|
||||
|
@ -125,7 +125,7 @@ information that you will need for updating Catch2's documentation, and
|
||||
possibly some generic advise as well.
|
||||
|
||||
|
||||
### Technicalities
|
||||
### Technicalities
|
||||
|
||||
First, the technicalities:
|
||||
|
||||
@ -203,7 +203,7 @@ and so on.
|
||||
|
||||
Catch2 currently targets C++14 as the minimum supported C++ version.
|
||||
Features from higher language versions should be used only sparingly,
|
||||
when the benefits from using them outweight the maintenance overhead.
|
||||
when the benefits from using them outweigh the maintenance overhead.
|
||||
|
||||
Example of good use of polyfilling features is our use of `conjunction`,
|
||||
where if available we use `std::conjunction` and otherwise provide our
|
||||
@ -291,7 +291,7 @@ Specifically, every source file should start with the licence header:
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -303,6 +303,20 @@ be `CATCH_MATCHERS_FOO_HPP_INCLUDED`, for `catch_generators_bar.hpp`, the includ
|
||||
guard should be `CATCH_GENERATORS_BAR_HPP_INCLUDED`, and so on.
|
||||
|
||||
|
||||
### Adding new `CATCH_CONFIG` option
|
||||
|
||||
When adding new `CATCH_CONFIG` option, there are multiple places to edit:
|
||||
* `CMake/CatchConfigOptions.cmake` - this is used to generate the
|
||||
configuration options in CMake, so that CMake frontends know about them.
|
||||
* `docs/configuration.md` - this is where the options are documented
|
||||
* `src/catch2/catch_user_config.hpp.in` - this is template for generating
|
||||
`catch_user_config.hpp` which contains the materialized configuration
|
||||
* `BUILD.bazel` - Bazel does not have configuration support like CMake,
|
||||
and all expansions need to be done manually
|
||||
* other files as needed, e.g. `catch2/internal/catch_config_foo.hpp`
|
||||
for the logic that guards the configuration
|
||||
|
||||
|
||||
## CoC
|
||||
|
||||
This project has a [CoC](../CODE_OF_CONDUCT.md). Please adhere to it
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
CATCH_REGISTER_LISTENER(testRunListener)
|
||||
```
|
||||
|
||||
_Note that you should not use any assertion macros within a Listener!_
|
||||
_Note that you should not use any assertion macros within a Listener!_
|
||||
|
||||
[You can find the list of events that the listeners can react to on its
|
||||
own page](reporter-events.md#top).
|
||||
|
34
docs/faq.md
34
docs/faq.md
@ -7,6 +7,10 @@
|
||||
[Why cannot I derive from the built-in reporters?](#why-cannot-i-derive-from-the-built-in-reporters)<br>
|
||||
[What is Catch2's ABI stability policy?](#what-is-catch2s-abi-stability-policy)<br>
|
||||
[What is Catch2's API stability policy?](#what-is-catch2s-api-stability-policy)<br>
|
||||
[Does Catch2 support running tests in parallel?](#does-catch2-support-running-tests-in-parallel)<br>
|
||||
[Can I compile Catch2 into a dynamic library?](#can-i-compile-catch2-into-a-dynamic-library)<br>
|
||||
[What repeatability guarantees does Catch2 provide?](#what-repeatability-guarantees-does-catch2-provide)<br>
|
||||
|
||||
|
||||
## How do I run global setup/teardown only if tests will be run?
|
||||
|
||||
@ -23,7 +27,7 @@ depending on how often the cleanup needs to happen.
|
||||
|
||||
## Why cannot I derive from the built-in reporters?
|
||||
|
||||
They are not made to be overriden, in that we do not attempt to maintain
|
||||
They are not made to be overridden, in that we do not attempt to maintain
|
||||
a consistent internal state if a member function is overriden, and by
|
||||
forbidding users from using them as a base class, we can refactor them
|
||||
as needed later.
|
||||
@ -57,6 +61,34 @@ runners easier. [See the relevant section in our page on best
|
||||
practices](usage-tips.md#parallel-tests).
|
||||
|
||||
|
||||
## Can I compile Catch2 into a dynamic library?
|
||||
|
||||
Yes, Catch2 supports the [standard CMake `BUILD_SHARED_LIBS`
|
||||
option](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html).
|
||||
However, the dynamic library support is provided as-is. Catch2 does not
|
||||
provide API export annotations, and so you can only use it as a dynamic
|
||||
library on platforms that default to public visibility, or with tooling
|
||||
support to force export Catch2's API.
|
||||
|
||||
|
||||
## What repeatability guarantees does Catch2 provide?
|
||||
|
||||
There are two places where it is meaningful to talk about Catch2's
|
||||
repeatability guarantees without taking into account user-provided
|
||||
code. First one is in the test case shuffling, and the second one is
|
||||
the output from random generators.
|
||||
|
||||
Test case shuffling is repeatable across different platforms since v2.12.0,
|
||||
and it is also generally repeatable across versions, but we might break
|
||||
it from time to time. E.g. we broke repeatability with previous versions
|
||||
in v2.13.4 so that test cases with similar names are shuffled better.
|
||||
|
||||
Random generators currently rely on platform's stdlib, specifically
|
||||
the distributions from `<random>`. We thus provide no extra guarantee
|
||||
above what your platform does. **Important: `<random>`'s distributions
|
||||
are not specified to be repeatable across different platforms.**
|
||||
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md#top)
|
||||
|
@ -99,7 +99,7 @@ Catch does not support running tests in isolated (forked) processes. While this
|
||||
|
||||
Catch2 keeps test execution in one process strictly serial, and there
|
||||
are no plans to change this. If you find yourself with a test suite
|
||||
that takes too long to run and yo uwant to make it parallel, you have
|
||||
that takes too long to run and you want to make it parallel, you have
|
||||
to run multiple processes side by side.
|
||||
|
||||
There are 2 basic ways to do that,
|
||||
@ -171,7 +171,7 @@ TEST_CASE("b") {
|
||||
}
|
||||
```
|
||||
|
||||
If you are seeing a problem like this, i.e. a weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library.
|
||||
If you are seeing a problem like this, i.e. weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library.
|
||||
|
||||
|
||||
### libstdc++, `_GLIBCXX_DEBUG` macro and random ordering of tests
|
||||
|
@ -150,49 +150,8 @@ are:
|
||||
|
||||
> `WithinRel` matcher was introduced in Catch2 2.10.0
|
||||
|
||||
|
||||
`WithinAbs` creates a matcher that accepts floating point numbers whose
|
||||
difference with `target` is less than the `margin`.
|
||||
|
||||
`WithinULP` creates a matcher that accepts floating point numbers that
|
||||
are no more than `maxUlpDiff`
|
||||
[ULPs](https://en.wikipedia.org/wiki/Unit_in_the_last_place)
|
||||
away from the `target` value. The short version of what this means
|
||||
is that there is no more than `maxUlpDiff - 1` representeable floating
|
||||
point numbers between the argument for matching and the `target` value.
|
||||
|
||||
**Important**: The WithinULP matcher requires the platform to use the
|
||||
[IEEE-754](https://en.wikipedia.org/wiki/IEEE_754) representation for
|
||||
floating point numbers.
|
||||
|
||||
|
||||
`WithinRel` creates a matcher that accepts floating point numbers that
|
||||
are _approximately equal_ with the `target` with tolerance of `eps.`
|
||||
Specifically, it matches if
|
||||
`|arg - target| <= eps * max(|arg|, |target|)` holds. If you do not
|
||||
specify `eps`, `std::numeric_limits<FloatingPoint>::epsilon * 100`
|
||||
is used as the default.
|
||||
|
||||
|
||||
In practice, you will often want to combine multiple of these matchers,
|
||||
together for an assertion, because all 3 options have edge cases where
|
||||
they behave differently than you would expect. As an example, under
|
||||
the `WithinRel` matcher, a `0.` only ever matches a `0.` (or `-0.`),
|
||||
regardless of the relative tolerance specified. Thus, if you want to
|
||||
handle numbers that are "close enough to 0 to be 0", you have to combine
|
||||
it with the `WithinAbs` matcher.
|
||||
|
||||
For example, to check that our computation matches known good value
|
||||
within 0.1%, or is close enough (no different to 5 decimal places)
|
||||
to zero, we would write this assertion:
|
||||
```cpp
|
||||
REQUIRE_THAT( computation(input),
|
||||
Catch::Matchers::WithinRel(expected, 0.001)
|
||||
|| Catch::Matchers::WithinAbs(0, 0.000001) );
|
||||
```
|
||||
|
||||
|
||||
> floating point matchers live in `catch2/matchers/catch_matchers_floating.hpp`
|
||||
For more details, read [the docs on comparing floating point
|
||||
numbers](comparing-floating-point-numbers.md#floating-point-matchers).
|
||||
|
||||
|
||||
### Miscellaneous matchers
|
||||
@ -224,7 +183,7 @@ The other miscellaneous matcher utility is exception matching.
|
||||
|
||||
#### Matching exceptions
|
||||
|
||||
Catch2 provides an utility macro for asserting that an expression
|
||||
Catch2 provides a utility macro for asserting that an expression
|
||||
throws exception of specific type, and that the exception has desired
|
||||
properties. The macro is `REQUIRE_THROWS_MATCHES(expr, ExceptionType, Matcher)`.
|
||||
|
||||
@ -282,12 +241,12 @@ in which case a range is accepted if any of its elements is accepted
|
||||
by the provided matcher.
|
||||
|
||||
`AllMatch`, `NoneMatch`, and `AnyMatch` match ranges for which either
|
||||
all, none, or any of the contained elements matches the given matcher,
|
||||
all, none, or any of the contained elements matches the given matcher,
|
||||
respectively.
|
||||
|
||||
`AllTrue`, `NoneTrue`, and `AnyTrue` match ranges for which either
|
||||
all, none, or any of the contained elements are `true`, respectively.
|
||||
It works for ranges of `bool`s and ranges of elements (explicitly)
|
||||
all, none, or any of the contained elements are `true`, respectively.
|
||||
It works for ranges of `bool`s and ranges of elements (explicitly)
|
||||
convertible to `bool`.
|
||||
|
||||
## Writing custom matchers (old style)
|
||||
@ -368,7 +327,7 @@ style matchers arbitrarily.
|
||||
|
||||
To create a new-style matcher, you have to create your own type that
|
||||
derives from `Catch::Matchers::MatcherGenericBase`. Your type has to
|
||||
also provide two methods, `bool match( ... ) const` and overriden
|
||||
also provide two methods, `bool match( ... ) const` and overridden
|
||||
`std::string describe() const`.
|
||||
|
||||
Unlike with old-style matchers, there are no requirements on how
|
||||
|
@ -21,9 +21,10 @@ reduced by roughly 80%. The improved ease of maintenance also led to
|
||||
various runtime performance improvements and the introduction of new features.
|
||||
For details, look at [the release notes of 3.0.1](release-notes.md#301).
|
||||
|
||||
_Note that we still provide one header + one TU distribution but do
|
||||
not consider it the primarily supported option. You should also expect
|
||||
that the compilation times will be worse if you use this option._
|
||||
_Note that we still provide one header + one translation unit (TU)
|
||||
distribution but do not consider it the primarily supported option. You
|
||||
should also expect that the compilation times will be worse if you use
|
||||
this option._
|
||||
|
||||
|
||||
## How to migrate projects from v2 to v3
|
||||
@ -65,7 +66,9 @@ to piecemeal includes. You will likely want to start by including
|
||||
[other notes](#other-notes) for further ideas)
|
||||
|
||||
## Other notes
|
||||
|
||||
* The main test include is now `<catch2/catch_test_macros.hpp>`
|
||||
|
||||
* Big "subparts" like Matchers, or Generators, have their own folder, and
|
||||
also their own "big header", so if you just want to include all matchers,
|
||||
you can include `<catch2/matchers/catch_matchers_all.hpp>`,
|
||||
@ -73,11 +76,21 @@ or `<catch2/generators/catch_generators_all.hpp>`
|
||||
|
||||
|
||||
## Things that can break during porting
|
||||
* The namespace on Matchers were cleaned up, they are no longer first declared
|
||||
deep within an internal namespace and then brought up. All Matchers now live
|
||||
in `Catch::Matchers`.
|
||||
* The reporter interfaces changed in a breaking manner. If you wrote custom
|
||||
reporter or listener, you might need to modify them a bit.
|
||||
|
||||
* The namespaces of Matchers were flattened and cleaned up.
|
||||
|
||||
Matchers are no longer declared deep within an internal namespace and
|
||||
then brought up into `Catch` namespace. All Matchers now live in the
|
||||
`Catch::Matchers` namespace.
|
||||
|
||||
* The `Contains` string matcher was renamed to `ContainsSubstring`.
|
||||
|
||||
* The reporter interfaces changed in a breaking manner.
|
||||
|
||||
If you are using a custom reporter or listener, you will likely need to
|
||||
modify them to conform to the new interfaces. Unlike before in v2,
|
||||
the [interfaces](reporters.md#top) and the [events](reporter-events.md#top)
|
||||
are now documented.
|
||||
|
||||
|
||||
---
|
||||
|
@ -72,7 +72,7 @@ A header-only template engine for modern C++.
|
||||
A C++17 template header-only library for the abstraction of memory access patterns.
|
||||
|
||||
### [libcluon](https://github.com/chrberger/libcluon)
|
||||
A single-header-only library written in C++14 to glue distributed software components (UDP, TCP, shared memory) supporting natively Protobuf, LCM/ZCM, MsgPack, and JSON for dynamic message transformations in-between.
|
||||
A single-header-only library written in C++14 to glue distributed software components (UDP, TCP, shared memory) supporting natively Protobuf, LCM/ZCM, MsgPack, and JSON for dynamic message transformations in-between.
|
||||
|
||||
### [MNMLSTC Core](https://github.com/mnmlstc/core)
|
||||
A small and easy to use C++11 library that adds a functionality set that will be available in C++14 and later, as well as some useful additions.
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
# Release notes
|
||||
**Contents**<br>
|
||||
[3.2.1](#321)<br>
|
||||
[3.2.0](#320)<br>
|
||||
[3.1.1](#311)<br>
|
||||
[3.1.0](#310)<br>
|
||||
[3.0.1](#301)<br>
|
||||
[2.13.7](#2137)<br>
|
||||
@ -50,6 +53,82 @@
|
||||
[Even Older versions](#even-older-versions)<br>
|
||||
|
||||
|
||||
|
||||
## 3.2.1
|
||||
|
||||
### Improvements
|
||||
* Fix the reworked decomposer to work with older (pre 9) GCC versions (#2571)
|
||||
* **This required more significant changes to properly support C++20, there might be bugs.**
|
||||
|
||||
|
||||
## 3.2.0
|
||||
|
||||
### Improvements
|
||||
* Catch2 now compiles on PlayStation (#2562)
|
||||
* Added `CATCH_CONFIG_GETENV` compile-time toggle (#2562)
|
||||
* This toggle guards whether Catch2 calls `std::getenv` when reading env variables
|
||||
* Added support for more Bazel test environment variables
|
||||
* `TESTBRIDGE_TEST_ONLY` is now supported (#2490)
|
||||
* Sharding variables, `TEST_SHARD_INDEX`, `TEST_TOTAL_SHARDS`, `TEST_SHARD_STATUS_FILE`, are now all supported (#2491)
|
||||
* Bunch of small tweaks and improvements in reporters
|
||||
* The TAP and SonarQube reporters output the used test filters
|
||||
* The XML reporter now also reports the version of its output format
|
||||
* The compact reporter now uses the same summary output as the console reporter (#878, #2554)
|
||||
* Added support for asserting on types that can only be compared with literal 0 (#2555)
|
||||
* A canonical example is C++20's `std::*_ordering` types, which cannot be compared with an `int` variable, only `0`
|
||||
* The support extends to any type with this property, not just the ones in stdlib
|
||||
* This change imposes 2-3% slowdown on compiling files that are heavy on `REQUIRE` and friends
|
||||
* **This required significant rewrite of decomposition, there might be bugs**
|
||||
* Simplified internals of matcher related macros
|
||||
* This provides about ~2% speed up compiling files that are heavy on `REQUIRE_THAT` and friends
|
||||
|
||||
|
||||
### Fixes
|
||||
* Cleaned out some warnings and static analysis issues
|
||||
* Suppressed `-Wcomma` warning rarely occuring in templated test cases (#2543)
|
||||
* Constified implementation details in `INFO` (#2564)
|
||||
* Made `MatcherGenericBase` copy constructor const (#2566)
|
||||
* Fixed serialization of test filters so the output roundtrips
|
||||
* This means that e.g. `./tests/SelfTest "aaa bbb", [approx]` outputs `Filters: "aaa bbb",[approx]`
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
* Catch2's build no longer leaks `-ffile-prefix-map` setting to dependees (#2533)
|
||||
|
||||
|
||||
|
||||
## 3.1.1
|
||||
|
||||
### Improvements
|
||||
* Added `Catch::getSeed` function that user code can call to retrieve current rng-seed
|
||||
* Better detection of compiler support for `-ffile-prefix-map` (#2517)
|
||||
* Catch2's shared libraries now have `SOVERSION` set (#2516)
|
||||
* `catch2/catch_all.hpp` convenience header no longer transitively includes `windows.h` (#2432, #2526)
|
||||
|
||||
|
||||
### Fixes
|
||||
* Fixed compilation on Universal Windows Platform
|
||||
* Fixed compilation on VxWorks (#2515)
|
||||
* Fixed compilation on Cygwin (#2540)
|
||||
* Remove unused variable in reporter registration (#2538)
|
||||
* Fixed some symbol visibility issues with dynamic library on Windows (#2527)
|
||||
* Suppressed `-Wuseless-cast` warnings in `REQUIRE_THROWS*` macros (#2520, #2521)
|
||||
* This was triggered when the potentially throwing expression evaluates to `void`
|
||||
* Fixed "warning: storage class is not first" with `nvc++` (#2533)
|
||||
* Fixed handling of `DL_PATHS` argument to `catch_discover_tests` on MacOS (#2483)
|
||||
* Suppressed `*-avoid-c-arrays` clang-tidy warning in `TEMPLATE_TEST_CASE` (#2095, #2536)
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
* Fixed CMake install step for Catch2 build as dynamic library (#2485)
|
||||
* Raised minimum CMake version to 3.10 (#2523)
|
||||
* Expect the minimum CMake version to increase once more in next few releases.
|
||||
* Whole bunch of doc updates and fixes
|
||||
* #1444, #2497, #2547, #2549, and more
|
||||
* Added support for building Catch2 with Meson (#2530, #2539)
|
||||
|
||||
|
||||
|
||||
## 3.1.0
|
||||
|
||||
### Improvements
|
||||
@ -415,7 +494,7 @@ v3 releases.
|
||||
### Improvements
|
||||
* `std::result_of` is not used if `std::invoke_result` is available (#1934)
|
||||
* JUnit reporter writes out `status` attribute for tests (#1899)
|
||||
* Suppresed clang-tidy's `hicpp-vararg` warning (#1921)
|
||||
* Suppressed clang-tidy's `hicpp-vararg` warning (#1921)
|
||||
* Catch2 was already suppressing the `cppcoreguidelines-pro-type-vararg` alias of the warning
|
||||
|
||||
|
||||
|
@ -138,7 +138,7 @@ benchmarking itself fails.
|
||||
> Introduced in Catch2 3.0.1.
|
||||
|
||||
Listings events are events that correspond to the test binary being
|
||||
invoked with `--list-foo` flag.
|
||||
invoked with `--list-foo` flag.
|
||||
|
||||
There are currently 3 listing events, one for reporters, one for tests,
|
||||
and one for tags. Note that they are not exclusive to each other.
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
## Defining test fixtures
|
||||
|
||||
Although Catch allows you to group tests together as sections within a test case, it can still be convenient, sometimes, to group them using a more traditional test fixture. Catch fully supports this too. You define the test fixture as a simple structure:
|
||||
Although Catch allows you to group tests together as [sections within a test case](test-cases-and-sections.md), it can still be convenient, sometimes, to group them using a more traditional test fixture. Catch fully supports this too. You define the test fixture as a simple structure:
|
||||
|
||||
```c++
|
||||
class UniqueTestsFixture {
|
||||
@ -130,9 +130,9 @@ struct Template_Foo_2 {
|
||||
};
|
||||
|
||||
TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(
|
||||
Template_Fixture_2,
|
||||
"A TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG based test run that succeeds",
|
||||
"[class][template][product][nttp]",
|
||||
Template_Fixture_2,
|
||||
"A TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG based test run that succeeds",
|
||||
"[class][template][product][nttp]",
|
||||
((typename T, size_t S), T, S),
|
||||
(std::array, Template_Foo_2),
|
||||
((int,2), (float,6))) {
|
||||
|
@ -13,9 +13,10 @@
|
||||
## Getting Catch2
|
||||
|
||||
Ideally you should be using Catch2 through its [CMake integration](cmake-integration.md#top).
|
||||
Catch2 also provides pkg-config files and single TU distribution, but this
|
||||
documentation will assume you are using CMake. If you are using single-TU
|
||||
distribution instead, remember to replace the included header with `catch_amalgamated.hpp`.
|
||||
Catch2 also provides pkg-config files and two file (header + cpp)
|
||||
distribution, but this documentation will assume you are using CMake. If
|
||||
you are using the two file distribution instead, remember to replace
|
||||
the included header with `catch_amalgamated.hpp`.
|
||||
|
||||
|
||||
## Writing tests
|
||||
@ -99,7 +100,7 @@ before we move on.
|
||||
It accepts a boolean expression, and uses expression templates to
|
||||
internally decompose it, so that it can be individually stringified
|
||||
on test failure.
|
||||
|
||||
|
||||
On the last point, note that there are more testing macros available,
|
||||
because not all useful checks can be expressed as a simple boolean
|
||||
expression. As an example, checking that an expression throws an exception
|
||||
@ -177,7 +178,7 @@ To continue on the vector example above, you could add a check that
|
||||
}
|
||||
```
|
||||
|
||||
Another way to look at sections is that they are a way to define a tree
|
||||
Another way to look at sections is that they are a way to define a tree
|
||||
of paths through the test. Each section represents a node, and the final
|
||||
tree is walked in depth-first manner, with each path only visiting only
|
||||
one leaf node.
|
||||
|
@ -47,7 +47,7 @@ Catch2 also supports [splitting tests in a binary into multiple
|
||||
shards](command-line.md#test-sharding). This can be used by any test
|
||||
runner to run batches of tests in parallel. Do note that when selecting
|
||||
on the number of shards, you should have more shards than there are cores,
|
||||
to avoid issues with long running tests getting accidentally grouped in
|
||||
to avoid issues with long-running tests getting accidentally grouped in
|
||||
the same shard, and causing long-tailed execution time.
|
||||
|
||||
**Note that naively composing sharding and random ordering of tests will break.**
|
||||
@ -73,6 +73,11 @@ seed, e.g.
|
||||
./tests --order rand --shard-index 2 --shard-count 3 --rng-seed 0xBEEF
|
||||
```
|
||||
|
||||
Catch2 actually provides a helper to automatically register multiple shards
|
||||
as CTest tests, with shared random seed that changes each CTest invocation.
|
||||
For details look at the documentation of
|
||||
[`CatchShardTests.cmake` CMake script](cmake-integration.md#catchshardtestscmake).
|
||||
|
||||
|
||||
## Organizing tests into binaries
|
||||
|
||||
|
@ -41,7 +41,7 @@ So what does Catch2 bring to the party that differentiates it from these? Apart
|
||||
|
||||
## Who else is using Catch2?
|
||||
|
||||
A whole lot of people. According to the 2021 Jetbrains C++ ecosystem survey,
|
||||
A whole lot of people. According to the 2021 JetBrains C++ ecosystem survey,
|
||||
about 11% of C++ programmers use Catch2 for unit testing, making it the
|
||||
second most popular unit testing framework.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required( VERSION 3.5 )
|
||||
cmake_minimum_required( VERSION 3.10 )
|
||||
|
||||
project( Catch2Examples LANGUAGES CXX )
|
||||
|
||||
@ -54,8 +54,6 @@ set(ALL_EXAMPLE_TARGETS
|
||||
|
||||
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
||||
target_link_libraries( ${name} Catch2 Catch2WithMain )
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
|
||||
endforeach()
|
||||
|
||||
|
||||
|
@ -17,6 +17,8 @@ set(tests)
|
||||
|
||||
if(WIN32)
|
||||
set(dl_paths_variable_name PATH)
|
||||
elseif(APPLE)
|
||||
set(dl_paths_variable_name DYLD_LIBRARY_PATH)
|
||||
else()
|
||||
set(dl_paths_variable_name LD_LIBRARY_PATH)
|
||||
endif()
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
# Copyright Catch2 Authors
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# (See accompanying file LICENSE.txt or copy at
|
||||
# https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
# Copyright Catch2 Authors
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# (See accompanying file LICENSE.txt or copy at
|
||||
# https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,12 +1,12 @@
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
// Catch v3.1.0
|
||||
// Generated: 2022-07-17 20:14:05.885021
|
||||
// Catch v3.2.1
|
||||
// Generated: 2022-12-09 23:01:15.713081
|
||||
// ----------------------------------------------------------
|
||||
// This file is an amalgamation of multiple different files.
|
||||
// You probably shouldn't edit it directly.
|
||||
@ -15,6 +15,28 @@
|
||||
#include "catch_amalgamated.hpp"
|
||||
|
||||
|
||||
#ifndef CATCH_WINDOWS_H_PROXY_HPP_INCLUDED
|
||||
#define CATCH_WINDOWS_H_PROXY_HPP_INCLUDED
|
||||
|
||||
|
||||
#if defined(CATCH_PLATFORM_WINDOWS)
|
||||
|
||||
// We might end up with the define made globally through the compiler,
|
||||
// and we don't want to trigger warnings for this
|
||||
#if !defined(NOMINMAX)
|
||||
# define NOMINMAX
|
||||
#endif
|
||||
#if !defined(WIN32_LEAN_AND_MEAN)
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#endif // defined(CATCH_PLATFORM_WINDOWS)
|
||||
|
||||
#endif // CATCH_WINDOWS_H_PROXY_HPP_INCLUDED
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Catch {
|
||||
@ -486,30 +508,74 @@ namespace Catch {
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
bool provideBazelReporterOutput() {
|
||||
#ifdef CATCH_CONFIG_BAZEL_SUPPORT
|
||||
return true;
|
||||
#else
|
||||
|
||||
# if defined( _MSC_VER )
|
||||
// On Windows getenv throws a warning as there is no input validation,
|
||||
// since the switch is hardcoded, this should not be an issue.
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4996 )
|
||||
# endif
|
||||
|
||||
return std::getenv( "BAZEL_TEST" ) != nullptr;
|
||||
|
||||
# if defined( _MSC_VER )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#include <fstream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
static bool enableBazelEnvSupport() {
|
||||
#if defined( CATCH_CONFIG_BAZEL_SUPPORT )
|
||||
return true;
|
||||
#else
|
||||
return Detail::getEnv( "BAZEL_TEST" ) != nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct bazelShardingOptions {
|
||||
unsigned int shardIndex, shardCount;
|
||||
std::string shardFilePath;
|
||||
};
|
||||
|
||||
static Optional<bazelShardingOptions> readBazelShardingOptions() {
|
||||
const auto bazelShardIndex = Detail::getEnv( "TEST_SHARD_INDEX" );
|
||||
const auto bazelShardTotal = Detail::getEnv( "TEST_TOTAL_SHARDS" );
|
||||
const auto bazelShardInfoFile = Detail::getEnv( "TEST_SHARD_STATUS_FILE" );
|
||||
|
||||
|
||||
const bool has_all =
|
||||
bazelShardIndex && bazelShardTotal && bazelShardInfoFile;
|
||||
if ( !has_all ) {
|
||||
// We provide nice warning message if the input is
|
||||
// misconfigured.
|
||||
auto warn = []( const char* env_var ) {
|
||||
Catch::cerr()
|
||||
<< "Warning: Bazel shard configuration is missing '"
|
||||
<< env_var << "'. Shard configuration is skipped.\n";
|
||||
};
|
||||
if ( !bazelShardIndex ) {
|
||||
warn( "TEST_SHARD_INDEX" );
|
||||
}
|
||||
if ( !bazelShardTotal ) {
|
||||
warn( "TEST_TOTAL_SHARDS" );
|
||||
}
|
||||
if ( !bazelShardInfoFile ) {
|
||||
warn( "TEST_SHARD_STATUS_FILE" );
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
auto shardIndex = parseUInt( bazelShardIndex );
|
||||
if ( !shardIndex ) {
|
||||
Catch::cerr()
|
||||
<< "Warning: could not parse 'TEST_SHARD_INDEX' ('" << bazelShardIndex
|
||||
<< "') as unsigned int.\n";
|
||||
return {};
|
||||
}
|
||||
auto shardTotal = parseUInt( bazelShardTotal );
|
||||
if ( !shardTotal ) {
|
||||
Catch::cerr()
|
||||
<< "Warning: could not parse 'TEST_TOTAL_SHARD' ('"
|
||||
<< bazelShardTotal << "') as unsigned int.\n";
|
||||
return {};
|
||||
}
|
||||
|
||||
return bazelShardingOptions{
|
||||
*shardIndex, *shardTotal, bazelShardInfoFile };
|
||||
|
||||
}
|
||||
} // end namespace
|
||||
|
||||
|
||||
bool operator==( ProcessedReporterSpec const& lhs,
|
||||
ProcessedReporterSpec const& rhs ) {
|
||||
return lhs.name == rhs.name &&
|
||||
@ -531,17 +597,6 @@ namespace Catch {
|
||||
elem = trim(elem);
|
||||
}
|
||||
|
||||
|
||||
TestSpecParser parser(ITagAliasRegistry::get());
|
||||
if (!m_data.testsOrTags.empty()) {
|
||||
m_hasTestFilters = true;
|
||||
for (auto const& testOrTags : m_data.testsOrTags) {
|
||||
parser.parse(testOrTags);
|
||||
}
|
||||
}
|
||||
m_testSpec = parser.testSpec();
|
||||
|
||||
|
||||
// Insert the default reporter if user hasn't asked for a specfic one
|
||||
if ( m_data.reporterSpecifications.empty() ) {
|
||||
m_data.reporterSpecifications.push_back( {
|
||||
@ -554,27 +609,20 @@ namespace Catch {
|
||||
} );
|
||||
}
|
||||
|
||||
if(provideBazelReporterOutput()){
|
||||
// Register a JUnit reporter for Bazel. Bazel sets an environment
|
||||
// variable with the path to XML output. If this file is written to
|
||||
// during test, Bazel will not generate a default XML output.
|
||||
// This allows the XML output file to contain higher level of detail
|
||||
// than what is possible otherwise.
|
||||
# if defined( _MSC_VER )
|
||||
// On Windows getenv throws a warning as there is no input validation,
|
||||
// since the key is hardcoded, this should not be an issue.
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4996 )
|
||||
# endif
|
||||
const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" );
|
||||
# if defined( _MSC_VER )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
if ( bazelOutputFilePtr != nullptr ) {
|
||||
m_data.reporterSpecifications.push_back(
|
||||
{ "junit", std::string( bazelOutputFilePtr ), {}, {} } );
|
||||
if ( enableBazelEnvSupport() ) {
|
||||
readBazelEnvVars();
|
||||
}
|
||||
|
||||
// Bazel support can modify the test specs, so parsing has to happen
|
||||
// after reading Bazel env vars.
|
||||
TestSpecParser parser( ITagAliasRegistry::get() );
|
||||
if ( !m_data.testsOrTags.empty() ) {
|
||||
m_hasTestFilters = true;
|
||||
for ( auto const& testOrTags : m_data.testsOrTags ) {
|
||||
parser.parse( testOrTags );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_testSpec = parser.testSpec();
|
||||
|
||||
|
||||
// We now fixup the reporter specs to handle default output spec,
|
||||
@ -655,10 +703,53 @@ namespace Catch {
|
||||
unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; }
|
||||
std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); }
|
||||
|
||||
void Config::readBazelEnvVars() {
|
||||
// Register a JUnit reporter for Bazel. Bazel sets an environment
|
||||
// variable with the path to XML output. If this file is written to
|
||||
// during test, Bazel will not generate a default XML output.
|
||||
// This allows the XML output file to contain higher level of detail
|
||||
// than what is possible otherwise.
|
||||
const auto bazelOutputFile = Detail::getEnv( "XML_OUTPUT_FILE" );
|
||||
|
||||
if ( bazelOutputFile ) {
|
||||
m_data.reporterSpecifications.push_back(
|
||||
{ "junit", std::string( bazelOutputFile ), {}, {} } );
|
||||
}
|
||||
|
||||
const auto bazelTestSpec = Detail::getEnv( "TESTBRIDGE_TEST_ONLY" );
|
||||
if ( bazelTestSpec ) {
|
||||
// Presumably the test spec from environment should overwrite
|
||||
// the one we got from CLI (if we got any)
|
||||
m_data.testsOrTags.clear();
|
||||
m_data.testsOrTags.push_back( bazelTestSpec );
|
||||
}
|
||||
|
||||
const auto bazelShardOptions = readBazelShardingOptions();
|
||||
if ( bazelShardOptions ) {
|
||||
std::ofstream f( bazelShardOptions->shardFilePath,
|
||||
std::ios_base::out | std::ios_base::trunc );
|
||||
if ( f.is_open() ) {
|
||||
f << "";
|
||||
m_data.shardIndex = bazelShardOptions->shardIndex;
|
||||
m_data.shardCount = bazelShardOptions->shardCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Catch {
|
||||
std::uint32_t getSeed() {
|
||||
return getCurrentContext().getConfig()->rngSeed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <stack>
|
||||
|
||||
@ -882,7 +973,6 @@ namespace Catch {
|
||||
multi->addListener(listener->create(config));
|
||||
}
|
||||
|
||||
std::size_t reporterIdx = 0;
|
||||
for ( auto const& reporterSpec : config->getProcessedReporterSpecs() ) {
|
||||
multi->addReporter( createReporter(
|
||||
reporterSpec.name,
|
||||
@ -890,7 +980,6 @@ namespace Catch {
|
||||
makeStream( reporterSpec.outputFilename ),
|
||||
reporterSpec.colourMode,
|
||||
reporterSpec.customOptions ) ) );
|
||||
reporterIdx++;
|
||||
}
|
||||
|
||||
return multi;
|
||||
@ -1438,6 +1527,7 @@ namespace Catch {
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -1461,6 +1551,10 @@ namespace Catch {
|
||||
return m_wildcardPattern.matches( testCase.name );
|
||||
}
|
||||
|
||||
void TestSpec::NamePattern::serializeTo( std::ostream& out ) const {
|
||||
out << '"' << name() << '"';
|
||||
}
|
||||
|
||||
|
||||
TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString )
|
||||
: Pattern( filterString )
|
||||
@ -1473,6 +1567,10 @@ namespace Catch {
|
||||
Tag( m_tag ) ) != end( testCase.tags );
|
||||
}
|
||||
|
||||
void TestSpec::TagPattern::serializeTo( std::ostream& out ) const {
|
||||
out << name();
|
||||
}
|
||||
|
||||
bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {
|
||||
bool should_use = !testCase.isHidden();
|
||||
for (auto const& pattern : m_required) {
|
||||
@ -1489,18 +1587,31 @@ namespace Catch {
|
||||
return should_use;
|
||||
}
|
||||
|
||||
std::string TestSpec::Filter::name() const {
|
||||
std::string name;
|
||||
for (auto const& p : m_required) {
|
||||
name += p->name();
|
||||
void TestSpec::Filter::serializeTo( std::ostream& out ) const {
|
||||
bool first = true;
|
||||
for ( auto const& pattern : m_required ) {
|
||||
if ( !first ) {
|
||||
out << ' ';
|
||||
}
|
||||
out << *pattern;
|
||||
first = false;
|
||||
}
|
||||
for (auto const& p : m_forbidden) {
|
||||
name += p->name();
|
||||
for ( auto const& pattern : m_forbidden ) {
|
||||
if ( !first ) {
|
||||
out << ' ';
|
||||
}
|
||||
out << *pattern;
|
||||
first = false;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
std::string TestSpec::extractFilterName( Filter const& filter ) {
|
||||
Catch::ReusableStringStream sstr;
|
||||
sstr << filter;
|
||||
return sstr.str();
|
||||
}
|
||||
|
||||
bool TestSpec::hasFilters() const {
|
||||
return !m_filters.empty();
|
||||
}
|
||||
@ -1517,7 +1628,7 @@ namespace Catch {
|
||||
for( auto const& test : testCases )
|
||||
if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) )
|
||||
currentMatches.emplace_back( &test );
|
||||
return FilterMatch{ filter.name(), currentMatches };
|
||||
return FilterMatch{ extractFilterName(filter), currentMatches };
|
||||
} );
|
||||
return matches;
|
||||
}
|
||||
@ -1526,6 +1637,17 @@ namespace Catch {
|
||||
return m_invalidSpecs;
|
||||
}
|
||||
|
||||
void TestSpec::serializeTo( std::ostream& out ) const {
|
||||
bool first = true;
|
||||
for ( auto const& filter : m_filters ) {
|
||||
if ( !first ) {
|
||||
out << ',';
|
||||
}
|
||||
out << filter;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1890,7 +2012,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 3, 1, 0, "", 0 );
|
||||
static Version version( 3, 2, 1, "", 0 );
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -2141,11 +2263,7 @@ namespace Catch {
|
||||
CATCH_BREAK_INTO_DEBUGGER();
|
||||
}
|
||||
if (m_reaction.shouldThrow) {
|
||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||
throw Catch::TestFailureException();
|
||||
#else
|
||||
CATCH_ERROR( "Test failure requires aborting test!" );
|
||||
#endif
|
||||
throw_test_failure_exception();
|
||||
}
|
||||
}
|
||||
void AssertionHandler::setCompleted() {
|
||||
@ -2173,8 +2291,8 @@ namespace Catch {
|
||||
|
||||
// This is the overload that takes a string and infers the Equals matcher from it
|
||||
// The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) {
|
||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str ) {
|
||||
handleExceptionMatchExpr( handler, Matchers::Equals( str ) );
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
@ -2710,23 +2828,14 @@ namespace Catch {
|
||||
return ParserResult::ok(ParseResultType::Matched);
|
||||
}
|
||||
|
||||
CATCH_TRY {
|
||||
std::size_t parsedTo = 0;
|
||||
unsigned long parsedSeed = std::stoul(seed, &parsedTo, 0);
|
||||
if (parsedTo != seed.size()) {
|
||||
return ParserResult::runtimeError("Could not parse '" + seed + "' as seed");
|
||||
}
|
||||
|
||||
// TODO: Ideally we could parse unsigned int directly,
|
||||
// but the stdlib doesn't provide helper for that
|
||||
// type. After this is refactored to use fixed size
|
||||
// type, we should check the parsed value is in range
|
||||
// of the underlying type.
|
||||
config.rngSeed = static_cast<unsigned int>(parsedSeed);
|
||||
return ParserResult::ok(ParseResultType::Matched);
|
||||
} CATCH_CATCH_ANON(std::exception const&) {
|
||||
return ParserResult::runtimeError("Could not parse '" + seed + "' as seed");
|
||||
// TODO: ideally we should be parsing uint32_t directly
|
||||
// fix this later when we add new parse overload
|
||||
auto parsedSeed = parseUInt( seed, 0 );
|
||||
if ( !parsedSeed ) {
|
||||
return ParserResult::runtimeError( "Could not parse '" + seed + "' as seed" );
|
||||
}
|
||||
config.rngSeed = *parsedSeed;
|
||||
return ParserResult::ok( ParseResultType::Matched );
|
||||
};
|
||||
auto const setDefaultColourMode = [&]( std::string const& colourMode ) {
|
||||
Optional<ColourMode> maybeMode = Catch::Detail::stringToColourMode(toLower( colourMode ));
|
||||
@ -2818,42 +2927,29 @@ namespace Catch {
|
||||
return ParserResult::ok( ParseResultType::Matched );
|
||||
};
|
||||
auto const setShardCount = [&]( std::string const& shardCount ) {
|
||||
CATCH_TRY{
|
||||
std::size_t parsedTo = 0;
|
||||
int64_t parsedCount = std::stoll(shardCount, &parsedTo, 0);
|
||||
if (parsedTo != shardCount.size()) {
|
||||
return ParserResult::runtimeError("Could not parse '" + shardCount + "' as shard count");
|
||||
}
|
||||
if (parsedCount <= 0) {
|
||||
return ParserResult::runtimeError("Shard count must be a positive number");
|
||||
}
|
||||
|
||||
config.shardCount = static_cast<unsigned int>(parsedCount);
|
||||
return ParserResult::ok(ParseResultType::Matched);
|
||||
} CATCH_CATCH_ANON(std::exception const&) {
|
||||
return ParserResult::runtimeError("Could not parse '" + shardCount + "' as shard count");
|
||||
auto parsedCount = parseUInt( shardCount );
|
||||
if ( !parsedCount ) {
|
||||
return ParserResult::runtimeError(
|
||||
"Could not parse '" + shardCount + "' as shard count" );
|
||||
}
|
||||
if ( *parsedCount == 0 ) {
|
||||
return ParserResult::runtimeError(
|
||||
"Shard count must be positive" );
|
||||
}
|
||||
config.shardCount = *parsedCount;
|
||||
return ParserResult::ok( ParseResultType::Matched );
|
||||
};
|
||||
|
||||
auto const setShardIndex = [&](std::string const& shardIndex) {
|
||||
CATCH_TRY{
|
||||
std::size_t parsedTo = 0;
|
||||
int64_t parsedIndex = std::stoll(shardIndex, &parsedTo, 0);
|
||||
if (parsedTo != shardIndex.size()) {
|
||||
return ParserResult::runtimeError("Could not parse '" + shardIndex + "' as shard index");
|
||||
}
|
||||
if (parsedIndex < 0) {
|
||||
return ParserResult::runtimeError("Shard index must be a non-negative number");
|
||||
}
|
||||
|
||||
config.shardIndex = static_cast<unsigned int>(parsedIndex);
|
||||
return ParserResult::ok(ParseResultType::Matched);
|
||||
} CATCH_CATCH_ANON(std::exception const&) {
|
||||
return ParserResult::runtimeError("Could not parse '" + shardIndex + "' as shard index");
|
||||
auto parsedIndex = parseUInt( shardIndex );
|
||||
if ( !parsedIndex ) {
|
||||
return ParserResult::runtimeError(
|
||||
"Could not parse '" + shardIndex + "' as shard index" );
|
||||
}
|
||||
config.shardIndex = *parsedIndex;
|
||||
return ParserResult::ok( ParseResultType::Matched );
|
||||
};
|
||||
|
||||
|
||||
auto cli
|
||||
= ExeName( config.processName )
|
||||
| Help( config.showHelp )
|
||||
@ -3891,6 +3987,35 @@ namespace Catch {
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
#if !defined (CATCH_CONFIG_GETENV)
|
||||
char const* getEnv( char const* ) { return nullptr; }
|
||||
#else
|
||||
|
||||
char const* getEnv( char const* varName ) {
|
||||
# if defined( _MSC_VER )
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4996 ) // use getenv_s instead of getenv
|
||||
# endif
|
||||
|
||||
return std::getenv( varName );
|
||||
|
||||
# if defined( _MSC_VER )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
} // namespace Detail
|
||||
} // namespace Catch
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@ -3957,6 +4082,7 @@ namespace Detail {
|
||||
FileStream( std::string const& filename ) {
|
||||
m_ofs.open( filename.c_str() );
|
||||
CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' );
|
||||
m_ofs << std::unitbuf;
|
||||
}
|
||||
~FileStream() override = default;
|
||||
public: // IStream
|
||||
@ -4383,6 +4509,47 @@ namespace Catch {
|
||||
|
||||
|
||||
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
Optional<unsigned int> parseUInt(std::string const& input, int base) {
|
||||
auto trimmed = trim( input );
|
||||
// std::stoull is annoying and accepts numbers starting with '-',
|
||||
// it just negates them into unsigned int
|
||||
if ( trimmed.empty() || trimmed[0] == '-' ) {
|
||||
return {};
|
||||
}
|
||||
|
||||
CATCH_TRY {
|
||||
size_t pos = 0;
|
||||
const auto ret = std::stoull( trimmed, &pos, base );
|
||||
|
||||
// We did not consume the whole input, so there is an issue
|
||||
// This can be bunch of different stuff, like multiple numbers
|
||||
// in the input, or invalid digits/characters and so on. Either
|
||||
// way, we do not want to return the partially parsed result.
|
||||
if ( pos != trimmed.size() ) {
|
||||
return {};
|
||||
}
|
||||
// Too large
|
||||
if ( ret > std::numeric_limits<unsigned int>::max() ) {
|
||||
return {};
|
||||
}
|
||||
return static_cast<unsigned int>(ret);
|
||||
} CATCH_CATCH_ANON( std::exception const& ) {
|
||||
// There was a larger issue with the input, e.g. the parsed
|
||||
// number would be too large to fit within ull.
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
|
||||
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace Catch {
|
||||
@ -5850,7 +6017,7 @@ namespace Catch {
|
||||
TestCaseInfo const* rhs ) {
|
||||
return *lhs < *rhs;
|
||||
};
|
||||
std::set<TestCaseInfo const*, decltype(testInfoCmp)> seenTests(testInfoCmp);
|
||||
std::set<TestCaseInfo const*, decltype(testInfoCmp) &> seenTests(testInfoCmp);
|
||||
for ( auto const& test : tests ) {
|
||||
const auto infoPtr = &test.getTestCaseInfo();
|
||||
const auto prev = seenTests.insert( infoPtr );
|
||||
@ -6155,6 +6322,21 @@ namespace TestCaseTracking {
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Catch {
|
||||
|
||||
void throw_test_failure_exception() {
|
||||
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
|
||||
throw TestFailureException{};
|
||||
#else
|
||||
CATCH_ERROR( "Test failure requires aborting test!" );
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
@ -6441,10 +6623,6 @@ namespace Catch {
|
||||
m_mode = None;
|
||||
}
|
||||
|
||||
TestSpec parseTestSpec( std::string const& arg ) {
|
||||
return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
|
||||
@ -7553,9 +7731,9 @@ namespace Catch {
|
||||
// This is the general overload that takes a any string matcher
|
||||
// There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers
|
||||
// the Equals matcher (so the header does not mention matchers)
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ) {
|
||||
std::string exceptionMessage = Catch::translateActiveException();
|
||||
MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher, matcherString );
|
||||
MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher );
|
||||
handler.handleExpr( expr );
|
||||
}
|
||||
|
||||
@ -7634,22 +7812,6 @@ namespace Catch {
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr Catch::StringRef bothOrAll( std::uint64_t count ) {
|
||||
switch (count) {
|
||||
case 1:
|
||||
return Catch::StringRef{};
|
||||
case 2:
|
||||
return "both "_catch_sr;
|
||||
default:
|
||||
return "all "_catch_sr;
|
||||
}
|
||||
}
|
||||
|
||||
} // anon namespace
|
||||
|
||||
|
||||
namespace Catch {
|
||||
namespace {
|
||||
|
||||
@ -7664,42 +7826,6 @@ namespace {
|
||||
static constexpr Catch::StringRef compactPassedString = "passed"_sr;
|
||||
#endif
|
||||
|
||||
// Colour, message variants:
|
||||
// - white: No tests ran.
|
||||
// - red: Failed [both/all] N test cases, failed [both/all] M assertions.
|
||||
// - white: Passed [both/all] N test cases (no assertions).
|
||||
// - red: Failed N tests cases, failed M assertions.
|
||||
// - green: Passed [both/all] N tests cases with M assertions.
|
||||
void printTotals(std::ostream& out, const Totals& totals, ColourImpl* colourImpl) {
|
||||
if (totals.testCases.total() == 0) {
|
||||
out << "No tests ran.";
|
||||
} else if (totals.testCases.failed == totals.testCases.total()) {
|
||||
auto guard = colourImpl->guardColour( Colour::ResultError ).engage( out );
|
||||
const StringRef qualify_assertions_failed =
|
||||
totals.assertions.failed == totals.assertions.total() ?
|
||||
bothOrAll(totals.assertions.failed) : StringRef{};
|
||||
out <<
|
||||
"Failed " << bothOrAll(totals.testCases.failed)
|
||||
<< pluralise(totals.testCases.failed, "test case"_sr) << ", "
|
||||
"failed " << qualify_assertions_failed <<
|
||||
pluralise(totals.assertions.failed, "assertion"_sr) << '.';
|
||||
} else if (totals.assertions.total() == 0) {
|
||||
out <<
|
||||
"Passed " << bothOrAll(totals.testCases.total())
|
||||
<< pluralise(totals.testCases.total(), "test case"_sr)
|
||||
<< " (no assertions).";
|
||||
} else if (totals.assertions.failed) {
|
||||
out << colourImpl->guardColour( Colour::ResultError ) <<
|
||||
"Failed " << pluralise(totals.testCases.failed, "test case"_sr) << ", "
|
||||
"failed " << pluralise(totals.assertions.failed, "assertion"_sr) << '.';
|
||||
} else {
|
||||
out << colourImpl->guardColour( Colour::ResultSuccess ) <<
|
||||
"Passed " << bothOrAll(totals.testCases.passed)
|
||||
<< pluralise(totals.testCases.passed, "test case"_sr) <<
|
||||
" with " << pluralise(totals.assertions.passed, "assertion"_sr) << '.';
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation of CompactReporter formatting
|
||||
class AssertionPrinter {
|
||||
public:
|
||||
@ -7875,10 +8001,10 @@ private:
|
||||
if ( m_config->testSpec().hasFilters() ) {
|
||||
m_stream << m_colour->guardColour( Colour::BrightYellow )
|
||||
<< "Filters: "
|
||||
<< serializeFilters( m_config->getTestsOrTags() )
|
||||
<< m_config->testSpec()
|
||||
<< '\n';
|
||||
}
|
||||
m_stream << "RNG seed: " << m_config->rngSeed() << '\n';
|
||||
m_stream << "RNG seed: " << getSeed() << '\n';
|
||||
}
|
||||
|
||||
void CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) {
|
||||
@ -7907,7 +8033,7 @@ private:
|
||||
}
|
||||
|
||||
void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) {
|
||||
printTotals( m_stream, _testRunStats.totals, m_colour.get() );
|
||||
printTestRunTotals( m_stream, *m_colour, _testRunStats.totals );
|
||||
m_stream << "\n\n" << std::flush;
|
||||
StreamingReporterBase::testRunEnded( _testRunStats );
|
||||
}
|
||||
@ -8389,7 +8515,7 @@ void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) {
|
||||
}
|
||||
void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
|
||||
printTotalsDivider(_testRunStats.totals);
|
||||
printTotals(_testRunStats.totals);
|
||||
printTestRunTotals( m_stream, *m_colour, _testRunStats.totals );
|
||||
m_stream << '\n' << std::flush;
|
||||
StreamingReporterBase::testRunEnded(_testRunStats);
|
||||
}
|
||||
@ -8397,9 +8523,9 @@ void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
|
||||
StreamingReporterBase::testRunStarting(_testInfo);
|
||||
if ( m_config->testSpec().hasFilters() ) {
|
||||
m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: "
|
||||
<< serializeFilters( m_config->getTestsOrTags() ) << '\n';
|
||||
<< m_config->testSpec() << '\n';
|
||||
}
|
||||
m_stream << "Randomness seeded to: " << m_config->rngSeed() << '\n';
|
||||
m_stream << "Randomness seeded to: " << getSeed() << '\n';
|
||||
}
|
||||
|
||||
void ConsoleReporter::lazyPrint() {
|
||||
@ -8496,82 +8622,6 @@ void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
struct SummaryColumn {
|
||||
|
||||
SummaryColumn( std::string _label, Colour::Code _colour )
|
||||
: label( CATCH_MOVE( _label ) ),
|
||||
colour( _colour ) {}
|
||||
SummaryColumn addRow( std::uint64_t count ) {
|
||||
ReusableStringStream rss;
|
||||
rss << count;
|
||||
std::string row = rss.str();
|
||||
for (auto& oldRow : rows) {
|
||||
while (oldRow.size() < row.size())
|
||||
oldRow = ' ' + oldRow;
|
||||
while (oldRow.size() > row.size())
|
||||
row = ' ' + row;
|
||||
}
|
||||
rows.push_back(row);
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string label;
|
||||
Colour::Code colour;
|
||||
std::vector<std::string> rows;
|
||||
|
||||
};
|
||||
|
||||
void ConsoleReporter::printTotals( Totals const& totals ) {
|
||||
if (totals.testCases.total() == 0) {
|
||||
m_stream << m_colour->guardColour( Colour::Warning )
|
||||
<< "No tests ran\n";
|
||||
} else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) {
|
||||
m_stream << m_colour->guardColour( Colour::ResultSuccess )
|
||||
<< "All tests passed";
|
||||
m_stream << " ("
|
||||
<< pluralise(totals.assertions.passed, "assertion"_sr) << " in "
|
||||
<< pluralise(totals.testCases.passed, "test case"_sr) << ')'
|
||||
<< '\n';
|
||||
} else {
|
||||
|
||||
std::vector<SummaryColumn> columns;
|
||||
columns.push_back(SummaryColumn("", Colour::None)
|
||||
.addRow(totals.testCases.total())
|
||||
.addRow(totals.assertions.total()));
|
||||
columns.push_back(SummaryColumn("passed", Colour::Success)
|
||||
.addRow(totals.testCases.passed)
|
||||
.addRow(totals.assertions.passed));
|
||||
columns.push_back(SummaryColumn("failed", Colour::ResultError)
|
||||
.addRow(totals.testCases.failed)
|
||||
.addRow(totals.assertions.failed));
|
||||
columns.push_back(SummaryColumn("failed as expected", Colour::ResultExpectedFailure)
|
||||
.addRow(totals.testCases.failedButOk)
|
||||
.addRow(totals.assertions.failedButOk));
|
||||
|
||||
printSummaryRow("test cases"_sr, columns, 0);
|
||||
printSummaryRow("assertions"_sr, columns, 1);
|
||||
}
|
||||
}
|
||||
void ConsoleReporter::printSummaryRow(StringRef label, std::vector<SummaryColumn> const& cols, std::size_t row) {
|
||||
for (auto col : cols) {
|
||||
std::string const& value = col.rows[row];
|
||||
if (col.label.empty()) {
|
||||
m_stream << label << ": ";
|
||||
if ( value != "0" ) {
|
||||
m_stream << value;
|
||||
} else {
|
||||
m_stream << m_colour->guardColour( Colour::Warning )
|
||||
<< "- none -";
|
||||
}
|
||||
} else if (value != "0") {
|
||||
m_stream << m_colour->guardColour( Colour::LightGrey ) << " | "
|
||||
<< m_colour->guardColour( col.colour ) << value << ' '
|
||||
<< col.label;
|
||||
}
|
||||
}
|
||||
m_stream << '\n';
|
||||
}
|
||||
|
||||
void ConsoleReporter::printTotalsDivider(Totals const& totals) {
|
||||
if (totals.testCases.total() > 0) {
|
||||
std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total());
|
||||
@ -8599,9 +8649,6 @@ void ConsoleReporter::printTotalsDivider(Totals const& totals) {
|
||||
}
|
||||
m_stream << '\n';
|
||||
}
|
||||
void ConsoleReporter::printSummaryDivider() {
|
||||
m_stream << lineOfChars('-') << '\n';
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
@ -9019,6 +9066,104 @@ namespace Catch {
|
||||
out << "\n\n" << std::flush;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class SummaryColumn {
|
||||
public:
|
||||
SummaryColumn( std::string suffix, Colour::Code colour ):
|
||||
m_suffix( CATCH_MOVE( suffix ) ), m_colour( colour ) {}
|
||||
|
||||
SummaryColumn&& addRow( std::uint64_t count ) && {
|
||||
std::string row = std::to_string(count);
|
||||
auto const new_width = std::max( m_width, row.size() );
|
||||
if ( new_width > m_width ) {
|
||||
for ( auto& oldRow : m_rows ) {
|
||||
oldRow.insert( 0, new_width - m_width, ' ' );
|
||||
}
|
||||
} else {
|
||||
row.insert( 0, m_width - row.size(), ' ' );
|
||||
}
|
||||
m_width = new_width;
|
||||
m_rows.push_back( row );
|
||||
return std::move( *this );
|
||||
}
|
||||
|
||||
std::string const& getSuffix() const { return m_suffix; }
|
||||
Colour::Code getColour() const { return m_colour; }
|
||||
std::string const& getRow( std::size_t index ) const {
|
||||
return m_rows[index];
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_suffix;
|
||||
Colour::Code m_colour;
|
||||
std::size_t m_width = 0;
|
||||
std::vector<std::string> m_rows;
|
||||
};
|
||||
|
||||
void printSummaryRow( std::ostream& stream,
|
||||
ColourImpl& colour,
|
||||
StringRef label,
|
||||
std::vector<SummaryColumn> const& cols,
|
||||
std::size_t row ) {
|
||||
for ( auto const& col : cols ) {
|
||||
auto const& value = col.getRow( row );
|
||||
auto const& suffix = col.getSuffix();
|
||||
if ( suffix.empty() ) {
|
||||
stream << label << ": ";
|
||||
if ( value != "0" ) {
|
||||
stream << value;
|
||||
} else {
|
||||
stream << colour.guardColour( Colour::Warning )
|
||||
<< "- none -";
|
||||
}
|
||||
} else if ( value != "0" ) {
|
||||
stream << colour.guardColour( Colour::LightGrey ) << " | "
|
||||
<< colour.guardColour( col.getColour() ) << value
|
||||
<< ' ' << suffix;
|
||||
}
|
||||
}
|
||||
stream << '\n';
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void printTestRunTotals( std::ostream& stream,
|
||||
ColourImpl& streamColour,
|
||||
Totals const& totals ) {
|
||||
if ( totals.testCases.total() == 0 ) {
|
||||
stream << streamColour.guardColour( Colour::Warning )
|
||||
<< "No tests ran\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if ( totals.assertions.total() > 0 && totals.testCases.allPassed() ) {
|
||||
stream << streamColour.guardColour( Colour::ResultSuccess )
|
||||
<< "All tests passed";
|
||||
stream << " ("
|
||||
<< pluralise( totals.assertions.passed, "assertion"_sr )
|
||||
<< " in "
|
||||
<< pluralise( totals.testCases.passed, "test case"_sr )
|
||||
<< ')' << '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<SummaryColumn> columns;
|
||||
columns.push_back( SummaryColumn( "", Colour::None )
|
||||
.addRow( totals.testCases.total() )
|
||||
.addRow( totals.assertions.total() ) );
|
||||
columns.push_back( SummaryColumn( "passed", Colour::Success )
|
||||
.addRow( totals.testCases.passed )
|
||||
.addRow( totals.assertions.passed ) );
|
||||
columns.push_back( SummaryColumn( "failed", Colour::ResultError )
|
||||
.addRow( totals.testCases.failed )
|
||||
.addRow( totals.assertions.failed ) );
|
||||
columns.push_back(
|
||||
SummaryColumn( "failed as expected", Colour::ResultExpectedFailure )
|
||||
.addRow( totals.testCases.failedButOk )
|
||||
.addRow( totals.assertions.failedButOk ) );
|
||||
printSummaryRow( stream, streamColour, "test cases"_sr, columns, 0 );
|
||||
printSummaryRow( stream, streamColour, "assertions"_sr, columns, 1 );
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
|
||||
@ -9039,6 +9184,8 @@ namespace Catch {
|
||||
std::tm timeInfo = {};
|
||||
#if defined (_MSC_VER) || defined (__MINGW32__)
|
||||
gmtime_s(&timeInfo, &rawtime);
|
||||
#elif defined (CATCH_PLATFORM_PLAYSTATION)
|
||||
gmtime_s(&rawtime, &timeInfo);
|
||||
#else
|
||||
gmtime_r(&rawtime, &timeInfo);
|
||||
#endif
|
||||
@ -9152,10 +9299,10 @@ namespace Catch {
|
||||
xml.scopedElement("property")
|
||||
.writeAttribute("name"_sr, "random-seed"_sr)
|
||||
.writeAttribute("value"_sr, m_config->rngSeed());
|
||||
if (m_config->hasTestFilters()) {
|
||||
if (m_config->testSpec().hasFilters()) {
|
||||
xml.scopedElement("property")
|
||||
.writeAttribute("name"_sr, "filters"_sr)
|
||||
.writeAttribute("value"_sr, serializeFilters(m_config->getTestsOrTags()));
|
||||
.writeAttribute("value"_sr, m_config->testSpec());
|
||||
}
|
||||
}
|
||||
|
||||
@ -9528,9 +9675,14 @@ namespace Catch {
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
std::string createRngSeedString(uint32_t seed) {
|
||||
std::string createMetadataString(IConfig const& config) {
|
||||
ReusableStringStream sstr;
|
||||
sstr << "rng-seed=" << seed;
|
||||
if ( config.testSpec().hasFilters() ) {
|
||||
sstr << "filters='"
|
||||
<< config.testSpec()
|
||||
<< "' ";
|
||||
}
|
||||
sstr << "rng-seed=" << config.rngSeed();
|
||||
return sstr.str();
|
||||
}
|
||||
}
|
||||
@ -9538,7 +9690,7 @@ namespace Catch {
|
||||
void SonarQubeReporter::testRunStarting(TestRunInfo const& testRunInfo) {
|
||||
CumulativeReporterBase::testRunStarting(testRunInfo);
|
||||
|
||||
xml.writeComment( createRngSeedString( m_config->rngSeed() ) );
|
||||
xml.writeComment( createMetadataString( *m_config ) );
|
||||
xml.startElement("testExecutions");
|
||||
xml.writeAttribute("version"_sr, '1');
|
||||
}
|
||||
@ -9858,6 +10010,9 @@ namespace Catch {
|
||||
} // End anonymous namespace
|
||||
|
||||
void TAPReporter::testRunStarting( TestRunInfo const& ) {
|
||||
if ( m_config->testSpec().hasFilters() ) {
|
||||
m_stream << "# filters: " << m_config->testSpec() << '\n';
|
||||
}
|
||||
m_stream << "# rng-seed: " << m_config->rngSeed() << '\n';
|
||||
}
|
||||
|
||||
@ -10096,9 +10251,11 @@ namespace Catch {
|
||||
m_xml.startElement("Catch2TestRun")
|
||||
.writeAttribute("name"_sr, m_config->name())
|
||||
.writeAttribute("rng-seed"_sr, m_config->rngSeed())
|
||||
.writeAttribute("xml-format-version"_sr, 2)
|
||||
.writeAttribute("catch2-version"_sr, libraryVersion());
|
||||
if (m_config->testSpec().hasFilters())
|
||||
m_xml.writeAttribute( "filters"_sr, serializeFilters( m_config->getTestsOrTags() ) );
|
||||
if ( m_config->testSpec().hasFilters() ) {
|
||||
m_xml.writeAttribute( "filters"_sr, m_config->testSpec() );
|
||||
}
|
||||
}
|
||||
|
||||
void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) {
|
||||
|
File diff suppressed because it is too large
Load Diff
17
meson.build
Normal file
17
meson.build
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright Catch2 Authors
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.txt or copy at
|
||||
# https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
project(
|
||||
'catch2',
|
||||
'cpp',
|
||||
version: '3.2.1', # CML version placeholder, don't delete
|
||||
license: 'BSL-1.0',
|
||||
meson_version: '>=0.50.0',
|
||||
)
|
||||
|
||||
subdir('src/catch2')
|
||||
subdir('tests')
|
@ -7,291 +7,332 @@ include(CatchMiscFunctions)
|
||||
set(Catch2_GUID_CMAKE "8d538cbe-01bf-4a2e-a98a-6c368fdf13d7" CACHE INTERNAL "Project GUID")
|
||||
set(Catch2WithMain_GUID_CMAKE "8bd3552a-2cfb-4a59-ab15-2031b97ada1e" CACHE INTERNAL "Project GUID")
|
||||
|
||||
# Please keep these ordered alphabetically
|
||||
set(BENCHMARK_HEADERS
|
||||
${SOURCES_DIR}/benchmark/catch_benchmark.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_benchmark_all.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_chronometer.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_clock.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_constructor.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_environment.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_estimate.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_execution_plan.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_optimizer.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_outlier_classification.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_sample_analysis.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_analyse.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_complete_invoke.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_estimate_clock.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_measure.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_repeat.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_stats.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_timing.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_benchmark.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_benchmark_all.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_chronometer.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_clock.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_constructor.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_environment.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_estimate.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_execution_plan.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_optimizer.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_outlier_classification.hpp
|
||||
${SOURCES_DIR}/benchmark/catch_sample_analysis.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_analyse.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_complete_invoke.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_estimate_clock.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_measure.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_repeat.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_stats.hpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_timing.hpp
|
||||
)
|
||||
set(BENCHMARK_SOURCES
|
||||
${SOURCES_DIR}/benchmark/catch_chronometer.cpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_stats.cpp
|
||||
${SOURCES_DIR}/benchmark/catch_chronometer.cpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp
|
||||
${SOURCES_DIR}/benchmark/detail/catch_stats.cpp
|
||||
)
|
||||
set(BENCHMARK_FILES ${BENCHMARK_HEADERS} ${BENCHMARK_SOURCES})
|
||||
|
||||
SOURCE_GROUP("benchmark" FILES ${BENCHMARK_HEADERS} ${BENCHMARK_SOURCES})
|
||||
|
||||
set(INTERNAL_HEADERS
|
||||
"${CMAKE_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
||||
"${SOURCES_DIR}/catch_user_config.hpp.in"
|
||||
${SOURCES_DIR}/catch_all.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_all.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_all.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_all.hpp
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_width.hpp
|
||||
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
||||
${SOURCES_DIR}/internal/catch_noncopyable.hpp
|
||||
${SOURCES_DIR}/catch_approx.hpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.hpp
|
||||
${SOURCES_DIR}/catch_assertion_info.hpp
|
||||
${SOURCES_DIR}/catch_assertion_result.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_macro_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_failure_exception.hpp
|
||||
${SOURCES_DIR}/internal/catch_case_sensitive.hpp
|
||||
${SOURCES_DIR}/internal/catch_clara.hpp
|
||||
${SOURCES_DIR}/internal/catch_commandline.hpp
|
||||
${SOURCES_DIR}/internal/catch_source_line_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
|
||||
${SOURCES_DIR}/catch_config.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_counter.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_wchar.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
||||
${SOURCES_DIR}/internal/catch_context.hpp
|
||||
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
||||
${SOURCES_DIR}/internal/catch_debugger.hpp
|
||||
${SOURCES_DIR}/internal/catch_decomposer.hpp
|
||||
${SOURCES_DIR}/internal/catch_enforce.hpp
|
||||
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
|
||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.hpp
|
||||
${SOURCES_DIR}/internal/catch_istream.hpp
|
||||
${SOURCES_DIR}/internal/catch_unique_name.hpp
|
||||
${SOURCES_DIR}/internal/catch_sharding.hpp
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_adapters.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_random.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_range.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_enum_values_registry.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_tag_alias_registry.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp
|
||||
${SOURCES_DIR}/internal/catch_lazy_expr.hpp
|
||||
${SOURCES_DIR}/internal/catch_leak_detector.hpp
|
||||
${SOURCES_DIR}/internal/catch_list.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_container_properties.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_contains.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_exception.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_floating_point.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_predicate.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_string.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_templated.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_vector.hpp
|
||||
${SOURCES_DIR}/catch_message.hpp
|
||||
${SOURCES_DIR}/internal/catch_message_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_meta.hpp
|
||||
${SOURCES_DIR}/internal/catch_move_and_forward.hpp
|
||||
${SOURCES_DIR}/internal/catch_optional.hpp
|
||||
${SOURCES_DIR}/internal/catch_output_redirect.hpp
|
||||
${SOURCES_DIR}/internal/catch_platform.hpp
|
||||
${SOURCES_DIR}/internal/catch_polyfills.hpp
|
||||
${SOURCES_DIR}/internal/catch_preprocessor.hpp
|
||||
${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp
|
||||
${SOURCES_DIR}/internal/catch_random_number_generator.hpp
|
||||
${SOURCES_DIR}/internal/catch_random_seed_generation.hpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.hpp
|
||||
${SOURCES_DIR}/internal/catch_result_type.hpp
|
||||
${SOURCES_DIR}/internal/catch_run_context.hpp
|
||||
${SOURCES_DIR}/internal/catch_section.hpp
|
||||
${SOURCES_DIR}/internal/catch_stdstreams.hpp
|
||||
${SOURCES_DIR}/catch_section_info.hpp
|
||||
${SOURCES_DIR}/catch_session.hpp
|
||||
${SOURCES_DIR}/internal/catch_singletons.hpp
|
||||
${SOURCES_DIR}/internal/catch_startup_exception_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.hpp
|
||||
${SOURCES_DIR}/internal/catch_stream_end_stop.hpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.hpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.hpp
|
||||
${SOURCES_DIR}/catch_tag_alias.hpp
|
||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.hpp
|
||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.hpp
|
||||
${SOURCES_DIR}/catch_test_case_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_registry_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_tracker.hpp
|
||||
${SOURCES_DIR}/catch_template_test_macros.hpp
|
||||
${SOURCES_DIR}/catch_test_macros.hpp
|
||||
${SOURCES_DIR}/internal/catch_template_test_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_registry.hpp
|
||||
${SOURCES_DIR}/catch_test_spec.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_spec_parser.hpp
|
||||
${SOURCES_DIR}/internal/catch_textflow.hpp
|
||||
${SOURCES_DIR}/catch_timer.hpp
|
||||
${SOURCES_DIR}/internal/catch_to_string.hpp
|
||||
${SOURCES_DIR}/catch_tostring.hpp
|
||||
${SOURCES_DIR}/catch_totals.hpp
|
||||
${SOURCES_DIR}/catch_translate_exception.hpp
|
||||
${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp
|
||||
${SOURCES_DIR}/internal/catch_unique_ptr.hpp
|
||||
${SOURCES_DIR}/internal/catch_void_type.hpp
|
||||
${SOURCES_DIR}/catch_version.hpp
|
||||
${SOURCES_DIR}/catch_version_macros.hpp
|
||||
${SOURCES_DIR}/internal/catch_wildcard_pattern.hpp
|
||||
${SOURCES_DIR}/internal/catch_windows_h_proxy.hpp
|
||||
${SOURCES_DIR}/internal/catch_xmlwriter.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_info_hasher.hpp
|
||||
set(IMPL_HEADERS
|
||||
"${CMAKE_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
||||
${SOURCES_DIR}/catch_user_config.hpp.in
|
||||
${SOURCES_DIR}/catch_all.hpp
|
||||
${SOURCES_DIR}/catch_approx.hpp
|
||||
${SOURCES_DIR}/catch_assertion_info.hpp
|
||||
${SOURCES_DIR}/catch_assertion_result.hpp
|
||||
${SOURCES_DIR}/catch_config.hpp
|
||||
${SOURCES_DIR}/catch_get_random_seed.hpp
|
||||
${SOURCES_DIR}/catch_message.hpp
|
||||
${SOURCES_DIR}/catch_section_info.hpp
|
||||
${SOURCES_DIR}/catch_session.hpp
|
||||
${SOURCES_DIR}/catch_tag_alias.hpp
|
||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.hpp
|
||||
${SOURCES_DIR}/catch_template_test_macros.hpp
|
||||
${SOURCES_DIR}/catch_test_case_info.hpp
|
||||
${SOURCES_DIR}/catch_test_macros.hpp
|
||||
${SOURCES_DIR}/catch_test_spec.hpp
|
||||
${SOURCES_DIR}/catch_timer.hpp
|
||||
${SOURCES_DIR}/catch_tostring.hpp
|
||||
${SOURCES_DIR}/catch_totals.hpp
|
||||
${SOURCES_DIR}/catch_translate_exception.hpp
|
||||
${SOURCES_DIR}/catch_version.hpp
|
||||
${SOURCES_DIR}/catch_version_macros.hpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.hpp
|
||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.hpp
|
||||
${SOURCES_DIR}/internal/catch_case_sensitive.hpp
|
||||
${SOURCES_DIR}/internal/catch_clara.hpp
|
||||
${SOURCES_DIR}/internal/catch_commandline.hpp
|
||||
${SOURCES_DIR}/internal/catch_compare_traits.hpp
|
||||
${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_counter.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
||||
${SOURCES_DIR}/internal/catch_config_wchar.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_width.hpp
|
||||
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
||||
${SOURCES_DIR}/internal/catch_context.hpp
|
||||
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
||||
${SOURCES_DIR}/internal/catch_debugger.hpp
|
||||
${SOURCES_DIR}/internal/catch_decomposer.hpp
|
||||
${SOURCES_DIR}/internal/catch_enforce.hpp
|
||||
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
|
||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.hpp
|
||||
${SOURCES_DIR}/internal/catch_getenv.hpp
|
||||
${SOURCES_DIR}/internal/catch_istream.hpp
|
||||
${SOURCES_DIR}/internal/catch_lazy_expr.hpp
|
||||
${SOURCES_DIR}/internal/catch_leak_detector.hpp
|
||||
${SOURCES_DIR}/internal/catch_list.hpp
|
||||
${SOURCES_DIR}/internal/catch_logical_traits.hpp
|
||||
${SOURCES_DIR}/internal/catch_message_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_meta.hpp
|
||||
${SOURCES_DIR}/internal/catch_move_and_forward.hpp
|
||||
${SOURCES_DIR}/internal/catch_noncopyable.hpp
|
||||
${SOURCES_DIR}/internal/catch_optional.hpp
|
||||
${SOURCES_DIR}/internal/catch_output_redirect.hpp
|
||||
${SOURCES_DIR}/internal/catch_parse_numbers.hpp
|
||||
${SOURCES_DIR}/internal/catch_platform.hpp
|
||||
${SOURCES_DIR}/internal/catch_polyfills.hpp
|
||||
${SOURCES_DIR}/internal/catch_preprocessor.hpp
|
||||
${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp
|
||||
${SOURCES_DIR}/internal/catch_random_number_generator.hpp
|
||||
${SOURCES_DIR}/internal/catch_random_seed_generation.hpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.hpp
|
||||
${SOURCES_DIR}/internal/catch_result_type.hpp
|
||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.hpp
|
||||
${SOURCES_DIR}/internal/catch_run_context.hpp
|
||||
${SOURCES_DIR}/internal/catch_section.hpp
|
||||
${SOURCES_DIR}/internal/catch_sharding.hpp
|
||||
${SOURCES_DIR}/internal/catch_singletons.hpp
|
||||
${SOURCES_DIR}/internal/catch_source_line_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_startup_exception_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_stdstreams.hpp
|
||||
${SOURCES_DIR}/internal/catch_stream_end_stop.hpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.hpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.hpp
|
||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_template_test_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_info_hasher.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_registry_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_tracker.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_failure_exception.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_macro_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_spec_parser.hpp
|
||||
${SOURCES_DIR}/internal/catch_textflow.hpp
|
||||
${SOURCES_DIR}/internal/catch_to_string.hpp
|
||||
${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp
|
||||
${SOURCES_DIR}/internal/catch_unique_name.hpp
|
||||
${SOURCES_DIR}/internal/catch_unique_ptr.hpp
|
||||
${SOURCES_DIR}/internal/catch_void_type.hpp
|
||||
${SOURCES_DIR}/internal/catch_wildcard_pattern.hpp
|
||||
${SOURCES_DIR}/internal/catch_windows_h_proxy.hpp
|
||||
${SOURCES_DIR}/internal/catch_xmlwriter.hpp
|
||||
)
|
||||
set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/catch_approx.cpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.cpp
|
||||
${SOURCES_DIR}/catch_assertion_result.cpp
|
||||
${SOURCES_DIR}/internal/catch_clara.cpp
|
||||
${SOURCES_DIR}/internal/catch_commandline.cpp
|
||||
${SOURCES_DIR}/internal/catch_source_line_info.cpp
|
||||
${SOURCES_DIR}/catch_config.cpp
|
||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp
|
||||
${SOURCES_DIR}/internal/catch_console_colour.cpp
|
||||
${SOURCES_DIR}/internal/catch_context.cpp
|
||||
${SOURCES_DIR}/internal/catch_debug_console.cpp
|
||||
${SOURCES_DIR}/internal/catch_debugger.cpp
|
||||
${SOURCES_DIR}/internal/catch_enforce.cpp
|
||||
${SOURCES_DIR}/internal/catch_enum_values_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
|
||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp
|
||||
${SOURCES_DIR}/internal/catch_istream.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
||||
${SOURCES_DIR}/internal/catch_list.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_floating_point.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_string.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_templated.cpp
|
||||
${SOURCES_DIR}/catch_message.cpp
|
||||
${SOURCES_DIR}/internal/catch_output_redirect.cpp
|
||||
${SOURCES_DIR}/catch_registry_hub.cpp
|
||||
${SOURCES_DIR}/internal/catch_random_number_generator.cpp
|
||||
${SOURCES_DIR}/internal/catch_random_seed_generation.cpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp
|
||||
${SOURCES_DIR}/internal/catch_result_type.cpp
|
||||
${SOURCES_DIR}/internal/catch_run_context.cpp
|
||||
${SOURCES_DIR}/internal/catch_section.cpp
|
||||
${SOURCES_DIR}/internal/catch_stdstreams.cpp
|
||||
${SOURCES_DIR}/catch_session.cpp
|
||||
${SOURCES_DIR}/internal/catch_singletons.cpp
|
||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.cpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.cpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.cpp
|
||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
|
||||
${SOURCES_DIR}/catch_test_case_info.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_registry_impl.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_tracker.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_textflow.cpp
|
||||
${SOURCES_DIR}/catch_test_spec.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_spec_parser.cpp
|
||||
${SOURCES_DIR}/catch_timer.cpp
|
||||
${SOURCES_DIR}/catch_tostring.cpp
|
||||
${SOURCES_DIR}/catch_totals.cpp
|
||||
${SOURCES_DIR}/catch_version.cpp
|
||||
${SOURCES_DIR}/internal/catch_wildcard_pattern.cpp
|
||||
${SOURCES_DIR}/internal/catch_xmlwriter.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp
|
||||
${SOURCES_DIR}/generators/catch_generators_random.cpp
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.cpp
|
||||
${SOURCES_DIR}/generators/catch_generators.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_container_properties.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_exception.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_predicate.cpp
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.cpp
|
||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
||||
${SOURCES_DIR}/internal/catch_decomposer.cpp
|
||||
${SOURCES_DIR}/internal/catch_errno_guard.cpp
|
||||
${SOURCES_DIR}/internal/catch_lazy_expr.cpp
|
||||
${SOURCES_DIR}/internal/catch_leak_detector.cpp
|
||||
${SOURCES_DIR}/internal/catch_message_info.cpp
|
||||
${SOURCES_DIR}/internal/catch_polyfills.cpp
|
||||
${SOURCES_DIR}/internal/catch_startup_exception_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_uncaught_exceptions.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.cpp
|
||||
${SOURCES_DIR}/catch_approx.cpp
|
||||
${SOURCES_DIR}/catch_assertion_result.cpp
|
||||
${SOURCES_DIR}/catch_config.cpp
|
||||
${SOURCES_DIR}/catch_get_random_seed.cpp
|
||||
${SOURCES_DIR}/catch_message.cpp
|
||||
${SOURCES_DIR}/catch_registry_hub.cpp
|
||||
${SOURCES_DIR}/catch_session.cpp
|
||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
||||
${SOURCES_DIR}/catch_test_case_info.cpp
|
||||
${SOURCES_DIR}/catch_test_spec.cpp
|
||||
${SOURCES_DIR}/catch_timer.cpp
|
||||
${SOURCES_DIR}/catch_tostring.cpp
|
||||
${SOURCES_DIR}/catch_totals.cpp
|
||||
${SOURCES_DIR}/catch_version.cpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.cpp
|
||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp
|
||||
${SOURCES_DIR}/internal/catch_clara.cpp
|
||||
${SOURCES_DIR}/internal/catch_commandline.cpp
|
||||
${SOURCES_DIR}/internal/catch_console_colour.cpp
|
||||
${SOURCES_DIR}/internal/catch_context.cpp
|
||||
${SOURCES_DIR}/internal/catch_debug_console.cpp
|
||||
${SOURCES_DIR}/internal/catch_debugger.cpp
|
||||
${SOURCES_DIR}/internal/catch_decomposer.cpp
|
||||
${SOURCES_DIR}/internal/catch_enforce.cpp
|
||||
${SOURCES_DIR}/internal/catch_enum_values_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_errno_guard.cpp
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
|
||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp
|
||||
${SOURCES_DIR}/internal/catch_getenv.cpp
|
||||
${SOURCES_DIR}/internal/catch_istream.cpp
|
||||
${SOURCES_DIR}/internal/catch_lazy_expr.cpp
|
||||
${SOURCES_DIR}/internal/catch_leak_detector.cpp
|
||||
${SOURCES_DIR}/internal/catch_list.cpp
|
||||
${SOURCES_DIR}/internal/catch_message_info.cpp
|
||||
${SOURCES_DIR}/internal/catch_output_redirect.cpp
|
||||
${SOURCES_DIR}/internal/catch_parse_numbers.cpp
|
||||
${SOURCES_DIR}/internal/catch_polyfills.cpp
|
||||
${SOURCES_DIR}/internal/catch_random_number_generator.cpp
|
||||
${SOURCES_DIR}/internal/catch_random_seed_generation.cpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp
|
||||
${SOURCES_DIR}/internal/catch_result_type.cpp
|
||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.cpp
|
||||
${SOURCES_DIR}/internal/catch_run_context.cpp
|
||||
${SOURCES_DIR}/internal/catch_section.cpp
|
||||
${SOURCES_DIR}/internal/catch_singletons.cpp
|
||||
${SOURCES_DIR}/internal/catch_source_line_info.cpp
|
||||
${SOURCES_DIR}/internal/catch_startup_exception_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_stdstreams.cpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.cpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.cpp
|
||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_registry_impl.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_case_tracker.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_failure_exception.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_test_spec_parser.cpp
|
||||
${SOURCES_DIR}/internal/catch_textflow.cpp
|
||||
${SOURCES_DIR}/internal/catch_uncaught_exceptions.cpp
|
||||
${SOURCES_DIR}/internal/catch_wildcard_pattern.cpp
|
||||
${SOURCES_DIR}/internal/catch_xmlwriter.cpp
|
||||
)
|
||||
set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS})
|
||||
set(INTERNAL_FILES ${IMPL_SOURCES} ${IMPL_HEADERS})
|
||||
|
||||
set(INTERFACE_HEADERS
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_all.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_enum_values_registry.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_tag_alias_registry.hpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp
|
||||
)
|
||||
set(INTERFACE_SOURCES
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.cpp
|
||||
)
|
||||
set(INTERFACE_FILES ${INTERFACE_HEADERS} ${INTERFACE_SOURCES})
|
||||
|
||||
set(GENERATOR_HEADERS
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_adapters.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_all.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_random.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_range.hpp
|
||||
)
|
||||
set(GENERATOR_SOURCES
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.cpp
|
||||
${SOURCES_DIR}/generators/catch_generators.cpp
|
||||
${SOURCES_DIR}/generators/catch_generators_random.cpp
|
||||
)
|
||||
set(GENERATOR_FILES ${GENERATOR_HEADERS} ${GENERATOR_SOURCES})
|
||||
|
||||
set(MATCHER_HEADERS
|
||||
${SOURCES_DIR}/matchers/catch_matchers.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_all.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_container_properties.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_contains.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_exception.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_floating_point.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_predicate.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_string.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_templated.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_vector.hpp
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp
|
||||
)
|
||||
set(MATCHER_SOURCES
|
||||
${SOURCES_DIR}/matchers/catch_matchers.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_container_properties.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_exception.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_floating_point.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_predicate.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_string.cpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_templated.cpp
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.cpp
|
||||
)
|
||||
set(MATCHER_FILES ${MATCHER_HEADERS} ${MATCHER_SOURCES})
|
||||
|
||||
# Please keep these ordered alphabetically
|
||||
set(REPORTER_HEADERS
|
||||
${SOURCES_DIR}/reporters/catch_reporters_all.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_automake.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_common_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_compact.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_console.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_junit.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_multi.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_registrars.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_tap.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_xml.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_automake.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_common_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_compact.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_console.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_junit.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_multi.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_registrars.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_tap.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_xml.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporters_all.hpp
|
||||
)
|
||||
set(REPORTER_SOURCES
|
||||
${SOURCES_DIR}/reporters/catch_reporter_automake.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_common_base.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_compact.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_console.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_junit.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_multi.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_registrars.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_tap.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_xml.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_automake.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_common_base.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_compact.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_console.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_junit.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_multi.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_registrars.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_tap.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_xml.cpp
|
||||
)
|
||||
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
||||
|
||||
add_library(Catch2
|
||||
set(ALL_FILES
|
||||
${BENCHMARK_FILES}
|
||||
${GENERATOR_FILES}
|
||||
${REPORTER_FILES}
|
||||
${INTERFACE_FILES}
|
||||
${INTERNAL_FILES}
|
||||
${BENCHMARK_HEADERS}
|
||||
${BENCHMARK_SOURCES}
|
||||
${MATCHER_FILES}
|
||||
)
|
||||
|
||||
set(FILTERED_FILES ${ALL_FILES})
|
||||
list(REMOVE_ITEM FILTERED_FILES "${CMAKE_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp")
|
||||
source_group(
|
||||
TREE ${SOURCES_DIR}
|
||||
PREFIX sources
|
||||
FILES ${FILTERED_FILES}
|
||||
)
|
||||
source_group("generated headers"
|
||||
FILES
|
||||
"${CMAKE_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
||||
)
|
||||
|
||||
add_library(Catch2 ${ALL_FILES})
|
||||
add_build_reproducibility_settings(Catch2)
|
||||
add_library(Catch2::Catch2 ALIAS Catch2)
|
||||
|
||||
@ -299,7 +340,10 @@ if (ANDROID)
|
||||
target_link_libraries(Catch2 INTERFACE log)
|
||||
endif()
|
||||
|
||||
set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "d")
|
||||
set_target_properties(Catch2 PROPERTIES
|
||||
DEBUG_POSTFIX "d"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION})
|
||||
|
||||
# depend on bunch of C++11 and C++14 features to have C++14 enabled by default
|
||||
target_compile_features(Catch2
|
||||
@ -348,6 +392,8 @@ target_link_libraries(Catch2WithMain PUBLIC Catch2)
|
||||
set_target_properties(Catch2WithMain
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "Catch2Main"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION}
|
||||
)
|
||||
set_target_properties(Catch2WithMain PROPERTIES DEBUG_POSTFIX "d")
|
||||
|
||||
@ -359,8 +405,12 @@ if (NOT_SUBPROJECT)
|
||||
Catch2WithMain
|
||||
EXPORT
|
||||
Catch2Targets
|
||||
DESTINATION
|
||||
LIBRARY DESTINATION
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION
|
||||
${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
@ -390,10 +440,7 @@ endif()
|
||||
if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||
add_library(Catch2_buildall_interface INTERFACE)
|
||||
target_sources(Catch2_buildall_interface INTERFACE
|
||||
${REPORTER_FILES}
|
||||
${INTERNAL_FILES}
|
||||
${BENCHMARK_HEADERS}
|
||||
${BENCHMARK_SOURCES}
|
||||
${ALL_FILES}
|
||||
# Also include main entry point
|
||||
${SOURCES_DIR}/internal/catch_main.cpp
|
||||
)
|
||||
@ -403,6 +450,10 @@ if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated-includes>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
target_compile_definitions(Catch2_buildall_interface
|
||||
INTERFACE
|
||||
CATCH_CONFIG_STATIC
|
||||
)
|
||||
target_compile_features(Catch2_buildall_interface
|
||||
INTERFACE
|
||||
cxx_alignas
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -54,14 +54,18 @@ namespace Catch {
|
||||
template <typename U>
|
||||
void destruct_on_exit(std::enable_if_t<!Destruct, U>* = nullptr) { }
|
||||
|
||||
T& stored_object() {
|
||||
return *static_cast<T*>(static_cast<void*>(data));
|
||||
}
|
||||
#if defined( __GNUC__ ) && __GNUC__ <= 6
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
T& stored_object() { return *reinterpret_cast<T*>( data ); }
|
||||
|
||||
T const& stored_object() const {
|
||||
return *static_cast<T const*>(static_cast<void const*>(data));
|
||||
return *reinterpret_cast<T const*>( data );
|
||||
}
|
||||
|
||||
#if defined( __GNUC__ ) && __GNUC__ <= 6
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
alignas( T ) unsigned char data[sizeof( T )]{};
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -27,6 +27,7 @@
|
||||
#include <catch2/catch_assertion_info.hpp>
|
||||
#include <catch2/catch_assertion_result.hpp>
|
||||
#include <catch2/catch_config.hpp>
|
||||
#include <catch2/catch_get_random_seed.hpp>
|
||||
#include <catch2/catch_message.hpp>
|
||||
#include <catch2/catch_section_info.hpp>
|
||||
#include <catch2/catch_session.hpp>
|
||||
@ -49,6 +50,7 @@
|
||||
#include <catch2/internal/catch_case_sensitive.hpp>
|
||||
#include <catch2/internal/catch_clara.hpp>
|
||||
#include <catch2/internal/catch_commandline.hpp>
|
||||
#include <catch2/internal/catch_compare_traits.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_config_android_logwrite.hpp>
|
||||
#include <catch2/internal/catch_config_counter.hpp>
|
||||
@ -67,16 +69,19 @@
|
||||
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
||||
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
||||
#include <catch2/internal/catch_floating_point_helpers.hpp>
|
||||
#include <catch2/internal/catch_getenv.hpp>
|
||||
#include <catch2/internal/catch_istream.hpp>
|
||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||
#include <catch2/internal/catch_leak_detector.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_logical_traits.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/internal/catch_optional.hpp>
|
||||
#include <catch2/internal/catch_output_redirect.hpp>
|
||||
#include <catch2/internal/catch_parse_numbers.hpp>
|
||||
#include <catch2/internal/catch_platform.hpp>
|
||||
#include <catch2/internal/catch_polyfills.hpp>
|
||||
#include <catch2/internal/catch_preprocessor.hpp>
|
||||
@ -113,7 +118,6 @@
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
#include <catch2/internal/catch_void_type.hpp>
|
||||
#include <catch2/internal/catch_wildcard_pattern.hpp>
|
||||
#include <catch2/internal/catch_windows_h_proxy.hpp>
|
||||
#include <catch2/internal/catch_xmlwriter.hpp>
|
||||
#include <catch2/matchers/catch_matchers_all.hpp>
|
||||
#include <catch2/reporters/catch_reporters_all.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,42 +1,89 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/catch_config.hpp>
|
||||
#include <catch2/catch_user_config.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_parse_numbers.hpp>
|
||||
#include <catch2/internal/catch_stdstreams.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_test_spec_parser.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
|
||||
#include <catch2/internal/catch_getenv.hpp>
|
||||
|
||||
namespace {
|
||||
bool provideBazelReporterOutput() {
|
||||
#ifdef CATCH_CONFIG_BAZEL_SUPPORT
|
||||
return true;
|
||||
#else
|
||||
|
||||
# if defined( _MSC_VER )
|
||||
// On Windows getenv throws a warning as there is no input validation,
|
||||
// since the switch is hardcoded, this should not be an issue.
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4996 )
|
||||
# endif
|
||||
|
||||
return std::getenv( "BAZEL_TEST" ) != nullptr;
|
||||
|
||||
# if defined( _MSC_VER )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#include <fstream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
static bool enableBazelEnvSupport() {
|
||||
#if defined( CATCH_CONFIG_BAZEL_SUPPORT )
|
||||
return true;
|
||||
#else
|
||||
return Detail::getEnv( "BAZEL_TEST" ) != nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct bazelShardingOptions {
|
||||
unsigned int shardIndex, shardCount;
|
||||
std::string shardFilePath;
|
||||
};
|
||||
|
||||
static Optional<bazelShardingOptions> readBazelShardingOptions() {
|
||||
const auto bazelShardIndex = Detail::getEnv( "TEST_SHARD_INDEX" );
|
||||
const auto bazelShardTotal = Detail::getEnv( "TEST_TOTAL_SHARDS" );
|
||||
const auto bazelShardInfoFile = Detail::getEnv( "TEST_SHARD_STATUS_FILE" );
|
||||
|
||||
|
||||
const bool has_all =
|
||||
bazelShardIndex && bazelShardTotal && bazelShardInfoFile;
|
||||
if ( !has_all ) {
|
||||
// We provide nice warning message if the input is
|
||||
// misconfigured.
|
||||
auto warn = []( const char* env_var ) {
|
||||
Catch::cerr()
|
||||
<< "Warning: Bazel shard configuration is missing '"
|
||||
<< env_var << "'. Shard configuration is skipped.\n";
|
||||
};
|
||||
if ( !bazelShardIndex ) {
|
||||
warn( "TEST_SHARD_INDEX" );
|
||||
}
|
||||
if ( !bazelShardTotal ) {
|
||||
warn( "TEST_TOTAL_SHARDS" );
|
||||
}
|
||||
if ( !bazelShardInfoFile ) {
|
||||
warn( "TEST_SHARD_STATUS_FILE" );
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
auto shardIndex = parseUInt( bazelShardIndex );
|
||||
if ( !shardIndex ) {
|
||||
Catch::cerr()
|
||||
<< "Warning: could not parse 'TEST_SHARD_INDEX' ('" << bazelShardIndex
|
||||
<< "') as unsigned int.\n";
|
||||
return {};
|
||||
}
|
||||
auto shardTotal = parseUInt( bazelShardTotal );
|
||||
if ( !shardTotal ) {
|
||||
Catch::cerr()
|
||||
<< "Warning: could not parse 'TEST_TOTAL_SHARD' ('"
|
||||
<< bazelShardTotal << "') as unsigned int.\n";
|
||||
return {};
|
||||
}
|
||||
|
||||
return bazelShardingOptions{
|
||||
*shardIndex, *shardTotal, bazelShardInfoFile };
|
||||
|
||||
}
|
||||
} // end namespace
|
||||
|
||||
|
||||
bool operator==( ProcessedReporterSpec const& lhs,
|
||||
ProcessedReporterSpec const& rhs ) {
|
||||
return lhs.name == rhs.name &&
|
||||
@ -58,17 +105,6 @@ namespace Catch {
|
||||
elem = trim(elem);
|
||||
}
|
||||
|
||||
|
||||
TestSpecParser parser(ITagAliasRegistry::get());
|
||||
if (!m_data.testsOrTags.empty()) {
|
||||
m_hasTestFilters = true;
|
||||
for (auto const& testOrTags : m_data.testsOrTags) {
|
||||
parser.parse(testOrTags);
|
||||
}
|
||||
}
|
||||
m_testSpec = parser.testSpec();
|
||||
|
||||
|
||||
// Insert the default reporter if user hasn't asked for a specfic one
|
||||
if ( m_data.reporterSpecifications.empty() ) {
|
||||
m_data.reporterSpecifications.push_back( {
|
||||
@ -81,27 +117,20 @@ namespace Catch {
|
||||
} );
|
||||
}
|
||||
|
||||
if(provideBazelReporterOutput()){
|
||||
// Register a JUnit reporter for Bazel. Bazel sets an environment
|
||||
// variable with the path to XML output. If this file is written to
|
||||
// during test, Bazel will not generate a default XML output.
|
||||
// This allows the XML output file to contain higher level of detail
|
||||
// than what is possible otherwise.
|
||||
# if defined( _MSC_VER )
|
||||
// On Windows getenv throws a warning as there is no input validation,
|
||||
// since the key is hardcoded, this should not be an issue.
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable : 4996 )
|
||||
# endif
|
||||
const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" );
|
||||
# if defined( _MSC_VER )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
if ( bazelOutputFilePtr != nullptr ) {
|
||||
m_data.reporterSpecifications.push_back(
|
||||
{ "junit", std::string( bazelOutputFilePtr ), {}, {} } );
|
||||
if ( enableBazelEnvSupport() ) {
|
||||
readBazelEnvVars();
|
||||
}
|
||||
|
||||
// Bazel support can modify the test specs, so parsing has to happen
|
||||
// after reading Bazel env vars.
|
||||
TestSpecParser parser( ITagAliasRegistry::get() );
|
||||
if ( !m_data.testsOrTags.empty() ) {
|
||||
m_hasTestFilters = true;
|
||||
for ( auto const& testOrTags : m_data.testsOrTags ) {
|
||||
parser.parse( testOrTags );
|
||||
}
|
||||
}
|
||||
}
|
||||
m_testSpec = parser.testSpec();
|
||||
|
||||
|
||||
// We now fixup the reporter specs to handle default output spec,
|
||||
@ -182,4 +211,37 @@ namespace Catch {
|
||||
unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; }
|
||||
std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); }
|
||||
|
||||
void Config::readBazelEnvVars() {
|
||||
// Register a JUnit reporter for Bazel. Bazel sets an environment
|
||||
// variable with the path to XML output. If this file is written to
|
||||
// during test, Bazel will not generate a default XML output.
|
||||
// This allows the XML output file to contain higher level of detail
|
||||
// than what is possible otherwise.
|
||||
const auto bazelOutputFile = Detail::getEnv( "XML_OUTPUT_FILE" );
|
||||
|
||||
if ( bazelOutputFile ) {
|
||||
m_data.reporterSpecifications.push_back(
|
||||
{ "junit", std::string( bazelOutputFile ), {}, {} } );
|
||||
}
|
||||
|
||||
const auto bazelTestSpec = Detail::getEnv( "TESTBRIDGE_TEST_ONLY" );
|
||||
if ( bazelTestSpec ) {
|
||||
// Presumably the test spec from environment should overwrite
|
||||
// the one we got from CLI (if we got any)
|
||||
m_data.testsOrTags.clear();
|
||||
m_data.testsOrTags.push_back( bazelTestSpec );
|
||||
}
|
||||
|
||||
const auto bazelShardOptions = readBazelShardingOptions();
|
||||
if ( bazelShardOptions ) {
|
||||
std::ofstream f( bazelShardOptions->shardFilePath,
|
||||
std::ios_base::out | std::ios_base::trunc );
|
||||
if ( f.is_open() ) {
|
||||
f << "";
|
||||
m_data.shardIndex = bazelShardOptions->shardIndex;
|
||||
m_data.shardCount = bazelShardOptions->shardCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -140,6 +140,9 @@ namespace Catch {
|
||||
std::chrono::milliseconds benchmarkWarmupTime() const override;
|
||||
|
||||
private:
|
||||
// Reads Bazel env vars and applies them to the config
|
||||
void readBazelEnvVars();
|
||||
|
||||
ConfigData m_data;
|
||||
std::vector<ProcessedReporterSpec> m_processedReporterSpecs;
|
||||
TestSpec m_testSpec;
|
||||
|
18
src/catch2/catch_get_random_seed.cpp
Normal file
18
src/catch2/catch_get_random_seed.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#include <catch2/catch_get_random_seed.hpp>
|
||||
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/catch_config.hpp>
|
||||
|
||||
namespace Catch {
|
||||
std::uint32_t getSeed() {
|
||||
return getCurrentContext().getConfig()->rngSeed();
|
||||
}
|
||||
}
|
18
src/catch2/catch_get_random_seed.hpp
Normal file
18
src/catch2/catch_get_random_seed.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#ifndef CATCH_GET_RANDOM_SEED_HPP_INCLUDED
|
||||
#define CATCH_GET_RANDOM_SEED_HPP_INCLUDED
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Catch {
|
||||
//! Returns Catch2's current RNG seed.
|
||||
std::uint32_t getSeed();
|
||||
}
|
||||
|
||||
#endif // CATCH_GET_RANDOM_SEED_HPP_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -103,7 +103,7 @@ namespace Catch {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_INFO( macroName, log ) \
|
||||
Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log )
|
||||
const Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -61,7 +61,6 @@ namespace Catch {
|
||||
multi->addListener(listener->create(config));
|
||||
}
|
||||
|
||||
std::size_t reporterIdx = 0;
|
||||
for ( auto const& reporterSpec : config->getProcessedReporterSpecs() ) {
|
||||
multi->addReporter( createReporter(
|
||||
reporterSpec.name,
|
||||
@ -69,7 +68,6 @@ namespace Catch {
|
||||
makeStream( reporterSpec.outputFilename ),
|
||||
reporterSpec.colourMode,
|
||||
reporterSpec.customOptions ) ) );
|
||||
reporterIdx++;
|
||||
}
|
||||
|
||||
return multi;
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,17 +1,19 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/catch_test_spec.hpp>
|
||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -35,6 +37,10 @@ namespace Catch {
|
||||
return m_wildcardPattern.matches( testCase.name );
|
||||
}
|
||||
|
||||
void TestSpec::NamePattern::serializeTo( std::ostream& out ) const {
|
||||
out << '"' << name() << '"';
|
||||
}
|
||||
|
||||
|
||||
TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString )
|
||||
: Pattern( filterString )
|
||||
@ -47,6 +53,10 @@ namespace Catch {
|
||||
Tag( m_tag ) ) != end( testCase.tags );
|
||||
}
|
||||
|
||||
void TestSpec::TagPattern::serializeTo( std::ostream& out ) const {
|
||||
out << name();
|
||||
}
|
||||
|
||||
bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {
|
||||
bool should_use = !testCase.isHidden();
|
||||
for (auto const& pattern : m_required) {
|
||||
@ -63,18 +73,31 @@ namespace Catch {
|
||||
return should_use;
|
||||
}
|
||||
|
||||
std::string TestSpec::Filter::name() const {
|
||||
std::string name;
|
||||
for (auto const& p : m_required) {
|
||||
name += p->name();
|
||||
void TestSpec::Filter::serializeTo( std::ostream& out ) const {
|
||||
bool first = true;
|
||||
for ( auto const& pattern : m_required ) {
|
||||
if ( !first ) {
|
||||
out << ' ';
|
||||
}
|
||||
out << *pattern;
|
||||
first = false;
|
||||
}
|
||||
for (auto const& p : m_forbidden) {
|
||||
name += p->name();
|
||||
for ( auto const& pattern : m_forbidden ) {
|
||||
if ( !first ) {
|
||||
out << ' ';
|
||||
}
|
||||
out << *pattern;
|
||||
first = false;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
std::string TestSpec::extractFilterName( Filter const& filter ) {
|
||||
Catch::ReusableStringStream sstr;
|
||||
sstr << filter;
|
||||
return sstr.str();
|
||||
}
|
||||
|
||||
bool TestSpec::hasFilters() const {
|
||||
return !m_filters.empty();
|
||||
}
|
||||
@ -91,7 +114,7 @@ namespace Catch {
|
||||
for( auto const& test : testCases )
|
||||
if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) )
|
||||
currentMatches.emplace_back( &test );
|
||||
return FilterMatch{ filter.name(), currentMatches };
|
||||
return FilterMatch{ extractFilterName(filter), currentMatches };
|
||||
} );
|
||||
return matches;
|
||||
}
|
||||
@ -100,4 +123,15 @@ namespace Catch {
|
||||
return m_invalidSpecs;
|
||||
}
|
||||
|
||||
void TestSpec::serializeTo( std::ostream& out ) const {
|
||||
bool first = true;
|
||||
for ( auto const& filter : m_filters ) {
|
||||
if ( !first ) {
|
||||
out << ',';
|
||||
}
|
||||
out << filter;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -16,6 +16,7 @@
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
#include <catch2/internal/catch_wildcard_pattern.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -34,6 +35,14 @@ namespace Catch {
|
||||
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
||||
std::string const& name() const;
|
||||
private:
|
||||
virtual void serializeTo( std::ostream& out ) const = 0;
|
||||
// Writes string that would be reparsed into the pattern
|
||||
friend std::ostream& operator<<(std::ostream& out,
|
||||
Pattern const& pattern) {
|
||||
pattern.serializeTo( out );
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string const m_name;
|
||||
};
|
||||
|
||||
@ -42,6 +51,8 @@ namespace Catch {
|
||||
explicit NamePattern( std::string const& name, std::string const& filterString );
|
||||
bool matches( TestCaseInfo const& testCase ) const override;
|
||||
private:
|
||||
void serializeTo( std::ostream& out ) const override;
|
||||
|
||||
WildcardPattern m_wildcardPattern;
|
||||
};
|
||||
|
||||
@ -50,6 +61,8 @@ namespace Catch {
|
||||
explicit TagPattern( std::string const& tag, std::string const& filterString );
|
||||
bool matches( TestCaseInfo const& testCase ) const override;
|
||||
private:
|
||||
void serializeTo( std::ostream& out ) const override;
|
||||
|
||||
std::string m_tag;
|
||||
};
|
||||
|
||||
@ -57,10 +70,19 @@ namespace Catch {
|
||||
std::vector<Detail::unique_ptr<Pattern>> m_required;
|
||||
std::vector<Detail::unique_ptr<Pattern>> m_forbidden;
|
||||
|
||||
//! Serializes this filter into a string that would be parsed into
|
||||
//! an equivalent filter
|
||||
void serializeTo( std::ostream& out ) const;
|
||||
friend std::ostream& operator<<(std::ostream& out, Filter const& f) {
|
||||
f.serializeTo( out );
|
||||
return out;
|
||||
}
|
||||
|
||||
bool matches( TestCaseInfo const& testCase ) const;
|
||||
std::string name() const;
|
||||
};
|
||||
|
||||
static std::string extractFilterName( Filter const& filter );
|
||||
|
||||
public:
|
||||
struct FilterMatch {
|
||||
std::string name;
|
||||
@ -77,7 +99,16 @@ namespace Catch {
|
||||
private:
|
||||
std::vector<Filter> m_filters;
|
||||
std::vector<std::string> m_invalidSpecs;
|
||||
|
||||
friend class TestSpecParser;
|
||||
//! Serializes this test spec into a string that would be parsed into
|
||||
//! equivalent test spec
|
||||
void serializeTo( std::ostream& out ) const;
|
||||
friend std::ostream& operator<<(std::ostream& out,
|
||||
TestSpec const& spec) {
|
||||
spec.serializeTo( out );
|
||||
return out;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
@ -13,7 +13,6 @@
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_config_wchar.hpp>
|
||||
@ -41,6 +40,13 @@ namespace Catch {
|
||||
|
||||
namespace Detail {
|
||||
|
||||
inline std::size_t catch_strnlen(const char *str, std::size_t n) {
|
||||
auto ret = std::char_traits<char>::find(str, n, '\0');
|
||||
if (ret != nullptr) {
|
||||
return static_cast<std::size_t>(ret - str);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
constexpr StringRef unprintableString = "{?}"_sr;
|
||||
|
||||
@ -208,28 +214,24 @@ namespace Catch {
|
||||
template<size_t SZ>
|
||||
struct StringMaker<char[SZ]> {
|
||||
static std::string convert(char const* str) {
|
||||
// Note that `strnlen` is not actually part of standard C++,
|
||||
// but both POSIX and Windows cstdlib provide it.
|
||||
return Detail::convertIntoString(
|
||||
StringRef( str, strnlen( str, SZ ) ) );
|
||||
StringRef( str, Detail::catch_strnlen( str, SZ ) ) );
|
||||
}
|
||||
};
|
||||
template<size_t SZ>
|
||||
struct StringMaker<signed char[SZ]> {
|
||||
static std::string convert(signed char const* str) {
|
||||
// See the plain `char const*` overload
|
||||
auto reinterpreted = reinterpret_cast<char const*>(str);
|
||||
return Detail::convertIntoString(
|
||||
StringRef(reinterpreted, strnlen(reinterpreted, SZ)));
|
||||
StringRef(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ)));
|
||||
}
|
||||
};
|
||||
template<size_t SZ>
|
||||
struct StringMaker<unsigned char[SZ]> {
|
||||
static std::string convert(unsigned char const* str) {
|
||||
// See the plain `char const*` overload
|
||||
auto reinterpreted = reinterpret_cast<char const*>(str);
|
||||
return Detail::convertIntoString(
|
||||
StringRef(reinterpreted, strnlen(reinterpreted, SZ)));
|
||||
StringRef(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -296,13 +298,13 @@ namespace Catch {
|
||||
template<>
|
||||
struct StringMaker<float> {
|
||||
static std::string convert(float value);
|
||||
static int precision;
|
||||
CATCH_EXPORT static int precision;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct StringMaker<double> {
|
||||
static std::string convert(double value);
|
||||
static int precision;
|
||||
CATCH_EXPORT static int precision;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
// Copyright Catch2 Authors
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// (See accompanying file LICENSE.txt or copy at
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user