mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-16 18:15:42 +02:00
Compare commits
204 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6e79e682b7 | ||
![]() |
683c85772f | ||
![]() |
1b049bdba4 | ||
![]() |
e4b16053a6 | ||
![]() |
42ee66b5e6 | ||
![]() |
a0c6a28460 | ||
![]() |
c8363143e7 | ||
![]() |
7a52dfa77b | ||
![]() |
9131736630 | ||
![]() |
0631b607ee | ||
![]() |
dff7513b28 | ||
![]() |
bf5aa7b383 | ||
![]() |
dba9197ec7 | ||
![]() |
f60c15364b | ||
![]() |
b3cf1bfb5d | ||
![]() |
73b93ce6bc | ||
![]() |
8008625d7e | ||
![]() |
ce7b153021 | ||
![]() |
535205e2ac | ||
![]() |
689fdcd7dc | ||
![]() |
a153fce724 | ||
![]() |
06c0e1cfab | ||
![]() |
05d7eb5a00 | ||
![]() |
f53bb3ae7b | ||
![]() |
ce8a7b3390 | ||
![]() |
6dce539fad | ||
![]() |
5a40b2275c | ||
![]() |
598895d048 | ||
![]() |
0dc82e08df | ||
![]() |
8ca504cbc9 | ||
![]() |
c57b5cdf43 | ||
![]() |
d84777c9cb | ||
![]() |
51fdbedd13 | ||
![]() |
10f0a58643 | ||
![]() |
fe64c28925 | ||
![]() |
7d07efc92b | ||
![]() |
f3c678c0ab | ||
![]() |
46539b6d9b | ||
![]() |
10596b2278 | ||
![]() |
897fe2a01b | ||
![]() |
aad926baf8 | ||
![]() |
4e8399d835 | ||
![]() |
9a2a4eadc0 | ||
![]() |
fb806da76f | ||
![]() |
50bf00e266 | ||
![]() |
9f08097f55 | ||
![]() |
1f881ab464 | ||
![]() |
c487b27d9d | ||
![]() |
3230760db2 | ||
![]() |
b3ebce715e | ||
![]() |
d0f70fdfd6 | ||
![]() |
4f4ad8ada9 | ||
![]() |
5b665be643 | ||
![]() |
2598116aa6 | ||
![]() |
173aa3f1f4 | ||
![]() |
28437e1214 | ||
![]() |
3c8fb6bbb2 | ||
![]() |
72f3ce4db5 | ||
![]() |
62167d756e | ||
![]() |
6783411349 | ||
![]() |
7b4dd326c0 | ||
![]() |
1dfaa8abe7 | ||
![]() |
ba94278bdd | ||
![]() |
8e5a4b6f70 | ||
![]() |
9b884d8107 | ||
![]() |
8a1b3b81cb | ||
![]() |
e5aabb6714 | ||
![]() |
3a1ef14097 | ||
![]() |
13fae1e2ff | ||
![]() |
3220ae6d4a | ||
![]() |
0a0ebf5003 | ||
![]() |
69f35a5ac8 | ||
![]() |
3f0283de7a | ||
![]() |
6fbb3f0723 | ||
![]() |
9ff3cde87b | ||
![]() |
4d802ca58f | ||
![]() |
13711be7cf | ||
![]() |
27ba26f743 | ||
![]() |
a209bcfb54 | ||
![]() |
584973a485 | ||
![]() |
4f7c8cb28a | ||
![]() |
e1dbad4c9e | ||
![]() |
2befd98da2 | ||
![]() |
00f259aeb2 | ||
![]() |
fed1436246 | ||
![]() |
0477326ad9 | ||
![]() |
f04c93462b | ||
![]() |
1af351cea1 | ||
![]() |
dcc9fa3f38 | ||
![]() |
bf6a15a69a | ||
![]() |
6135a78c31 | ||
![]() |
e8ba329b6c | ||
![]() |
4aa88299af | ||
![]() |
4ff9be3bc5 | ||
![]() |
76cdaa3b51 | ||
![]() |
644294df60 | ||
![]() |
cefa8fcf32 | ||
![]() |
772fa3f790 | ||
![]() |
f3c0a3cd09 | ||
![]() |
42d9d4533e | ||
![]() |
618d44c448 | ||
![]() |
388f7e1737 | ||
![]() |
2ab20a0e00 | ||
![]() |
60264b8807 | ||
![]() |
65ffee5189 | ||
![]() |
43f02027e4 | ||
![]() |
906552f8c8 | ||
![]() |
356dfc1439 | ||
![]() |
e5d1eb757f | ||
![]() |
2403f5620e | ||
![]() |
d58491c85a | ||
![]() |
c837cb4a8a | ||
![]() |
8359a6b244 | ||
![]() |
adf43494e1 | ||
![]() |
efca9a0f18 | ||
![]() |
dd36f83b88 | ||
![]() |
baab9e8d28 | ||
![]() |
2d3c9713a3 | ||
![]() |
956f915e31 | ||
![]() |
aa8da505ec | ||
![]() |
e27bb7198d | ||
![]() |
3486f8ed9e | ||
![]() |
b5be642042 | ||
![]() |
d59572f46f | ||
![]() |
16f48f8c7c | ||
![]() |
367c2cb248 | ||
![]() |
d548be26e3 | ||
![]() |
52066dbc2a | ||
![]() |
cdf604f30e | ||
![]() |
04382af4c6 | ||
![]() |
ac93f19437 | ||
![]() |
72b60dfd28 | ||
![]() |
0c62167fea | ||
![]() |
1be954ff70 | ||
![]() |
78bb4fda05 | ||
![]() |
e6ec1c238b | ||
![]() |
477c1f5152 | ||
![]() |
f8b9f77259 | ||
![]() |
77fbacb03f | ||
![]() |
e3fc97dffb | ||
![]() |
9c0533a905 | ||
![]() |
ed02710b83 | ||
![]() |
8b84438be4 | ||
![]() |
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 |
@@ -1,25 +1,45 @@
|
|||||||
---
|
---
|
||||||
AccessModifierOffset: '-4'
|
|
||||||
AlignEscapedNewlines: Left
|
|
||||||
AllowAllConstructorInitializersOnNextLine: 'true'
|
|
||||||
BinPackArguments: 'false'
|
|
||||||
BinPackParameters: 'false'
|
|
||||||
BreakConstructorInitializers: AfterColon
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
|
|
||||||
DerivePointerAlignment: 'false'
|
|
||||||
FixNamespaceComments: 'true'
|
|
||||||
IncludeBlocks: Regroup
|
|
||||||
IndentCaseLabels: 'false'
|
|
||||||
IndentPPDirectives: AfterHash
|
|
||||||
IndentWidth: '4'
|
|
||||||
Language: Cpp
|
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"
|
||||||
|
BinPackArguments: "false"
|
||||||
|
BinPackParameters: "false"
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: "true"
|
||||||
|
DerivePointerAlignment: "false"
|
||||||
|
FixNamespaceComments: "true"
|
||||||
|
IndentCaseLabels: "false"
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWidth: "4"
|
||||||
NamespaceIndentation: All
|
NamespaceIndentation: All
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
SpaceBeforeCtorInitializerColon: 'false'
|
SpaceBeforeCtorInitializerColon: "false"
|
||||||
SpaceInEmptyParentheses: 'false'
|
SpaceInEmptyParentheses: "false"
|
||||||
SpacesInParentheses: 'true'
|
SpacesInParentheses: "true"
|
||||||
Standard: Cpp11
|
TabWidth: "4"
|
||||||
TabWidth: '4'
|
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
...
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
ReflowComments: true
|
||||||
|
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}} //...
|
2
.github/workflows/linux-meson-builds.yml
vendored
2
.github/workflows/linux-meson-builds.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Linux builds (basic) using meson build system
|
name: Linux builds (meson)
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
9
.github/workflows/linux-other-builds.yml
vendored
9
.github/workflows/linux-other-builds.yml
vendored
@@ -29,13 +29,13 @@ jobs:
|
|||||||
build_type: Debug
|
build_type: Debug
|
||||||
std: 14
|
std: 14
|
||||||
other_pkgs: g++-7
|
other_pkgs: g++-7
|
||||||
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON
|
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON
|
||||||
- cxx: g++-7
|
- cxx: g++-7
|
||||||
build_description: Extras + Examples
|
build_description: Extras + Examples
|
||||||
build_type: Release
|
build_type: Release
|
||||||
std: 14
|
std: 14
|
||||||
other_pkgs: g++-7
|
other_pkgs: g++-7
|
||||||
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON
|
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON
|
||||||
|
|
||||||
# Extras and examples with Clang-10
|
# Extras and examples with Clang-10
|
||||||
- cxx: clang++-10
|
- cxx: clang++-10
|
||||||
@@ -43,13 +43,13 @@ jobs:
|
|||||||
build_type: Debug
|
build_type: Debug
|
||||||
std: 17
|
std: 17
|
||||||
other_pkgs: clang-10
|
other_pkgs: clang-10
|
||||||
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON
|
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON
|
||||||
- cxx: clang++-10
|
- cxx: clang++-10
|
||||||
build_description: Extras + Examples
|
build_description: Extras + Examples
|
||||||
build_type: Release
|
build_type: Release
|
||||||
std: 17
|
std: 17
|
||||||
other_pkgs: clang-10
|
other_pkgs: clang-10
|
||||||
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON
|
cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON
|
||||||
|
|
||||||
# Configure tests with Clang-10
|
# Configure tests with Clang-10
|
||||||
- cxx: clang++-10
|
- cxx: clang++-10
|
||||||
@@ -86,6 +86,7 @@ jobs:
|
|||||||
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
||||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
-DCMAKE_CXX_EXTENSIONS=OFF \
|
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||||
-DCATCH_DEVELOPMENT_BUILD=ON \
|
-DCATCH_DEVELOPMENT_BUILD=ON \
|
||||||
${{matrix.cmake_configurations}} \
|
${{matrix.cmake_configurations}} \
|
||||||
|
17
.github/workflows/linux-simple-builds.yml
vendored
17
.github/workflows/linux-simple-builds.yml
vendored
@@ -65,6 +65,22 @@ jobs:
|
|||||||
build_type: Release
|
build_type: Release
|
||||||
std: 17
|
std: 17
|
||||||
other_pkgs: clang-10
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -89,6 +105,7 @@ jobs:
|
|||||||
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
||||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
-DCMAKE_CXX_EXTENSIONS=OFF \
|
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||||
-DCATCH_DEVELOPMENT_BUILD=ON \
|
-DCATCH_DEVELOPMENT_BUILD=ON \
|
||||||
-G Ninja
|
-G Ninja
|
||||||
|
7
.github/workflows/mac-builds.yml
vendored
7
.github/workflows/mac-builds.yml
vendored
@@ -33,8 +33,11 @@ jobs:
|
|||||||
# This is important
|
# This is important
|
||||||
run: |
|
run: |
|
||||||
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
cmake -Bbuild -H$GITHUB_WORKSPACE \
|
||||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
-DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \
|
-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}}
|
-DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}}
|
||||||
|
|
||||||
- name: Build tests + lib
|
- name: Build tests + lib
|
||||||
|
37
.github/workflows/windows-simple-builds.yml
vendored
Normal file
37
.github/workflows/windows-simple-builds.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Windows builds (basic)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}}
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [windows-2019, windows-2022]
|
||||||
|
platform: [Win32, x64]
|
||||||
|
build_type: [Debug, Release]
|
||||||
|
std: [14, 17]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure build
|
||||||
|
working-directory: ${{runner.workspace}}
|
||||||
|
run: |
|
||||||
|
cmake -S $Env:GITHUB_WORKSPACE `
|
||||||
|
-B ${{runner.workspace}}/build `
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
|
||||||
|
-A ${{matrix.platform}} `
|
||||||
|
--preset all-tests
|
||||||
|
|
||||||
|
- name: Build tests
|
||||||
|
working-directory: ${{runner.workspace}}
|
||||||
|
run: cmake --build build --config ${{matrix.build_type}} --parallel %NUMBER_OF_PROCESSORS%
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
working-directory: ${{runner.workspace}}/build
|
||||||
|
env:
|
||||||
|
CTEST_OUTPUT_ON_FAILURE: 1
|
||||||
|
run: ctest -C ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS%
|
||||||
|
shell: cmd
|
@@ -28,6 +28,7 @@ expand_template(
|
|||||||
"#cmakedefine CATCH_CONFIG_EXPERIMENTAL_REDIRECT": "",
|
"#cmakedefine CATCH_CONFIG_EXPERIMENTAL_REDIRECT": "",
|
||||||
"#cmakedefine CATCH_CONFIG_FALLBACK_STRINGIFIER @CATCH_CONFIG_FALLBACK_STRINGIFIER@": "",
|
"#cmakedefine CATCH_CONFIG_FALLBACK_STRINGIFIER @CATCH_CONFIG_FALLBACK_STRINGIFIER@": "",
|
||||||
"#cmakedefine CATCH_CONFIG_FAST_COMPILE": "",
|
"#cmakedefine CATCH_CONFIG_FAST_COMPILE": "",
|
||||||
|
"#cmakedefine CATCH_CONFIG_GETENV": "",
|
||||||
"#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER": "",
|
"#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "",
|
"#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "",
|
"#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "",
|
||||||
@@ -38,15 +39,18 @@ expand_template(
|
|||||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW": "",
|
"#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS": "",
|
"#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT": "",
|
"#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT": "",
|
||||||
|
"#cmakedefine CATCH_CONFIG_NO_GETENV": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "",
|
"#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "",
|
"#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "",
|
"#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "",
|
||||||
|
"#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_WCHAR": "",
|
"#cmakedefine CATCH_CONFIG_NO_WCHAR": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NO_WINDOWS_SEH": "",
|
"#cmakedefine CATCH_CONFIG_NO_WINDOWS_SEH": "",
|
||||||
"#cmakedefine CATCH_CONFIG_NOSTDOUT": "",
|
"#cmakedefine CATCH_CONFIG_NOSTDOUT": "",
|
||||||
"#cmakedefine CATCH_CONFIG_POSIX_SIGNALS": "",
|
"#cmakedefine CATCH_CONFIG_POSIX_SIGNALS": "",
|
||||||
"#cmakedefine CATCH_CONFIG_PREFIX_ALL": "",
|
"#cmakedefine CATCH_CONFIG_PREFIX_ALL": "",
|
||||||
"#cmakedefine CATCH_CONFIG_SHARED_LIBRARY": "",
|
"#cmakedefine CATCH_CONFIG_SHARED_LIBRARY": "",
|
||||||
|
"#cmakedefine CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "",
|
||||||
"#cmakedefine CATCH_CONFIG_USE_ASYNC": "",
|
"#cmakedefine CATCH_CONFIG_USE_ASYNC": "",
|
||||||
"#cmakedefine CATCH_CONFIG_WCHAR": "",
|
"#cmakedefine CATCH_CONFIG_WCHAR": "",
|
||||||
"#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG": "",
|
"#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG": "",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# Copyright Catch2 Authors
|
# Copyright Catch2 Authors
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
# SPDX-License-Identifier: BSL-1.0
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -40,6 +40,8 @@ set(_OverridableOptions
|
|||||||
"USE_ASYNC"
|
"USE_ASYNC"
|
||||||
"WCHAR"
|
"WCHAR"
|
||||||
"WINDOWS_SEH"
|
"WINDOWS_SEH"
|
||||||
|
"GETENV"
|
||||||
|
"EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT"
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(OptionName ${_OverridableOptions})
|
foreach(OptionName ${_OverridableOptions})
|
||||||
@@ -67,7 +69,11 @@ set(_OtherConfigOptions
|
|||||||
foreach(OptionName ${_OtherConfigOptions})
|
foreach(OptionName ${_OtherConfigOptions})
|
||||||
AddConfigOption(${OptionName})
|
AddConfigOption(${OptionName})
|
||||||
endforeach()
|
endforeach()
|
||||||
set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
if(DEFINED BUILD_SHARED_LIBS)
|
||||||
|
set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||||
|
else()
|
||||||
|
set(CATCH_CONFIG_SHARED_LIBRARY "")
|
||||||
|
endif()
|
||||||
|
|
||||||
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_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.")
|
set(CATCH_CONFIG_CONSOLE_WIDTH "80" CACHE STRING "Read docs/configuration.md for details. Must form a valid integer literal.")
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# Copyright Catch2 Authors
|
# Copyright Catch2 Authors
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
# SPDX-License-Identifier: BSL-1.0
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -13,7 +13,7 @@ function(add_cxx_flag_if_supported_to_targets flagname targets)
|
|||||||
|
|
||||||
if (HAVE_FLAG_${flag_identifier})
|
if (HAVE_FLAG_${flag_identifier})
|
||||||
foreach(target ${targets})
|
foreach(target ${targets})
|
||||||
target_compile_options(${target} PUBLIC ${flagname})
|
target_compile_options(${target} PRIVATE ${flagname})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
@@ -74,6 +74,7 @@ function(add_warnings_to_targets targets)
|
|||||||
"-Woverloaded-virtual"
|
"-Woverloaded-virtual"
|
||||||
"-Wparentheses"
|
"-Wparentheses"
|
||||||
"-Wpedantic"
|
"-Wpedantic"
|
||||||
|
"-Wredundant-decls"
|
||||||
"-Wreorder"
|
"-Wreorder"
|
||||||
"-Wreturn-std-move"
|
"-Wreturn-std-move"
|
||||||
"-Wshadow"
|
"-Wshadow"
|
||||||
@@ -83,7 +84,7 @@ function(add_warnings_to_targets targets)
|
|||||||
"-Wundef"
|
"-Wundef"
|
||||||
"-Wuninitialized"
|
"-Wuninitialized"
|
||||||
"-Wunneeded-internal-declaration"
|
"-Wunneeded-internal-declaration"
|
||||||
"-Wunreachable-code"
|
"-Wunreachable-code-aggressive"
|
||||||
"-Wunused"
|
"-Wunused"
|
||||||
"-Wunused-function"
|
"-Wunused-function"
|
||||||
"-Wunused-parameter"
|
"-Wunused-parameter"
|
||||||
|
@@ -21,6 +21,7 @@ cmake_dependent_option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io"
|
|||||||
cmake_dependent_option(CATCH_ENABLE_WERROR "Enables Werror during build" ON "CATCH_DEVELOPMENT_BUILD" OFF)
|
cmake_dependent_option(CATCH_ENABLE_WERROR "Enables Werror during build" ON "CATCH_DEVELOPMENT_BUILD" OFF)
|
||||||
cmake_dependent_option(CATCH_BUILD_SURROGATES "Enable generating and building surrogate TUs for the main headers" OFF "CATCH_DEVELOPMENT_BUILD" OFF)
|
cmake_dependent_option(CATCH_BUILD_SURROGATES "Enable generating and building surrogate TUs for the main headers" OFF "CATCH_DEVELOPMENT_BUILD" OFF)
|
||||||
cmake_dependent_option(CATCH_ENABLE_CONFIGURE_TESTS "Enable CMake configuration tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF)
|
cmake_dependent_option(CATCH_ENABLE_CONFIGURE_TESTS "Enable CMake configuration tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF)
|
||||||
|
cmake_dependent_option(CATCH_ENABLE_CMAKE_HELPER_TESTS "Enable CMake helper tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF)
|
||||||
|
|
||||||
|
|
||||||
# Catch2's build breaks if done in-tree. You probably should not build
|
# Catch2's build breaks if done in-tree. You probably should not build
|
||||||
@@ -31,7 +32,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(Catch2
|
project(Catch2
|
||||||
VERSION 3.1.1 # CML version placeholder, don't delete
|
VERSION 3.4.0 # CML version placeholder, don't delete
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
# HOMEPAGE_URL is not supported until CMake version 3.12, which
|
# HOMEPAGE_URL is not supported until CMake version 3.12, which
|
||||||
# we do not target yet.
|
# we do not target yet.
|
||||||
@@ -148,6 +149,8 @@ if (NOT_SUBPROJECT)
|
|||||||
"extras/ParseAndAddCatchTests.cmake"
|
"extras/ParseAndAddCatchTests.cmake"
|
||||||
"extras/Catch.cmake"
|
"extras/Catch.cmake"
|
||||||
"extras/CatchAddTests.cmake"
|
"extras/CatchAddTests.cmake"
|
||||||
|
"extras/CatchShardTests.cmake"
|
||||||
|
"extras/CatchShardTestsImpl.cmake"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
@@ -18,7 +18,8 @@
|
|||||||
"CATCH_BUILD_EXAMPLES": "ON",
|
"CATCH_BUILD_EXAMPLES": "ON",
|
||||||
"CATCH_BUILD_EXTRA_TESTS": "ON",
|
"CATCH_BUILD_EXTRA_TESTS": "ON",
|
||||||
"CATCH_BUILD_SURROGATES": "ON",
|
"CATCH_BUILD_SURROGATES": "ON",
|
||||||
"CATCH_ENABLE_CONFIGURE_TESTS": "ON"
|
"CATCH_ENABLE_CONFIGURE_TESTS": "ON",
|
||||||
|
"CATCH_ENABLE_CMAKE_HELPER_TESTS": "ON"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
2
Doxyfile
2
Doxyfile
@@ -1319,7 +1319,7 @@ CHM_FILE =
|
|||||||
HHC_LOCATION =
|
HHC_LOCATION =
|
||||||
|
|
||||||
# The GENERATE_CHI flag controls if a separate .chi index file is generated
|
# The GENERATE_CHI flag controls if a separate .chi index file is generated
|
||||||
# (YES) or that it should be included in the master .chm file (NO).
|
# (YES) or that it should be included in the main .chm file (NO).
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
|
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
|
||||||
|
|
||||||
|
73
README.md
73
README.md
@@ -1,5 +1,5 @@
|
|||||||
<a id="top"></a>
|
<a id="top"></a>
|
||||||

|

|
||||||
|
|
||||||
[](https://github.com/catchorg/catch2/releases)
|
[](https://github.com/catchorg/catch2/releases)
|
||||||
[](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml)
|
[](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml)
|
||||||
@@ -11,31 +11,82 @@
|
|||||||
[](https://discord.gg/4CWS9zD)
|
[](https://discord.gg/4CWS9zD)
|
||||||
|
|
||||||
|
|
||||||
## What's the Catch2?
|
## What is Catch2?
|
||||||
|
|
||||||
Catch2 is mainly a unit testing framework for C++, but it also
|
Catch2 is mainly a unit testing framework for C++, but it also
|
||||||
provides basic micro-benchmarking features, and simple BDD macros.
|
provides basic micro-benchmarking features, and simple BDD macros.
|
||||||
|
|
||||||
Catch2's main advantage is that using it is both simple and natural.
|
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
|
Test names do not have to be valid identifiers, assertions look like
|
||||||
identifiers, assertions look like normal C++ code, and sections provide
|
normal C++ boolean expressions, and sections provide a nice and local way
|
||||||
a nice way to share set-up and tear-down code in tests.
|
to share set-up and tear-down code in tests.
|
||||||
|
|
||||||
|
**Example unit test**
|
||||||
|
```cpp
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
uint32_t factorial( uint32_t number ) {
|
||||||
|
return number <= 1 ? number : factorial(number-1) * number;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ? number : 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);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
_Note that benchmarks are not run by default, so you need to run it explicitly
|
||||||
|
with the `[!benchmark]` tag._
|
||||||
|
|
||||||
|
|
||||||
## Catch2 v3 is being developed!
|
## Catch2 v3 has been released!
|
||||||
|
|
||||||
You are on the `devel` branch, where the next major version, v3, of
|
You are on the `devel` branch, where the v3 version is being developed.
|
||||||
Catch2 is being developed. As it is a significant rework, you will
|
v3 brings a bunch of significant changes, the big one being that Catch2
|
||||||
find that parts of this documentation are likely still stuck on v2.
|
is no longer a single-header library. Catch2 now behaves as a normal
|
||||||
|
library, with multiple headers and separately compiled implementation.
|
||||||
|
|
||||||
For stable (and documentation-matching) version of Catch2, [go to the
|
The documentation is slowly being updated to take these changes into
|
||||||
`v2.x` branch](https://github.com/catchorg/Catch2/tree/v2.x).
|
account, but this work is currently still ongoing.
|
||||||
|
|
||||||
For migrating from the v2 releases to v3, you should look at [our
|
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
|
documentation](docs/migrate-v2-to-v3.md#top). It provides a simple
|
||||||
guidelines on getting started, and collects most common migration
|
guidelines on getting started, and collects most common migration
|
||||||
problems.
|
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
|
## How to use it
|
||||||
This documentation comprises these three parts:
|
This documentation comprises these three parts:
|
||||||
|
@@ -4,12 +4,13 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "bazel_skylib",
|
name = "bazel_skylib",
|
||||||
|
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
|
||||||
urls = [
|
urls = [
|
||||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
|
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
|
||||||
"https://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.4.2/bazel-skylib-1.4.2.tar.gz",
|
||||||
],
|
],
|
||||||
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||||
|
|
||||||
bazel_skylib_workspace()
|
bazel_skylib_workspace()
|
||||||
|
48
appveyor.yml
48
appveyor.yml
@@ -51,18 +51,6 @@ test_script:
|
|||||||
# build explicitly.
|
# build explicitly.
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- FLAVOR: VS 2019 x64 Debug Surrogates Configure Tests
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
|
||||||
surrogates: 1
|
|
||||||
configure_tests: 1
|
|
||||||
platform: x64
|
|
||||||
configuration: Debug
|
|
||||||
|
|
||||||
- FLAVOR: VS 2019 x64 Release
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
|
||||||
platform: x64
|
|
||||||
configuration: Release
|
|
||||||
|
|
||||||
- FLAVOR: VS 2019 x64 Debug Coverage Examples
|
- FLAVOR: VS 2019 x64 Debug Coverage Examples
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
examples: 1
|
examples: 1
|
||||||
@@ -77,11 +65,6 @@ environment:
|
|||||||
platform: x64
|
platform: x64
|
||||||
configuration: Debug
|
configuration: Debug
|
||||||
|
|
||||||
- FLAVOR: VS 2019 Win32 Debug
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
|
||||||
platform: Win32
|
|
||||||
configuration: Debug
|
|
||||||
|
|
||||||
- FLAVOR: VS 2019 x64 Debug Latest Strict
|
- FLAVOR: VS 2019 x64 Debug Latest Strict
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
additional_flags: "/permissive- /std:c++latest"
|
additional_flags: "/permissive- /std:c++latest"
|
||||||
@@ -92,38 +75,9 @@ environment:
|
|||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
platform: x64
|
platform: x64
|
||||||
configuration: Debug
|
configuration: Debug
|
||||||
|
|
||||||
- FLAVOR: VS 2017 x64 Release
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
platform: x64
|
|
||||||
configuration: Release
|
|
||||||
|
|
||||||
- FLAVOR: VS 2017 x64 Release Coverage
|
- FLAVOR: VS 2017 x64 Release Coverage
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
coverage: 1
|
coverage: 1
|
||||||
platform: x64
|
platform: x64
|
||||||
configuration: Debug
|
configuration: Debug
|
||||||
|
|
||||||
- FLAVOR: VS 2017 Win32 Debug
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
platform: Win32
|
|
||||||
configuration: Debug
|
|
||||||
|
|
||||||
- FLAVOR: VS 2017 Win32 Debug Examples
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
examples: 1
|
|
||||||
platform: Win32
|
|
||||||
configuration: Debug
|
|
||||||
|
|
||||||
- FLAVOR: VS 2017 Win32 Debug WMain
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
wmain: 1
|
|
||||||
additional_flags: "/D_UNICODE /DUNICODE"
|
|
||||||
platform: Win32
|
|
||||||
configuration: Debug
|
|
||||||
|
|
||||||
- FLAVOR: VS 2017 x64 Debug Latest Strict
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
additional_flags: "/permissive- /std:c++latest"
|
|
||||||
platform: x64
|
|
||||||
configuration: Debug
|
|
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 |
@@ -11,6 +11,7 @@ Once you're up and running consider the following reference material.
|
|||||||
* [Logging macros](logging.md#top)
|
* [Logging macros](logging.md#top)
|
||||||
* [Test cases and sections](test-cases-and-sections.md#top)
|
* [Test cases and sections](test-cases-and-sections.md#top)
|
||||||
* [Test fixtures](test-fixtures.md#top)
|
* [Test fixtures](test-fixtures.md#top)
|
||||||
|
* [Explicitly skipping, passing, and failing tests at runtime](skipping-passing-failing.md#top)
|
||||||
* [Reporters (output customization)](reporters.md#top)
|
* [Reporters (output customization)](reporters.md#top)
|
||||||
* [Event Listeners](event-listeners.md#top)
|
* [Event Listeners](event-listeners.md#top)
|
||||||
* [Data Generators (value parameterized tests)](generators.md#top)
|
* [Data Generators (value parameterized tests)](generators.md#top)
|
||||||
@@ -29,7 +30,7 @@ Once you're up and running consider the following reference material.
|
|||||||
* [Frequently Asked Questions (FAQ)](faq.md#top)
|
* [Frequently Asked Questions (FAQ)](faq.md#top)
|
||||||
* [Best practices and other tips](usage-tips.md#top)
|
* [Best practices and other tips](usage-tips.md#top)
|
||||||
* [CMake integration](cmake-integration.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)
|
* [Known limitations](limitations.md#top)
|
||||||
|
|
||||||
**Other:**
|
**Other:**
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
<a id="top"></a>
|
<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>
|
||||||
|
[Bazel test runner integration](#bazel-test-runner-integration)<br>
|
||||||
|
[Low-level tools](#low-level-tools)<br>
|
||||||
|
[CMake](#cmake)<br>
|
||||||
|
|
||||||
|
This page talks about Catch2's integration with other related tooling,
|
||||||
|
like Continuous Integration and 3rd party test runners.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Continuous Integration systems
|
## Continuous Integration systems
|
||||||
|
|
||||||
@@ -51,6 +58,26 @@ Because of the incremental nature of Catch's test suites and ability to run spec
|
|||||||
[SonarQube Generic Test Data](https://docs.sonarqube.org/latest/analysis/generic-test/) XML format for tests metrics.
|
[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
|
## Low-level tools
|
||||||
|
|
||||||
### CodeCoverage module (GCOV, LCOV...)
|
### CodeCoverage module (GCOV, LCOV...)
|
||||||
|
@@ -90,12 +90,12 @@ cmake_minimum_required(VERSION 3.5)
|
|||||||
project(baz LANGUAGES CXX VERSION 0.0.1)
|
project(baz LANGUAGES CXX VERSION 0.0.1)
|
||||||
|
|
||||||
find_package(Catch2 REQUIRED)
|
find_package(Catch2 REQUIRED)
|
||||||
add_executable(foo test.cpp)
|
add_executable(tests test.cpp)
|
||||||
target_link_libraries(foo PRIVATE Catch2::Catch2)
|
target_link_libraries(tests PRIVATE Catch2::Catch2)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(Catch)
|
include(Catch)
|
||||||
catch_discover_tests(foo)
|
catch_discover_tests(tests)
|
||||||
```
|
```
|
||||||
|
|
||||||
When using `FetchContent`, `include(Catch)` will fail unless
|
When using `FetchContent`, `include(Catch)` will fail unless
|
||||||
@@ -108,7 +108,7 @@ directory.
|
|||||||
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(Catch)
|
include(Catch)
|
||||||
catch_discover_tests()
|
catch_discover_tests(tests)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Customization
|
#### Customization
|
||||||
@@ -126,6 +126,7 @@ catch_discover_tests(target
|
|||||||
[OUTPUT_DIR dir]
|
[OUTPUT_DIR dir]
|
||||||
[OUTPUT_PREFIX prefix]
|
[OUTPUT_PREFIX prefix]
|
||||||
[OUTPUT_SUFFIX suffix]
|
[OUTPUT_SUFFIX suffix]
|
||||||
|
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -198,6 +199,16 @@ If specified, `suffix` is added to each output file name, like so
|
|||||||
`--out dir/<test_name>suffix`. This can be used to add a file extension to
|
`--out dir/<test_name>suffix`. This can be used to add a file extension to
|
||||||
the output file name e.g. ".xml".
|
the output file name e.g. ".xml".
|
||||||
|
|
||||||
|
* `DISCOVERY_MODE mode`
|
||||||
|
|
||||||
|
If specified allows control over when test discovery is performed.
|
||||||
|
For a value of `POST_BUILD` (default) test discovery is performed at build time.
|
||||||
|
For a a value of `PRE_TEST` test discovery is delayed until just prior to test
|
||||||
|
execution (useful e.g. in cross-compilation environments).
|
||||||
|
``DISCOVERY_MODE`` defaults to the value of the
|
||||||
|
``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when
|
||||||
|
calling ``catch_discover_tests``. This provides a mechanism for globally
|
||||||
|
selecting a preferred test discovery behavior.
|
||||||
|
|
||||||
### `ParseAndAddCatchTests.cmake`
|
### `ParseAndAddCatchTests.cmake`
|
||||||
|
|
||||||
@@ -222,12 +233,12 @@ cmake_minimum_required(VERSION 3.5)
|
|||||||
project(baz LANGUAGES CXX VERSION 0.0.1)
|
project(baz LANGUAGES CXX VERSION 0.0.1)
|
||||||
|
|
||||||
find_package(Catch2 REQUIRED)
|
find_package(Catch2 REQUIRED)
|
||||||
add_executable(foo test.cpp)
|
add_executable(tests test.cpp)
|
||||||
target_link_libraries(foo PRIVATE Catch2::Catch2)
|
target_link_libraries(tests PRIVATE Catch2::Catch2)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(ParseAndAddCatchTests)
|
include(ParseAndAddCatchTests)
|
||||||
ParseAndAddCatchTests(foo)
|
ParseAndAddCatchTests(tests)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@@ -148,7 +148,7 @@ validity, and throw an error if they are wrong._
|
|||||||
> Support for passing arguments to reporters through the `-r`, `--reporter` flag was introduced in Catch2 3.0.1
|
> Support for passing arguments to reporters through the `-r`, `--reporter` flag was introduced in Catch2 3.0.1
|
||||||
|
|
||||||
There are multiple built-in reporters, you can see what they do by using the
|
There are multiple built-in reporters, you can see what they do by using the
|
||||||
[`--list-reporter`](command-line.md#listing-available-tests-tags-or-reporters)
|
[`--list-reporters`](command-line.md#listing-available-tests-tags-or-reporters)
|
||||||
flag. If you need a reporter providing custom format outside of the already
|
flag. If you need a reporter providing custom format outside of the already
|
||||||
provided ones, look at the ["write your own reporter" part of the reporter
|
provided ones, look at the ["write your own reporter" part of the reporter
|
||||||
documentation](reporters.md#writing-your-own-reporter).
|
documentation](reporters.md#writing-your-own-reporter).
|
||||||
@@ -507,10 +507,13 @@ start of the first section.</br>
|
|||||||
## Filenames as tags
|
## Filenames as tags
|
||||||
<pre>-#, --filenames-as-tags</pre>
|
<pre>-#, --filenames-as-tags</pre>
|
||||||
|
|
||||||
When this option is used then every test is given an additional tag which is formed of the unqualified
|
This option adds an extra tag to all test cases. The tag is `#` followed
|
||||||
filename it is found in, with any extension stripped, prefixed with the `#` character.
|
by the unqualified filename the test case is defined in, with the _last_
|
||||||
|
extension stripped out.
|
||||||
|
|
||||||
|
For example, tests within the file `tests\SelfTest\UsageTests\BDD.tests.cpp`
|
||||||
|
will be given the `[#BDD.tests]` tag.
|
||||||
|
|
||||||
So, for example, tests within the file `~\Dev\MyProject\Ferrets.cpp` would be tagged `[#Ferrets]`.
|
|
||||||
|
|
||||||
<a id="colour-mode"></a>
|
<a id="colour-mode"></a>
|
||||||
## Override output colouring
|
## Override output colouring
|
||||||
@@ -561,10 +564,10 @@ processes, as is done with the [Bazel test sharding](https://docs.bazel.build/ve
|
|||||||
|
|
||||||
> Introduced in Catch2 3.0.1.
|
> Introduced in Catch2 3.0.1.
|
||||||
|
|
||||||
By default, Catch2 test binaries return non-0 exit code if no tests were
|
By default, Catch2 test binaries return non-0 exit code if no tests were run,
|
||||||
run, e.g. if the binary was compiled with no tests, or the provided test
|
e.g. if the binary was compiled with no tests, the provided test spec matched no
|
||||||
spec matched no tests. This flag overrides that, so a test run with no
|
tests, or all tests [were skipped at runtime](skipping-passing-failing.md#top). This flag
|
||||||
tests still returns 0.
|
overrides that, so a test run with no tests still returns 0.
|
||||||
|
|
||||||
## Output verbosity
|
## Output verbosity
|
||||||
```
|
```
|
||||||
|
@@ -16,7 +16,7 @@ this blog post](https://codingnest.com/the-little-things-comparing-floating-poin
|
|||||||
## Floating point matchers
|
## Floating point matchers
|
||||||
|
|
||||||
```
|
```
|
||||||
#include <catch2/matchers/catch_matchers_floating.hpp
|
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||||
```
|
```
|
||||||
|
|
||||||
[Matchers](matchers.md#top) are the preferred way of comparing floating
|
[Matchers](matchers.md#top) are the preferred way of comparing floating
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
[Enabling stringification](#enabling-stringification)<br>
|
[Enabling stringification](#enabling-stringification)<br>
|
||||||
[Disabling exceptions](#disabling-exceptions)<br>
|
[Disabling exceptions](#disabling-exceptions)<br>
|
||||||
[Overriding Catch's debug break (`-b`)](#overriding-catchs-debug-break--b)<br>
|
[Overriding Catch's debug break (`-b`)](#overriding-catchs-debug-break--b)<br>
|
||||||
|
[Static analysis support](#static-analysis-support)<br>
|
||||||
|
|
||||||
Catch2 is designed to "just work" as much as possible, and most of the
|
Catch2 is designed to "just work" as much as possible, and most of the
|
||||||
configuration options below are changed automatically during compilation,
|
configuration options below are changed automatically during compilation,
|
||||||
@@ -98,13 +99,19 @@ is equivalent with the out-of-the-box experience.
|
|||||||
|
|
||||||
|
|
||||||
## Bazel support
|
## 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 [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.
|
> `CATCH_CONFIG_BAZEL_SUPPORT` was [deprecated](https://github.com/catchorg/Catch2/pull/2459) in Catch2 3.1.0.
|
||||||
|
|
||||||
|
|
||||||
## C++11 toggles
|
## C++11 toggles
|
||||||
|
|
||||||
CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string`
|
CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string`
|
||||||
@@ -149,13 +156,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_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
|
||||||
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
|
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_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_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.
|
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_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
|
`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
|
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
|
finish running. This option only works when linking against the default
|
||||||
@@ -251,6 +265,31 @@ The macro will be used as is, that is, `CATCH_BREAK_INTO_DEBUGGER();`
|
|||||||
must compile and must break into debugger.
|
must compile and must break into debugger.
|
||||||
|
|
||||||
|
|
||||||
|
## Static analysis support
|
||||||
|
|
||||||
|
> Introduced in Catch2 3.4.0.
|
||||||
|
|
||||||
|
Some parts of Catch2, e.g. `SECTION`s, can be hard for static analysis
|
||||||
|
tools to reason about. Catch2 can change its internals to help static
|
||||||
|
analysis tools reason about the tests.
|
||||||
|
|
||||||
|
Catch2 automatically detects some static analysis tools (initial
|
||||||
|
implementation checks for clang-tidy and Coverity), but you can override
|
||||||
|
its detection (in either direction) via
|
||||||
|
|
||||||
|
```
|
||||||
|
CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT // force enables static analysis help
|
||||||
|
CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT // force disables static analysis help
|
||||||
|
```
|
||||||
|
|
||||||
|
_As the name suggests, this is currently experimental, and thus we provide
|
||||||
|
no backwards compatibility guarantees._
|
||||||
|
|
||||||
|
**DO NOT ENABLE THIS FOR BUILDS YOU INTEND TO RUN.** The changed internals
|
||||||
|
are not meant to be runnable, only "scannable".
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Home](Readme.md#top)
|
[Home](Readme.md#top)
|
||||||
|
@@ -55,6 +55,15 @@ tests from `SelfTest` through a specific reporter and then compare the
|
|||||||
generated output with a known good output ("Baseline"). By default, new
|
generated output with a known good output ("Baseline"). By default, new
|
||||||
tests should be placed here.
|
tests should be placed here.
|
||||||
|
|
||||||
|
To configure a Catch2 build with just the basic tests, use the `basic-tests`
|
||||||
|
preset, like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Assuming you are in Catch2's root folder
|
||||||
|
|
||||||
|
cmake -B basic-test-build -S . -DCMAKE_BUILD_TYPE=Debug --preset basic-tests
|
||||||
|
```
|
||||||
|
|
||||||
However, not all tests can be written as plain unit tests. For example,
|
However, not all tests can be written as plain unit tests. For example,
|
||||||
checking that Catch2 orders tests randomly when asked to, and that this
|
checking that Catch2 orders tests randomly when asked to, and that this
|
||||||
random ordering is subset-invariant, is better done as an integration
|
random ordering is subset-invariant, is better done as an integration
|
||||||
@@ -76,21 +85,23 @@ configuration and require separate compilation.
|
|||||||
Finally, CMake config tests test that you set Catch2's compile-time
|
Finally, CMake config tests test that you set Catch2's compile-time
|
||||||
configuration options through CMake, using CMake options of the same name.
|
configuration options through CMake, using CMake options of the same name.
|
||||||
|
|
||||||
None of these tests are enabled by default. To enable them, add
|
These test categories can be enabled one by one, by passing
|
||||||
`-DCATCH_BUILD_EXAMPLES=ON`, `-DCATCH_BUILD_EXTRA_TESTS=ON`, and
|
`-DCATCH_BUILD_EXAMPLES=ON`, `-DCATCH_BUILD_EXTRA_TESTS=ON`, and
|
||||||
`-DCATCH_ENABLE_CONFIGURE_TESTS=ON` when configuration the CMake build.
|
`-DCATCH_ENABLE_CONFIGURE_TESTS=ON` when configuring the build.
|
||||||
|
|
||||||
Bringing this all together, the steps below should configure, build,
|
Catch2 also provides a preset that promises to enable _all_ test types,
|
||||||
and run all tests in the `Debug` compilation.
|
`all-tests`.
|
||||||
|
|
||||||
|
The snippet below will build & run all tests, in `Debug` compilation mode.
|
||||||
|
|
||||||
<!-- snippet: catch2-build-and-test -->
|
<!-- snippet: catch2-build-and-test -->
|
||||||
<a id='snippet-catch2-build-and-test'></a>
|
<a id='snippet-catch2-build-and-test'></a>
|
||||||
```sh
|
```sh
|
||||||
# 1. Regenerate the amalgamated distribution
|
# 1. Regenerate the amalgamated distribution (some tests are built against it)
|
||||||
./tools/scripts/generateAmalgamatedFiles.py
|
./tools/scripts/generateAmalgamatedFiles.py
|
||||||
|
|
||||||
# 2. Configure the full test build
|
# 2. Configure the full test build
|
||||||
cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON
|
cmake -B debug-build -S . -DCMAKE_BUILD_TYPE=Debug --preset all-tests
|
||||||
|
|
||||||
# 3. Run the actual build
|
# 3. Run the actual build
|
||||||
cmake --build debug-build
|
cmake --build debug-build
|
||||||
@@ -291,7 +302,7 @@ Specifically, every source file should start with the licence header:
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -303,6 +314,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.
|
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
|
## CoC
|
||||||
|
|
||||||
This project has a [CoC](../CODE_OF_CONDUCT.md). Please adhere to it
|
This project has a [CoC](../CODE_OF_CONDUCT.md). Please adhere to it
|
||||||
|
@@ -26,6 +26,15 @@ to accurately probe the environment for this information so the flag
|
|||||||
where it will export `BAZEL_TEST=1` for purposes like the above. Catch2
|
where it will export `BAZEL_TEST=1` for purposes like the above. Catch2
|
||||||
will now instead inspect the environment instead of relying on build configuration.
|
will now instead inspect the environment instead of relying on build configuration.
|
||||||
|
|
||||||
|
### `IEventLister::skipTest( TestCaseInfo const& testInfo )`
|
||||||
|
|
||||||
|
This event (including implementations in derived classes such as `ReporterBase`)
|
||||||
|
is deprecated and will be removed in the next major release. It is currently
|
||||||
|
invoked for all test cases that are not going to be executed due to the test run
|
||||||
|
being aborted (when using `--abort` or `--abortx`). It is however
|
||||||
|
**NOT** invoked for test cases that are [explicitly skipped using the `SKIP`
|
||||||
|
macro](skipping-passing-failing.md#top).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Home](Readme.md#top)
|
[Home](Readme.md#top)
|
||||||
|
22
docs/faq.md
22
docs/faq.md
@@ -9,6 +9,8 @@
|
|||||||
[What is Catch2's API stability policy?](#what-is-catch2s-api-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>
|
[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>
|
[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?
|
## How do I run global setup/teardown only if tests will be run?
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ depending on how often the cleanup needs to happen.
|
|||||||
## Why cannot I derive from the built-in reporters?
|
## Why cannot I derive from the built-in reporters?
|
||||||
|
|
||||||
They are not made to be overridden, 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
|
a consistent internal state if a member function is overridden, and by
|
||||||
forbidding users from using them as a base class, we can refactor them
|
forbidding users from using them as a base class, we can refactor them
|
||||||
as needed later.
|
as needed later.
|
||||||
|
|
||||||
@@ -69,6 +71,24 @@ library on platforms that default to public visibility, or with tooling
|
|||||||
support to force export Catch2's API.
|
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)
|
[Home](Readme.md#top)
|
||||||
|
@@ -134,7 +134,7 @@ type, making their usage much nicer. These are
|
|||||||
* `map<T>(func, GeneratorWrapper<U>&&)` for `MapGenerator<T, U, Func>` (map `U` to `T`)
|
* `map<T>(func, GeneratorWrapper<U>&&)` for `MapGenerator<T, U, Func>` (map `U` to `T`)
|
||||||
* `chunk(chunk-size, GeneratorWrapper<T>&&)` for `ChunkGenerator<T>`
|
* `chunk(chunk-size, GeneratorWrapper<T>&&)` for `ChunkGenerator<T>`
|
||||||
* `random(IntegerOrFloat a, IntegerOrFloat b)` for `RandomIntegerGenerator` or `RandomFloatGenerator`
|
* `random(IntegerOrFloat a, IntegerOrFloat b)` for `RandomIntegerGenerator` or `RandomFloatGenerator`
|
||||||
* `range(Arithemtic start, Arithmetic end)` for `RangeGenerator<Arithmetic>` with a step size of `1`
|
* `range(Arithmetic start, Arithmetic end)` for `RangeGenerator<Arithmetic>` with a step size of `1`
|
||||||
* `range(Arithmetic start, Arithmetic end, Arithmetic step)` for `RangeGenerator<Arithmetic>` with a custom step size
|
* `range(Arithmetic start, Arithmetic end, Arithmetic step)` for `RangeGenerator<Arithmetic>` with a custom step size
|
||||||
* `from_range(InputIterator from, InputIterator to)` for `IteratorGenerator<T>`
|
* `from_range(InputIterator from, InputIterator to)` for `IteratorGenerator<T>`
|
||||||
* `from_range(Container const&)` for `IteratorGenerator<T>`
|
* `from_range(Container const&)` for `IteratorGenerator<T>`
|
||||||
@@ -205,15 +205,37 @@ struct IGenerator : GeneratorUntypedBase {
|
|||||||
// Precondition:
|
// Precondition:
|
||||||
// The generator is either freshly constructed or the last call to next() returned true
|
// The generator is either freshly constructed or the last call to next() returned true
|
||||||
virtual T const& get() const = 0;
|
virtual T const& get() const = 0;
|
||||||
|
|
||||||
|
// Returns user-friendly string showing the current generator element
|
||||||
|
// Does not have to be overridden, IGenerator provides default implementation
|
||||||
|
virtual std::string stringifyImpl() const;
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
However, to be able to use your custom generator inside `GENERATE`, it
|
However, to be able to use your custom generator inside `GENERATE`, it
|
||||||
will need to be wrapped inside a `GeneratorWrapper<T>`.
|
will need to be wrapped inside a `GeneratorWrapper<T>`.
|
||||||
`GeneratorWrapper<T>` is a value wrapper around a
|
`GeneratorWrapper<T>` is a value wrapper around a
|
||||||
`std::unique_ptr<IGenerator<T>>`.
|
`Catch::Detail::unique_ptr<IGenerator<T>>`.
|
||||||
|
|
||||||
For full example of implementing your own generator, look into Catch2's
|
For full example of implementing your own generator, look into Catch2's
|
||||||
examples, specifically
|
examples, specifically
|
||||||
[Generators: Create your own generator](../examples/300-Gen-OwnGenerator.cpp).
|
[Generators: Create your own generator](../examples/300-Gen-OwnGenerator.cpp).
|
||||||
|
|
||||||
|
|
||||||
|
### Handling empty generators
|
||||||
|
|
||||||
|
The generator interface assumes that a generator always has at least one
|
||||||
|
element. This is not always true, e.g. if the generator depends on an external
|
||||||
|
datafile, the file might be missing.
|
||||||
|
|
||||||
|
There are two ways to handle this, depending on whether you want this
|
||||||
|
to be an error or not.
|
||||||
|
|
||||||
|
* If empty generator **is** an error, throw an exception in constructor.
|
||||||
|
* If empty generator **is not** an error, use the [`SKIP`](skipping-passing-failing.md#skipping-test-cases-at-runtime) in constructor.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[Home](Readme.md#top)
|
||||||
|
@@ -88,8 +88,8 @@ because only one thread passes the `REQUIRE` macro and this is not
|
|||||||
REQUIRE(cnt == 16);
|
REQUIRE(cnt == 16);
|
||||||
```
|
```
|
||||||
|
|
||||||
Because C++11 provides the necessary tools to do this, we are planning
|
We currently do not plan to support thread-safe assertions.
|
||||||
to remove this limitation in the future.
|
|
||||||
|
|
||||||
### Process isolation in a test
|
### Process isolation in a test
|
||||||
Catch does not support running tests in isolated (forked) processes. While this might in the future, the fact that Windows does not support forking and only allows full-on process creation and the desire to keep code as similar as possible across platforms, mean that this is likely to take significant development time, that is not currently available.
|
Catch does not support running tests in isolated (forked) processes. While this might in the future, the fact that Windows does not support forking and only allows full-on process creation and the desire to keep code as similar as possible across platforms, mean that this is likely to take significant development time, that is not currently available.
|
||||||
@@ -155,7 +155,7 @@ with expansion:
|
|||||||
|
|
||||||
|
|
||||||
### Clang/G++ -- skipping leaf sections after an exception
|
### Clang/G++ -- skipping leaf sections after an exception
|
||||||
Some versions of `libc++` and `libstdc++` (or their runtimes) have a bug with `std::uncaught_exception()` getting stuck returning `true` after rethrow, even if there are no active exceptions. One such case is this snippet, which skipped the sections "a" and "b", when compiled against `libcxxrt` from master
|
Some versions of `libc++` and `libstdc++` (or their runtimes) have a bug with `std::uncaught_exception()` getting stuck returning `true` after rethrow, even if there are no active exceptions. One such case is this snippet, which skipped the sections "a" and "b", when compiled against `libcxxrt` from the master branch
|
||||||
```cpp
|
```cpp
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
@@ -141,18 +141,27 @@ are a permutation of the ones in `some_vec`.
|
|||||||
|
|
||||||
### Floating point matchers
|
### Floating point matchers
|
||||||
|
|
||||||
Catch2 provides 3 matchers that target floating point numbers. These
|
Catch2 provides 4 matchers that target floating point numbers. These
|
||||||
are:
|
are:
|
||||||
|
|
||||||
* `WithinAbs(double target, double margin)`,
|
* `WithinAbs(double target, double margin)`,
|
||||||
* `WithinULP(FloatingPoint target, uint64_t maxUlpDiff)`, and
|
* `WithinULP(FloatingPoint target, uint64_t maxUlpDiff)`, and
|
||||||
* `WithinRel(FloatingPoint target, FloatingPoint eps)`.
|
* `WithinRel(FloatingPoint target, FloatingPoint eps)`.
|
||||||
|
* `IsNaN()`
|
||||||
|
|
||||||
> `WithinRel` matcher was introduced in Catch2 2.10.0
|
> `WithinRel` matcher was introduced in Catch2 2.10.0
|
||||||
|
|
||||||
For more details, read [the docs on comparing floating point
|
> `IsNaN` matcher was introduced in Catch2 3.3.2.
|
||||||
|
|
||||||
|
The first three serve to compare two floating pointe numbers. For more
|
||||||
|
details about how they work, read [the docs on comparing floating point
|
||||||
numbers](comparing-floating-point-numbers.md#floating-point-matchers).
|
numbers](comparing-floating-point-numbers.md#floating-point-matchers).
|
||||||
|
|
||||||
|
`IsNaN` then does exactly what it says on the tin. It matches the input
|
||||||
|
if it is a NaN (Not a Number). The advantage of using it over just plain
|
||||||
|
`REQUIRE(std::isnan(x))`, is that if the check fails, with `REQUIRE` you
|
||||||
|
won't see the value of `x`, but with `REQUIRE_THAT(x, IsNaN())`, you will.
|
||||||
|
|
||||||
|
|
||||||
### Miscellaneous matchers
|
### Miscellaneous matchers
|
||||||
|
|
||||||
@@ -190,13 +199,23 @@ properties. The macro is `REQUIRE_THROWS_MATCHES(expr, ExceptionType, Matcher)`.
|
|||||||
> `REQUIRE_THROWS_MATCHES` macro lives in `catch2/matchers/catch_matchers.hpp`
|
> `REQUIRE_THROWS_MATCHES` macro lives in `catch2/matchers/catch_matchers.hpp`
|
||||||
|
|
||||||
|
|
||||||
Catch2 currently provides only one matcher for exceptions,
|
Catch2 currently provides two matchers for exceptions.
|
||||||
`Message(std::string message)`. `Message` checks that the exception's
|
These are:
|
||||||
|
* `Message(std::string message)`.
|
||||||
|
* `MessageMatches(Matcher matcher)`.
|
||||||
|
|
||||||
|
> `MessageMatches` was [introduced](https://github.com/catchorg/Catch2/pull/2570) in Catch2 3.3.0
|
||||||
|
|
||||||
|
`Message` checks that the exception's
|
||||||
message, as returned from `what` is exactly equal to `message`.
|
message, as returned from `what` is exactly equal to `message`.
|
||||||
|
|
||||||
|
`MessageMatches` applies the provided matcher on the exception's
|
||||||
|
message, as returned from `what`. This is useful in conjunctions with the `std::string` matchers (e.g. `StartsWith`)
|
||||||
|
|
||||||
Example use:
|
Example use:
|
||||||
```cpp
|
```cpp
|
||||||
REQUIRE_THROWS_MATCHES(throwsDerivedException(), DerivedException, Message("DerivedException::what"));
|
REQUIRE_THROWS_MATCHES(throwsDerivedException(), DerivedException, Message("DerivedException::what"));
|
||||||
|
REQUIRE_THROWS_MATCHES(throwsDerivedException(), DerivedException, MessageMatches(StartsWith("DerivedException")));
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that `DerivedException` in the example above has to derive from
|
Note that `DerivedException` in the example above has to derive from
|
||||||
@@ -218,11 +237,19 @@ definitions to handle generic range-like types. These are:
|
|||||||
* `Contains(T&& target_element, Comparator = std::equal_to<>{})`
|
* `Contains(T&& target_element, Comparator = std::equal_to<>{})`
|
||||||
* `Contains(Matcher element_matcher)`
|
* `Contains(Matcher element_matcher)`
|
||||||
* `AllMatch(Matcher element_matcher)`
|
* `AllMatch(Matcher element_matcher)`
|
||||||
* `NoneMatch(Matcher element_matcher)`
|
|
||||||
* `AnyMatch(Matcher element_matcher)`
|
* `AnyMatch(Matcher element_matcher)`
|
||||||
* `AllTrue()`
|
* `NoneMatch(Matcher element_matcher)`
|
||||||
* `NoneTrue()`
|
* `AllTrue()`, `AnyTrue()`, `NoneTrue()`
|
||||||
* `AnyTrue()`
|
* `RangeEquals(TargetRangeLike&&, Comparator = std::equal_to<>{})`
|
||||||
|
* `UnorderedRangeEquals(TargetRangeLike&&, Comparator = std::equal_to<>{})`
|
||||||
|
|
||||||
|
> `IsEmpty`, `SizeIs`, `Contains` were introduced in Catch2 3.0.1
|
||||||
|
|
||||||
|
> `All/Any/NoneMatch` were introduced in Catch2 3.0.1
|
||||||
|
|
||||||
|
> `All/Any/NoneTrue` were introduced in Catch2 3.1.0
|
||||||
|
|
||||||
|
> `RangeEquals` and `UnorderedRangeEquals` matchers were [introduced](https://github.com/catchorg/Catch2/pull/2377) in Catch2 3.3.0
|
||||||
|
|
||||||
`IsEmpty` should be self-explanatory. It successfully matches objects
|
`IsEmpty` should be self-explanatory. It successfully matches objects
|
||||||
that are empty according to either `std::empty`, or ADL-found `empty`
|
that are empty according to either `std::empty`, or ADL-found `empty`
|
||||||
@@ -249,6 +276,25 @@ all, none, or any of the contained elements are `true`, respectively.
|
|||||||
It works for ranges of `bool`s and ranges of elements (explicitly)
|
It works for ranges of `bool`s and ranges of elements (explicitly)
|
||||||
convertible to `bool`.
|
convertible to `bool`.
|
||||||
|
|
||||||
|
`RangeEquals` compares the range that the matcher is constructed with
|
||||||
|
(the "target range") against the range to be tested, element-wise. The
|
||||||
|
match succeeds if all elements from the two ranges compare equal (using
|
||||||
|
`operator==` by default). The ranges do not need to be the same type,
|
||||||
|
and the element types do not need to be the same, as long as they are
|
||||||
|
comparable. (e.g. you may compare `std::vector<int>` to `std::array<char>`).
|
||||||
|
|
||||||
|
`UnorderedRangeEquals` is similar to `RangeEquals`, but the order
|
||||||
|
does not matter. For example "1, 2, 3" would match "3, 2, 1", but not
|
||||||
|
"1, 1, 2, 3" As with `RangeEquals`, `UnorderedRangeEquals` compares
|
||||||
|
the individual elements using using `operator==` by default.
|
||||||
|
|
||||||
|
Both `RangeEquals` and `UnorderedRangeEquals` optionally accept a
|
||||||
|
predicate which can be used to compare the containers element-wise.
|
||||||
|
|
||||||
|
To check a container elementwise against a given matcher, use
|
||||||
|
`AllMatch`.
|
||||||
|
|
||||||
|
|
||||||
## Writing custom matchers (old style)
|
## Writing custom matchers (old style)
|
||||||
|
|
||||||
The old style of writing matchers has been introduced back in Catch
|
The old style of writing matchers has been introduced back in Catch
|
||||||
|
@@ -95,6 +95,9 @@ A C++ client library for Consul. Consul is a distributed tool for discovering an
|
|||||||
### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp)
|
### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp)
|
||||||
A library of algorithms for values-distributed-in-time.
|
A library of algorithms for values-distributed-in-time.
|
||||||
|
|
||||||
|
### [SFML](https://github.com/SFML/SFML)
|
||||||
|
Simple and Fast Multimedia Library.
|
||||||
|
|
||||||
### [SOCI](https://github.com/SOCI/soci)
|
### [SOCI](https://github.com/SOCI/soci)
|
||||||
The C++ Database Access Library.
|
The C++ Database Access Library.
|
||||||
|
|
||||||
@@ -110,6 +113,12 @@ A header-only TOML parser and serializer for modern C++.
|
|||||||
### [Trompeloeil](https://github.com/rollbear/trompeloeil)
|
### [Trompeloeil](https://github.com/rollbear/trompeloeil)
|
||||||
A thread-safe header-only mocking framework for C++14.
|
A thread-safe header-only mocking framework for C++14.
|
||||||
|
|
||||||
|
### [wxWidgets](https://www.wxwidgets.org/)
|
||||||
|
Cross-Platform C++ GUI Library.
|
||||||
|
|
||||||
|
### [xmlwrapp](https://github.com/vslavik/xmlwrapp)
|
||||||
|
C++ XML parsing library using libxml2.
|
||||||
|
|
||||||
## Applications & Tools
|
## Applications & Tools
|
||||||
|
|
||||||
### [App Mesh](https://github.com/laoshanxi/app-mesh)
|
### [App Mesh](https://github.com/laoshanxi/app-mesh)
|
||||||
@@ -137,7 +146,7 @@ Newsbeuter is an open-source RSS/Atom feed reader for text terminals.
|
|||||||
A 2D, Zombie, RPG game which is being made on our own engine.
|
A 2D, Zombie, RPG game which is being made on our own engine.
|
||||||
|
|
||||||
### [raspigcd](https://github.com/pantadeusz/raspigcd)
|
### [raspigcd](https://github.com/pantadeusz/raspigcd)
|
||||||
Low level CLI app and library for execution of GCODE on Raspberry Pi without any additional microcontrolers (just RPi + Stepsticks).
|
Low level CLI app and library for execution of GCODE on Raspberry Pi without any additional microcontrollers (just RPi + Stepsticks).
|
||||||
|
|
||||||
### [SpECTRE](https://github.com/sxs-collaboration/spectre)
|
### [SpECTRE](https://github.com/sxs-collaboration/spectre)
|
||||||
SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics.
|
SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics.
|
||||||
|
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
# Release notes
|
# Release notes
|
||||||
**Contents**<br>
|
**Contents**<br>
|
||||||
|
[3.3.2](#332)<br>
|
||||||
|
[3.3.1](#331)<br>
|
||||||
|
[3.3.0](#330)<br>
|
||||||
|
[3.2.1](#321)<br>
|
||||||
|
[3.2.0](#320)<br>
|
||||||
[3.1.1](#311)<br>
|
[3.1.1](#311)<br>
|
||||||
[3.1.0](#310)<br>
|
[3.1.0](#310)<br>
|
||||||
[3.0.1](#301)<br>
|
[3.0.1](#301)<br>
|
||||||
@@ -52,6 +57,138 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 3.4.0
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
* `VectorEquals` supports elements that provide only `==` and not `!=` (#2648)
|
||||||
|
* Catch2 supports compiling with IAR compiler (#2651)
|
||||||
|
* Various small internal performance improvements
|
||||||
|
* Various small internal compilation time improvements
|
||||||
|
* XMLReporter now reports location info for INFO and WARN (#1251)
|
||||||
|
* This bumps up the xml format version to 3
|
||||||
|
* Documented that `SKIP` in generator constructor can be used to handle empty generator (#1593)
|
||||||
|
* Added experimental static analysis support to `TEST_CASE` and `SECTION` macros (#2681)
|
||||||
|
* The two macros are redefined in a way that helps the SA tools reason about the possible paths through a test case with sections.
|
||||||
|
* The support is controlled by the `CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT` option and autodetects clang-tidy and Coverity.
|
||||||
|
* `*_THROWS`, `*_THROWS_AS`, etc now suppress warning coming from `__attribute__((warn_unused_result))` on GCC (#2691)
|
||||||
|
* Unlike plain `[[nodiscard]]`, this warning is not silenced by void cast. WTF GCC?
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
* Fixed `assertionStarting` events being sent after the expr is evaluated (#2678)
|
||||||
|
* Errors in `TEST_CASE` tags are now reported nicely (#2650)
|
||||||
|
|
||||||
|
### Miscellaneous
|
||||||
|
* Bunch of improvements to `catch_discover_tests`
|
||||||
|
* Added DISCOVERY_MODE option, so the discovery can happen either post build or pre-run.
|
||||||
|
* Fixed handling of semicolons and backslashes in test names (#2674, #2676)
|
||||||
|
* meson build can disable building tests (#2693)
|
||||||
|
* meson build properly sets meson version 0.54.1 as the minimal supported version (#2688)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.3.2
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
* Further reduced allocations
|
||||||
|
* The compact, console, TAP and XML reporters perform less allocations in various cases
|
||||||
|
* Removed 1 allocation per entered `SECTION`/`TEST_CASE`.
|
||||||
|
* Removed 2 allocations per test case exit, if stdout/stderr is captured
|
||||||
|
* Improved performance
|
||||||
|
* Section tracking is 10%-25% faster than in v3.3.0
|
||||||
|
* Assertion handling is 5%-10% faster than in v3.3.0
|
||||||
|
* Test case registration is 1%-2% faster than in v3.3.0
|
||||||
|
* Tiny speedup for registering listeners
|
||||||
|
* Tiny speedup for `CAPTURE`, `TEST_CASE_METHOD`, `METHOD_AS_TEST_CASE`, and `TEMPLATE_LIST_TEST_*` macros.
|
||||||
|
* `Contains`, `RangeEquals` and `UnorderedRangeEquals` matchers now support ranges with iterator + sentinel pair
|
||||||
|
* Added `IsNaN` matcher
|
||||||
|
* Unlike `REQUIRE(isnan(x))`, `REQUIRE_THAT(x, IsNaN())` shows you the value of `x`.
|
||||||
|
* Suppressed `declared_but_not_referenced` warning for NVHPC (#2637)
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
* Fixed performance regression in section tracking introduced in v3.3.1
|
||||||
|
* Extreme cases would cause the tracking to run about 4x slower than in 3.3.0
|
||||||
|
|
||||||
|
|
||||||
|
## 3.3.1
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
* Reduced allocations and improved performance
|
||||||
|
* The exact improvements are dependent on your usage of Catch2.
|
||||||
|
* For example running Catch2's SelfTest binary performs 8k less allocations.
|
||||||
|
* The main improvement comes from smarter handling of `SECTION`s, especially sibling `SECTION`s
|
||||||
|
|
||||||
|
|
||||||
|
## 3.3.0
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* Added `MessageMatches` exception matcher (#2570)
|
||||||
|
* Added `RangeEquals` and `UnorderedRangeEquals` generic range matchers (#2377)
|
||||||
|
* Added `SKIP` macro for skipping tests from within the test body (#2360)
|
||||||
|
* All built-in reporters have been extended to handle it properly, whether your custom reporter needs changes depends on how it was written
|
||||||
|
* `skipTest` reporter event **is unrelated** to this, and has been deprecated since it has practically no uses
|
||||||
|
* Restored support for PPC Macs in the break-into-debugger functionality (#2619)
|
||||||
|
* Made our warning suppression compatible with CUDA toolkit pre 11.5 (#2626)
|
||||||
|
* Cleaned out some static analysis complaints
|
||||||
|
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
* Fixed macro redefinition warning when NVCC was reporting as MSVC (#2603)
|
||||||
|
* Fixed throws in generator constructor causing the whole binary to abort (#2615)
|
||||||
|
* Now it just fails the test
|
||||||
|
* Fixed missing transitive include with libstdc++13 (#2611)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous
|
||||||
|
|
||||||
|
* Improved support for dynamic library build with non-MSVC compilers on Windows (#2630)
|
||||||
|
* When used as a subproject, Catch2 keeps its generated header in a separate directory from the main project (#2604)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 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 occurring 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
|
## 3.1.1
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
@@ -408,7 +545,7 @@ v3 releases.
|
|||||||
* The `SECTION`(s) before the `GENERATE` will not be run multiple times, the following ones will.
|
* The `SECTION`(s) before the `GENERATE` will not be run multiple times, the following ones will.
|
||||||
* Added `-D`/`--min-duration` command line flag (#1910)
|
* Added `-D`/`--min-duration` command line flag (#1910)
|
||||||
* If a test takes longer to finish than the provided value, its name and duration will be printed.
|
* If a test takes longer to finish than the provided value, its name and duration will be printed.
|
||||||
* This flag is overriden by setting `-d`/`--duration`.
|
* This flag is overridden by setting `-d`/`--duration`.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
* `TAPReporter` no longer skips successful assertions (#1983)
|
* `TAPReporter` no longer skips successful assertions (#1983)
|
||||||
@@ -449,7 +586,7 @@ v3 releases.
|
|||||||
### Improvements
|
### Improvements
|
||||||
* `std::result_of` is not used if `std::invoke_result` is available (#1934)
|
* `std::result_of` is not used if `std::invoke_result` is available (#1934)
|
||||||
* JUnit reporter writes out `status` attribute for tests (#1899)
|
* 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
|
* Catch2 was already suppressing the `cppcoreguidelines-pro-type-vararg` alias of the warning
|
||||||
|
|
||||||
|
|
||||||
@@ -476,7 +613,7 @@ v3 releases.
|
|||||||
### Fixes
|
### Fixes
|
||||||
* Fixed computation of benchmarking column widths in ConsoleReporter (#1885, #1886)
|
* Fixed computation of benchmarking column widths in ConsoleReporter (#1885, #1886)
|
||||||
* Suppressed clang-tidy's `cppcoreguidelines-pro-type-vararg` in assertions (#1901)
|
* Suppressed clang-tidy's `cppcoreguidelines-pro-type-vararg` in assertions (#1901)
|
||||||
* It was a false positive trigered by the new warning support workaround
|
* It was a false positive triggered by the new warning support workaround
|
||||||
* Fixed bug in test specification parser handling of OR'd patterns using escaping (#1905)
|
* Fixed bug in test specification parser handling of OR'd patterns using escaping (#1905)
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
@@ -813,7 +950,7 @@ v3 releases.
|
|||||||
|
|
||||||
### Contrib
|
### Contrib
|
||||||
* `ParseAndAddCatchTests` has learned how to use `DISABLED` CTest property (#1452)
|
* `ParseAndAddCatchTests` has learned how to use `DISABLED` CTest property (#1452)
|
||||||
* `ParseAndAddCatchTests` now works when there is a whitspace before the test name (#1493)
|
* `ParseAndAddCatchTests` now works when there is a whitespace before the test name (#1493)
|
||||||
|
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
@@ -96,12 +96,12 @@ void assertionStarting( AssertionInfo const& assertionInfo );
|
|||||||
void assertionEnded( AssertionStats const& assertionStats );
|
void assertionEnded( AssertionStats const& assertionStats );
|
||||||
```
|
```
|
||||||
|
|
||||||
`assertionStarting` is called after the expression is captured, but before
|
The `assertionStarting` event is emitted before the expression in the
|
||||||
the assertion expression is evaluated. This might seem like a minor
|
assertion is captured or evaluated and `assertionEnded` is emitted
|
||||||
distinction, but what it means is that if you have assertion like
|
afterwards. This means that given assertion like `REQUIRE(a + b == c + d)`,
|
||||||
`REQUIRE( a + b == c + d )`, then what happens is that `a + b` and `c + d`
|
Catch2 first emits `assertionStarting` event, then `a + b` and `c + d`
|
||||||
are evaluated before `assertionStarting` is emitted, while the `==` is
|
are evaluated, then their results are captured, the comparison is evaluated,
|
||||||
evaluated after the event.
|
and then `assertionEnded` event is emitted.
|
||||||
|
|
||||||
|
|
||||||
## Benchmarking events
|
## Benchmarking events
|
||||||
|
@@ -52,7 +52,7 @@ its machine-readable XML output to file `result-junit.xml`, and the
|
|||||||
uses ANSI colour codes for colouring the output.
|
uses ANSI colour codes for colouring the output.
|
||||||
|
|
||||||
Using multiple reporters (or one reporter and one-or-more [event
|
Using multiple reporters (or one reporter and one-or-more [event
|
||||||
listeners](event-listener.md#top)) can have surprisingly complex semantics
|
listeners](event-listeners.md#top)) can have surprisingly complex semantics
|
||||||
when using customization points provided to reporters by Catch2, namely
|
when using customization points provided to reporters by Catch2, namely
|
||||||
capturing stdout/stderr from test cases.
|
capturing stdout/stderr from test cases.
|
||||||
|
|
||||||
|
135
docs/skipping-passing-failing.md
Normal file
135
docs/skipping-passing-failing.md
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<a id="top"></a>
|
||||||
|
# Explicitly skipping, passing, and failing tests at runtime
|
||||||
|
|
||||||
|
## Skipping Test Cases at Runtime
|
||||||
|
|
||||||
|
> [Introduced](https://github.com/catchorg/Catch2/pull/2360) in Catch2 3.3.0.
|
||||||
|
|
||||||
|
In some situations it may not be possible to meaningfully execute a test case,
|
||||||
|
for example when the system under test is missing certain hardware capabilities.
|
||||||
|
If the required conditions can only be determined at runtime, it often
|
||||||
|
doesn't make sense to consider such a test case as either passed or failed,
|
||||||
|
because it simply can not run at all.
|
||||||
|
|
||||||
|
To properly express such scenarios, Catch2 provides a way to explicitly
|
||||||
|
_skip_ test cases, using the `SKIP` macro:
|
||||||
|
|
||||||
|
```
|
||||||
|
SKIP( [streamable expression] )
|
||||||
|
```
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
TEST_CASE("copy files between drives") {
|
||||||
|
if(getNumberOfHardDrives() < 2) {
|
||||||
|
SKIP("at least two hard drives required");
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This test case is then reported as _skipped_ instead of _passed_ or _failed_.
|
||||||
|
|
||||||
|
The `SKIP` macro behaves similarly to an explicit [`FAIL`](#passing-and-failing-test-cases),
|
||||||
|
in that it is the last expression that will be executed:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
TEST_CASE("my test") {
|
||||||
|
printf("foo");
|
||||||
|
SKIP();
|
||||||
|
printf("bar"); // not printed
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
However a failed assertion _before_ a `SKIP` still causes the entire
|
||||||
|
test case to fail:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
TEST_CASE("failing test") {
|
||||||
|
CHECK(1 == 2);
|
||||||
|
SKIP();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Interaction with Sections and Generators
|
||||||
|
|
||||||
|
Sections, nested sections as well as specific outputs from [generators](generators.md#top)
|
||||||
|
can all be individually skipped, with the rest executing as usual:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
TEST_CASE("complex test case") {
|
||||||
|
int value = GENERATE(2, 4, 6);
|
||||||
|
SECTION("a") {
|
||||||
|
SECTION("a1") { CHECK(value < 8); }
|
||||||
|
SECTION("a2") {
|
||||||
|
if (value == 4) {
|
||||||
|
SKIP();
|
||||||
|
}
|
||||||
|
CHECK(value % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This test case will report 5 passing assertions; one for each of the three
|
||||||
|
values in section `a1`, and then two in section `a2`, from values 2 and 4.
|
||||||
|
|
||||||
|
Note that as soon as one section is skipped, the entire test case will
|
||||||
|
be reported as _skipped_ (unless there is a failing assertion, in which
|
||||||
|
case the test is handled as _failed_ instead).
|
||||||
|
|
||||||
|
Note that if all test cases in a run are skipped, Catch2 returns a non-zero
|
||||||
|
exit code, same as it does if no test cases have run. This behaviour can
|
||||||
|
be overridden using the [--allow-running-no-tests](command-line.md#no-tests-override)
|
||||||
|
flag.
|
||||||
|
|
||||||
|
### `SKIP` inside generators
|
||||||
|
|
||||||
|
You can also use the `SKIP` macro inside generator's constructor to handle
|
||||||
|
cases where the generator is empty, but you do not want to fail the test
|
||||||
|
case.
|
||||||
|
|
||||||
|
|
||||||
|
## Passing and failing test cases
|
||||||
|
|
||||||
|
Test cases can also be explicitly passed or failed, without the use of
|
||||||
|
assertions, and with a specific message. This can be useful to handle
|
||||||
|
complex preconditions/postconditions and give useful error messages
|
||||||
|
when they fail.
|
||||||
|
|
||||||
|
* `SUCCEED( [streamable expression] )`
|
||||||
|
|
||||||
|
`SUCCEED` is morally equivalent with `INFO( [streamable expression] ); REQUIRE( true );`.
|
||||||
|
Note that it does not stop further test execution, so it cannot be used
|
||||||
|
to guard failing assertions from being executed.
|
||||||
|
|
||||||
|
_In practice, `SUCCEED` is usually used as a test placeholder, to avoid
|
||||||
|
[failing a test case due to missing assertions](command-line.md#warnings)._
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
TEST_CASE( "SUCCEED showcase" ) {
|
||||||
|
int I = 1;
|
||||||
|
SUCCEED( "I is " << I );
|
||||||
|
// ... execution continues here ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* `FAIL( [streamable expression] )`
|
||||||
|
|
||||||
|
`FAIL` is morally equivalent with `INFO( [streamable expression] ); REQUIRE( false );`.
|
||||||
|
|
||||||
|
_In practice, `FAIL` is usually used to stop executing test that is currently
|
||||||
|
known to be broken, but has to be fixed later._
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
TEST_CASE( "FAIL showcase" ) {
|
||||||
|
FAIL( "This test case causes segfault, which breaks CI." );
|
||||||
|
// ... this will not be executed ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[Home](Readme.md#top)
|
@@ -25,7 +25,8 @@ _section description_ can be used to provide long form description
|
|||||||
of a section while keeping the _section name_ short for use with the
|
of a section while keeping the _section name_ short for use with the
|
||||||
[`-c` command line parameter](command-line.md#specify-the-section-to-run).
|
[`-c` command line parameter](command-line.md#specify-the-section-to-run).
|
||||||
|
|
||||||
**Test names must be unique within the Catch executable.**
|
**The combination of test names and tags must be unique within the Catch2
|
||||||
|
executable.**
|
||||||
|
|
||||||
For examples see the [Tutorial](tutorial.md#top)
|
For examples see the [Tutorial](tutorial.md#top)
|
||||||
|
|
||||||
@@ -68,7 +69,8 @@ All tag names beginning with non-alphanumeric characters are reserved by Catch.
|
|||||||
|
|
||||||
* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers.
|
* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers.
|
||||||
|
|
||||||
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped), as a tag to all contained tests, e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
|
* `[#<filename>]` - these tags are added to test cases when you run Catch2
|
||||||
|
with [`-#` or `--filenames-as-tags`](command-line.md#filenames-as-tags).
|
||||||
|
|
||||||
* `[@<alias>]` - tag aliases all begin with `@` (see below).
|
* `[@<alias>]` - tag aliases all begin with `@` (see below).
|
||||||
|
|
||||||
@@ -167,7 +169,11 @@ Other than the additional prefixes and the formatting in the console reporter th
|
|||||||
|
|
||||||
In addition to `TEST_CASE`s, Catch2 also supports test cases parametrised
|
In addition to `TEST_CASE`s, Catch2 also supports test cases parametrised
|
||||||
by types, in the form of `TEMPLATE_TEST_CASE`,
|
by types, in the form of `TEMPLATE_TEST_CASE`,
|
||||||
`TEMPLATE_PRODUCT_TEST_CASE` and `TEMPLATE_LIST_TEST_CASE`.
|
`TEMPLATE_PRODUCT_TEST_CASE` and `TEMPLATE_LIST_TEST_CASE`. These macros
|
||||||
|
are defined in the `catch_template_test_macros.hpp` header, so compiling
|
||||||
|
the code examples below also requires
|
||||||
|
`#include <catch2/catch_template_test_macros.hpp>`.
|
||||||
|
|
||||||
|
|
||||||
* **TEMPLATE_TEST_CASE(** _test name_ , _tags_, _type1_, _type2_, ..., _typen_ **)**
|
* **TEMPLATE_TEST_CASE(** _test name_ , _tags_, _type1_, _type2_, ..., _typen_ **)**
|
||||||
|
|
||||||
@@ -289,7 +295,9 @@ TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside std
|
|||||||
In addition to [type parametrised test cases](#type-parametrised-test-cases) Catch2 also supports
|
In addition to [type parametrised test cases](#type-parametrised-test-cases) Catch2 also supports
|
||||||
signature base parametrised test cases, in form of `TEMPLATE_TEST_CASE_SIG` and `TEMPLATE_PRODUCT_TEST_CASE_SIG`.
|
signature base parametrised test cases, in form of `TEMPLATE_TEST_CASE_SIG` and `TEMPLATE_PRODUCT_TEST_CASE_SIG`.
|
||||||
These test cases have similar syntax like [type parametrised test cases](#type-parametrised-test-cases), with one
|
These test cases have similar syntax like [type parametrised test cases](#type-parametrised-test-cases), with one
|
||||||
additional positional argument which specifies the signature.
|
additional positional argument which specifies the signature. These macros are defined in the
|
||||||
|
`catch_template_test_macros.hpp` header, so compiling the code examples below also requires
|
||||||
|
`#include <catch2/catch_template_test_macros.hpp>`.
|
||||||
|
|
||||||
### Signature
|
### Signature
|
||||||
Signature has some strict rules for these tests cases to work properly:
|
Signature has some strict rules for these tests cases to work properly:
|
||||||
|
@@ -44,11 +44,11 @@ TEST_CASE("Table allows pre-computed test inputs and outputs", "[example][genera
|
|||||||
|
|
||||||
/* Possible simplifications where less legacy toolchain support is needed:
|
/* Possible simplifications where less legacy toolchain support is needed:
|
||||||
*
|
*
|
||||||
* - With libstdc++6 or newer, the make_tuple() calls can be ommitted
|
* - With libstdc++6 or newer, the make_tuple() calls can be omitted
|
||||||
* (technically C++17 but does not require -std in GCC/Clang). See
|
* (technically C++17 but does not require -std in GCC/Clang). See
|
||||||
* https://stackoverflow.com/questions/12436586/tuple-vector-and-initializer-list
|
* https://stackoverflow.com/questions/12436586/tuple-vector-and-initializer-list
|
||||||
*
|
*
|
||||||
* - In C++17 mode std::tie() and the preceding variable delcarations can be
|
* - In C++17 mode std::tie() and the preceding variable declarations can be
|
||||||
* replaced by structured bindings: auto [test_input, expected] = GENERATE(
|
* replaced by structured bindings: auto [test_input, expected] = GENERATE(
|
||||||
* table<std::string, size_t>({ ...
|
* table<std::string, size_t>({ ...
|
||||||
*/
|
*/
|
||||||
|
@@ -54,8 +54,6 @@ set(ALL_EXAMPLE_TARGETS
|
|||||||
|
|
||||||
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
||||||
target_link_libraries( ${name} Catch2 Catch2WithMain )
|
target_link_libraries( ${name} Catch2 Catch2WithMain )
|
||||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 14)
|
|
||||||
set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
@@ -35,8 +35,9 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
|
|||||||
[TEST_LIST var]
|
[TEST_LIST var]
|
||||||
[REPORTER reporter]
|
[REPORTER reporter]
|
||||||
[OUTPUT_DIR dir]
|
[OUTPUT_DIR dir]
|
||||||
[OUTPUT_PREFIX prefix}
|
[OUTPUT_PREFIX prefix]
|
||||||
[OUTPUT_SUFFIX suffix]
|
[OUTPUT_SUFFIX suffix]
|
||||||
|
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
|
||||||
)
|
)
|
||||||
|
|
||||||
``catch_discover_tests`` sets up a post-build command on the test executable
|
``catch_discover_tests`` sets up a post-build command on the test executable
|
||||||
@@ -123,14 +124,28 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
|
|||||||
test executable and when the tests are executed themselves. This requires
|
test executable and when the tests are executed themselves. This requires
|
||||||
cmake/ctest >= 3.22.
|
cmake/ctest >= 3.22.
|
||||||
|
|
||||||
|
`DISCOVERY_MODE mode``
|
||||||
|
Provides control over when ``catch_discover_tests`` performs test discovery.
|
||||||
|
By default, ``POST_BUILD`` sets up a post-build command to perform test discovery
|
||||||
|
at build time. In certain scenarios, like cross-compiling, this ``POST_BUILD``
|
||||||
|
behavior is not desirable. By contrast, ``PRE_TEST`` delays test discovery until
|
||||||
|
just prior to test execution. This way test discovery occurs in the target environment
|
||||||
|
where the test has a better chance at finding appropriate runtime dependencies.
|
||||||
|
|
||||||
|
``DISCOVERY_MODE`` defaults to the value of the
|
||||||
|
``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when
|
||||||
|
calling ``catch_discover_tests``. This provides a mechanism for globally selecting
|
||||||
|
a preferred test discovery behavior without having to modify each call site.
|
||||||
|
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
function(catch_discover_tests TARGET)
|
function(catch_discover_tests TARGET)
|
||||||
|
|
||||||
cmake_parse_arguments(
|
cmake_parse_arguments(
|
||||||
""
|
""
|
||||||
""
|
""
|
||||||
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX"
|
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX;DISCOVERY_MODE"
|
||||||
"TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS"
|
"TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS"
|
||||||
${ARGN}
|
${ARGN}
|
||||||
)
|
)
|
||||||
@@ -141,12 +156,20 @@ function(catch_discover_tests TARGET)
|
|||||||
if(NOT _TEST_LIST)
|
if(NOT _TEST_LIST)
|
||||||
set(_TEST_LIST ${TARGET}_TESTS)
|
set(_TEST_LIST ${TARGET}_TESTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (_DL_PATHS)
|
if (_DL_PATHS)
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.22.0")
|
if(${CMAKE_VERSION} VERSION_LESS "3.22.0")
|
||||||
message(FATAL_ERROR "The DL_PATHS option requires at least cmake 3.22")
|
message(FATAL_ERROR "The DL_PATHS option requires at least cmake 3.22")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT _DISCOVERY_MODE)
|
||||||
|
if(NOT CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE)
|
||||||
|
set(CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE "POST_BUILD")
|
||||||
|
endif()
|
||||||
|
set(_DISCOVERY_MODE ${CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE})
|
||||||
|
endif()
|
||||||
|
if (NOT _DISCOVERY_MODE MATCHES "^(POST_BUILD|PRE_TEST)$")
|
||||||
|
message(FATAL_ERROR "Unknown DISCOVERY_MODE: ${_DISCOVERY_MODE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
## Generate a unique name based on the extra arguments
|
## Generate a unique name based on the extra arguments
|
||||||
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}")
|
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}")
|
||||||
@@ -159,39 +182,77 @@ function(catch_discover_tests TARGET)
|
|||||||
TARGET ${TARGET}
|
TARGET ${TARGET}
|
||||||
PROPERTY CROSSCOMPILING_EMULATOR
|
PROPERTY CROSSCOMPILING_EMULATOR
|
||||||
)
|
)
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TARGET} POST_BUILD
|
|
||||||
BYPRODUCTS "${ctest_tests_file}"
|
|
||||||
COMMAND "${CMAKE_COMMAND}"
|
|
||||||
-D "TEST_TARGET=${TARGET}"
|
|
||||||
-D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
|
|
||||||
-D "TEST_EXECUTOR=${crosscompiling_emulator}"
|
|
||||||
-D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
|
|
||||||
-D "TEST_SPEC=${_TEST_SPEC}"
|
|
||||||
-D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
|
|
||||||
-D "TEST_PROPERTIES=${_PROPERTIES}"
|
|
||||||
-D "TEST_PREFIX=${_TEST_PREFIX}"
|
|
||||||
-D "TEST_SUFFIX=${_TEST_SUFFIX}"
|
|
||||||
-D "TEST_LIST=${_TEST_LIST}"
|
|
||||||
-D "TEST_REPORTER=${_REPORTER}"
|
|
||||||
-D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}"
|
|
||||||
-D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}"
|
|
||||||
-D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}"
|
|
||||||
-D "TEST_DL_PATHS=${_DL_PATHS}"
|
|
||||||
-D "CTEST_FILE=${ctest_tests_file}"
|
|
||||||
-P "${_CATCH_DISCOVER_TESTS_SCRIPT}"
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
|
|
||||||
file(WRITE "${ctest_include_file}"
|
if(_DISCOVERY_MODE STREQUAL "POST_BUILD")
|
||||||
"if(EXISTS \"${ctest_tests_file}\")\n"
|
add_custom_command(
|
||||||
" include(\"${ctest_tests_file}\")\n"
|
TARGET ${TARGET} POST_BUILD
|
||||||
"else()\n"
|
BYPRODUCTS "${ctest_tests_file}"
|
||||||
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
"endif()\n"
|
-D "TEST_TARGET=${TARGET}"
|
||||||
)
|
-D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
|
||||||
|
-D "TEST_EXECUTOR=${crosscompiling_emulator}"
|
||||||
|
-D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
|
||||||
|
-D "TEST_SPEC=${_TEST_SPEC}"
|
||||||
|
-D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
|
||||||
|
-D "TEST_PROPERTIES=${_PROPERTIES}"
|
||||||
|
-D "TEST_PREFIX=${_TEST_PREFIX}"
|
||||||
|
-D "TEST_SUFFIX=${_TEST_SUFFIX}"
|
||||||
|
-D "TEST_LIST=${_TEST_LIST}"
|
||||||
|
-D "TEST_REPORTER=${_REPORTER}"
|
||||||
|
-D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}"
|
||||||
|
-D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}"
|
||||||
|
-D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}"
|
||||||
|
-D "TEST_DL_PATHS=${_DL_PATHS}"
|
||||||
|
-D "CTEST_FILE=${ctest_tests_file}"
|
||||||
|
-P "${_CATCH_DISCOVER_TESTS_SCRIPT}"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
|
file(WRITE "${ctest_include_file}"
|
||||||
|
"if(EXISTS \"${ctest_tests_file}\")\n"
|
||||||
|
" include(\"${ctest_tests_file}\")\n"
|
||||||
|
"else()\n"
|
||||||
|
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
|
||||||
|
"endif()\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
elseif(_DISCOVERY_MODE STREQUAL "PRE_TEST")
|
||||||
|
|
||||||
|
string(CONCAT ctest_include_content
|
||||||
|
"if(EXISTS \"$<TARGET_FILE:${TARGET}>\")" "\n"
|
||||||
|
" if(NOT EXISTS \"${ctest_tests_file}\" OR" "\n"
|
||||||
|
" NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"$<TARGET_FILE:${TARGET}>\" OR\n"
|
||||||
|
" NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"\${CMAKE_CURRENT_LIST_FILE}\")\n"
|
||||||
|
" include(\"${_CATCH_DISCOVER_TESTS_SCRIPT}\")" "\n"
|
||||||
|
" catch_discover_tests_impl(" "\n"
|
||||||
|
" TEST_EXECUTABLE" " [==[" "$<TARGET_FILE:${TARGET}>" "]==]" "\n"
|
||||||
|
" TEST_EXECUTOR" " [==[" "${crosscompiling_emulator}" "]==]" "\n"
|
||||||
|
" TEST_WORKING_DIR" " [==[" "${_WORKING_DIRECTORY}" "]==]" "\n"
|
||||||
|
" TEST_SPEC" " [==[" "${_TEST_SPEC}" "]==]" "\n"
|
||||||
|
" TEST_EXTRA_ARGS" " [==[" "${_EXTRA_ARGS}" "]==]" "\n"
|
||||||
|
" TEST_PROPERTIES" " [==[" "${_PROPERTIES}" "]==]" "\n"
|
||||||
|
" TEST_PREFIX" " [==[" "${_TEST_PREFIX}" "]==]" "\n"
|
||||||
|
" TEST_SUFFIX" " [==[" "${_TEST_SUFFIX}" "]==]" "\n"
|
||||||
|
" TEST_LIST" " [==[" "${_TEST_LIST}" "]==]" "\n"
|
||||||
|
" TEST_REPORTER" " [==[" "${_REPORTER}" "]==]" "\n"
|
||||||
|
" TEST_OUTPUT_DIR" " [==[" "${_OUTPUT_DIR}" "]==]" "\n"
|
||||||
|
" TEST_OUTPUT_PREFIX" " [==[" "${_OUTPUT_PREFIX}" "]==]" "\n"
|
||||||
|
" TEST_OUTPUT_SUFFIX" " [==[" "${_OUTPUT_SUFFIX}" "]==]" "\n"
|
||||||
|
" CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n"
|
||||||
|
" TEST_DL_PATHS" " [==[" "${_DL_PATHS}" "]==]" "\n"
|
||||||
|
" CTEST_FILE" " [==[" "${CTEST_FILE}" "]==]" "\n"
|
||||||
|
" )" "\n"
|
||||||
|
" endif()" "\n"
|
||||||
|
" include(\"${ctest_tests_file}\")" "\n"
|
||||||
|
"else()" "\n"
|
||||||
|
" add_test(${TARGET}_NOT_BUILT ${TARGET}_NOT_BUILT)" "\n"
|
||||||
|
"endif()" "\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GENERATE OUTPUT "${ctest_include_file}" CONTENT "${ctest_include_content}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
|
||||||
# Add discovered tests to directory TEST_INCLUDE_FILES
|
# Add discovered tests to directory TEST_INCLUDE_FILES
|
||||||
set_property(DIRECTORY
|
set_property(DIRECTORY
|
||||||
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
|
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
|
||||||
@@ -204,9 +265,7 @@ function(catch_discover_tests TARGET)
|
|||||||
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}"
|
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR "Cannot set more than one TEST_INCLUDE_FILE")
|
||||||
"Cannot set more than one TEST_INCLUDE_FILE"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -1,28 +1,6 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
set(prefix "${TEST_PREFIX}")
|
|
||||||
set(suffix "${TEST_SUFFIX}")
|
|
||||||
set(spec ${TEST_SPEC})
|
|
||||||
set(extra_args ${TEST_EXTRA_ARGS})
|
|
||||||
set(properties ${TEST_PROPERTIES})
|
|
||||||
set(reporter ${TEST_REPORTER})
|
|
||||||
set(output_dir ${TEST_OUTPUT_DIR})
|
|
||||||
set(output_prefix ${TEST_OUTPUT_PREFIX})
|
|
||||||
set(output_suffix ${TEST_OUTPUT_SUFFIX})
|
|
||||||
set(dl_paths ${TEST_DL_PATHS})
|
|
||||||
set(script)
|
|
||||||
set(suite)
|
|
||||||
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()
|
|
||||||
|
|
||||||
function(add_command NAME)
|
function(add_command NAME)
|
||||||
set(_args "")
|
set(_args "")
|
||||||
# use ARGV* instead of ARGN, because ARGN splits arrays into multiple arguments
|
# use ARGV* instead of ARGN, because ARGN splits arrays into multiple arguments
|
||||||
@@ -38,119 +16,177 @@ function(add_command NAME)
|
|||||||
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
|
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Run test executable to get list of available tests
|
function(catch_discover_tests_impl)
|
||||||
if(NOT EXISTS "${TEST_EXECUTABLE}")
|
|
||||||
message(FATAL_ERROR
|
cmake_parse_arguments(
|
||||||
"Specified test executable '${TEST_EXECUTABLE}' does not exist"
|
""
|
||||||
|
""
|
||||||
|
"TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_DL_PATHS;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE"
|
||||||
|
"TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR"
|
||||||
|
${ARGN}
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(dl_paths)
|
set(prefix "${_TEST_PREFIX}")
|
||||||
cmake_path(CONVERT "${dl_paths}" TO_NATIVE_PATH_LIST paths)
|
set(suffix "${_TEST_SUFFIX}")
|
||||||
set(ENV{${dl_paths_variable_name}} "${paths}")
|
set(spec ${_TEST_SPEC})
|
||||||
endif()
|
set(extra_args ${_TEST_EXTRA_ARGS})
|
||||||
|
set(properties ${_TEST_PROPERTIES})
|
||||||
|
set(reporter ${_TEST_REPORTER})
|
||||||
|
set(output_dir ${_TEST_OUTPUT_DIR})
|
||||||
|
set(output_prefix ${_TEST_OUTPUT_PREFIX})
|
||||||
|
set(output_suffix ${_TEST_OUTPUT_SUFFIX})
|
||||||
|
set(dl_paths ${_TEST_DL_PATHS})
|
||||||
|
set(script)
|
||||||
|
set(suite)
|
||||||
|
set(tests)
|
||||||
|
|
||||||
execute_process(
|
if(WIN32)
|
||||||
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-tests --verbosity quiet
|
set(dl_paths_variable_name PATH)
|
||||||
OUTPUT_VARIABLE output
|
elseif(APPLE)
|
||||||
RESULT_VARIABLE result
|
set(dl_paths_variable_name DYLD_LIBRARY_PATH)
|
||||||
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
else()
|
||||||
)
|
set(dl_paths_variable_name LD_LIBRARY_PATH)
|
||||||
if(NOT ${result} EQUAL 0)
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"Error running test executable '${TEST_EXECUTABLE}':\n"
|
|
||||||
" Result: ${result}\n"
|
|
||||||
" Output: ${output}\n"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
string(REPLACE "\n" ";" output "${output}")
|
|
||||||
|
|
||||||
# Run test executable to get list of available reporters
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-reporters
|
|
||||||
OUTPUT_VARIABLE reporters_output
|
|
||||||
RESULT_VARIABLE reporters_result
|
|
||||||
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
|
||||||
)
|
|
||||||
if(NOT ${reporters_result} EQUAL 0)
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"Error running test executable '${TEST_EXECUTABLE}':\n"
|
|
||||||
" Result: ${reporters_result}\n"
|
|
||||||
" Output: ${reporters_output}\n"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
string(FIND "${reporters_output}" "${reporter}" reporter_is_valid)
|
|
||||||
if(reporter AND ${reporter_is_valid} EQUAL -1)
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"\"${reporter}\" is not a valid reporter!\n"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Prepare reporter
|
|
||||||
if(reporter)
|
|
||||||
set(reporter_arg "--reporter ${reporter}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Prepare output dir
|
|
||||||
if(output_dir AND NOT IS_ABSOLUTE ${output_dir})
|
|
||||||
set(output_dir "${TEST_WORKING_DIR}/${output_dir}")
|
|
||||||
if(NOT EXISTS ${output_dir})
|
|
||||||
file(MAKE_DIRECTORY ${output_dir})
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
if(dl_paths)
|
# Run test executable to get list of available tests
|
||||||
foreach(path ${dl_paths})
|
if(NOT EXISTS "${_TEST_EXECUTABLE}")
|
||||||
cmake_path(NATIVE_PATH path native_path)
|
message(FATAL_ERROR
|
||||||
list(APPEND environment_modifications "${dl_paths_variable_name}=path_list_prepend:${native_path}")
|
"Specified test executable '${_TEST_EXECUTABLE}' does not exist"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(dl_paths)
|
||||||
|
cmake_path(CONVERT "${dl_paths}" TO_NATIVE_PATH_LIST paths)
|
||||||
|
set(ENV{${dl_paths_variable_name}} "${paths}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" ${spec} --list-tests --verbosity quiet
|
||||||
|
OUTPUT_VARIABLE output
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
|
||||||
|
)
|
||||||
|
if(NOT ${result} EQUAL 0)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Error running test executable '${_TEST_EXECUTABLE}':\n"
|
||||||
|
" Result: ${result}\n"
|
||||||
|
" Output: ${output}\n"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Make sure to escape ; (semicolons) in test names first, because
|
||||||
|
# that'd break the foreach loop for "Parse output" later and create
|
||||||
|
# wrongly splitted and thus failing test cases (false positives)
|
||||||
|
string(REPLACE ";" "\;" output "${output}")
|
||||||
|
string(REPLACE "\n" ";" output "${output}")
|
||||||
|
|
||||||
|
# Prepare reporter
|
||||||
|
if(reporter)
|
||||||
|
set(reporter_arg "--reporter ${reporter}")
|
||||||
|
|
||||||
|
# Run test executable to check whether reporter is available
|
||||||
|
# note that the use of --list-reporters is not the important part,
|
||||||
|
# we only want to check whether the execution succeeds with ${reporter_arg}
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} ${reporter_arg} --list-reporters
|
||||||
|
OUTPUT_VARIABLE reporter_check_output
|
||||||
|
RESULT_VARIABLE reporter_check_result
|
||||||
|
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
||||||
|
)
|
||||||
|
if(${reporter_check_result} EQUAL 255)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"\"${reporter}\" is not a valid reporter!\n"
|
||||||
|
)
|
||||||
|
elseif(NOT ${reporter_check_result} EQUAL 0)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Error running test executable '${TEST_EXECUTABLE}':\n"
|
||||||
|
" Result: ${reporter_check_result}\n"
|
||||||
|
" Output: ${reporter_check_output}\n"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Prepare output dir
|
||||||
|
if(output_dir AND NOT IS_ABSOLUTE ${output_dir})
|
||||||
|
set(output_dir "${_TEST_WORKING_DIR}/${output_dir}")
|
||||||
|
if(NOT EXISTS ${output_dir})
|
||||||
|
file(MAKE_DIRECTORY ${output_dir})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(dl_paths)
|
||||||
|
foreach(path ${dl_paths})
|
||||||
|
cmake_path(NATIVE_PATH path native_path)
|
||||||
|
list(APPEND environment_modifications "${dl_paths_variable_name}=path_list_prepend:${native_path}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Parse output
|
||||||
|
foreach(line ${output})
|
||||||
|
set(test "${line}")
|
||||||
|
# Escape characters in test case names that would be parsed by Catch2
|
||||||
|
# Note that the \ escaping must happen FIRST! Do not change the order.
|
||||||
|
set(test_name "${test}")
|
||||||
|
foreach(char \\ , [ ])
|
||||||
|
string(REPLACE ${char} "\\${char}" test_name "${test_name}")
|
||||||
|
endforeach(char)
|
||||||
|
# ...add output dir
|
||||||
|
if(output_dir)
|
||||||
|
string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean "${test_name}")
|
||||||
|
set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ...and add to script
|
||||||
|
add_command(add_test
|
||||||
|
"${prefix}${test}${suffix}"
|
||||||
|
${_TEST_EXECUTOR}
|
||||||
|
"${_TEST_EXECUTABLE}"
|
||||||
|
"${test_name}"
|
||||||
|
${extra_args}
|
||||||
|
"${reporter_arg}"
|
||||||
|
"${output_dir_arg}"
|
||||||
|
)
|
||||||
|
add_command(set_tests_properties
|
||||||
|
"${prefix}${test}${suffix}"
|
||||||
|
PROPERTIES
|
||||||
|
WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
|
||||||
|
${properties}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(environment_modifications)
|
||||||
|
add_command(set_tests_properties
|
||||||
|
"${prefix}${test}${suffix}"
|
||||||
|
PROPERTIES
|
||||||
|
ENVIRONMENT_MODIFICATION "${environment_modifications}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND tests "${prefix}${test}${suffix}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# Create a list of all discovered tests, which users may use to e.g. set
|
||||||
|
# properties on the tests
|
||||||
|
add_command(set ${_TEST_LIST} ${tests})
|
||||||
|
|
||||||
|
# Write CTest script
|
||||||
|
file(WRITE "${_CTEST_FILE}" "${script}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(CMAKE_SCRIPT_MODE_FILE)
|
||||||
|
catch_discover_tests_impl(
|
||||||
|
TEST_EXECUTABLE ${TEST_EXECUTABLE}
|
||||||
|
TEST_EXECUTOR ${TEST_EXECUTOR}
|
||||||
|
TEST_WORKING_DIR ${TEST_WORKING_DIR}
|
||||||
|
TEST_SPEC ${TEST_SPEC}
|
||||||
|
TEST_EXTRA_ARGS ${TEST_EXTRA_ARGS}
|
||||||
|
TEST_PROPERTIES ${TEST_PROPERTIES}
|
||||||
|
TEST_PREFIX ${TEST_PREFIX}
|
||||||
|
TEST_SUFFIX ${TEST_SUFFIX}
|
||||||
|
TEST_LIST ${TEST_LIST}
|
||||||
|
TEST_REPORTER ${TEST_REPORTER}
|
||||||
|
TEST_OUTPUT_DIR ${TEST_OUTPUT_DIR}
|
||||||
|
TEST_OUTPUT_PREFIX ${TEST_OUTPUT_PREFIX}
|
||||||
|
TEST_OUTPUT_SUFFIX ${TEST_OUTPUT_SUFFIX}
|
||||||
|
TEST_DL_PATHS ${TEST_DL_PATHS}
|
||||||
|
CTEST_FILE ${CTEST_FILE}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Parse output
|
|
||||||
foreach(line ${output})
|
|
||||||
set(test ${line})
|
|
||||||
# Escape characters in test case names that would be parsed by Catch2
|
|
||||||
set(test_name ${test})
|
|
||||||
foreach(char , [ ])
|
|
||||||
string(REPLACE ${char} "\\${char}" test_name ${test_name})
|
|
||||||
endforeach(char)
|
|
||||||
# ...add output dir
|
|
||||||
if(output_dir)
|
|
||||||
string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean ${test_name})
|
|
||||||
set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# ...and add to script
|
|
||||||
add_command(add_test
|
|
||||||
"${prefix}${test}${suffix}"
|
|
||||||
${TEST_EXECUTOR}
|
|
||||||
"${TEST_EXECUTABLE}"
|
|
||||||
"${test_name}"
|
|
||||||
${extra_args}
|
|
||||||
"${reporter_arg}"
|
|
||||||
"${output_dir_arg}"
|
|
||||||
)
|
|
||||||
add_command(set_tests_properties
|
|
||||||
"${prefix}${test}${suffix}"
|
|
||||||
PROPERTIES
|
|
||||||
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
|
|
||||||
${properties}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(environment_modifications)
|
|
||||||
add_command(set_tests_properties
|
|
||||||
"${prefix}${test}${suffix}"
|
|
||||||
PROPERTIES
|
|
||||||
ENVIRONMENT_MODIFICATION "${environment_modifications}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND tests "${prefix}${test}${suffix}")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Create a list of all discovered tests, which users may use to e.g. set
|
|
||||||
# properties on the tests
|
|
||||||
add_command(set ${TEST_LIST} ${tests})
|
|
||||||
|
|
||||||
# Write CTest script
|
|
||||||
file(WRITE "${CTEST_FILE}" "${script}")
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# Copyright Catch2 Authors
|
# Copyright Catch2 Authors
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
# SPDX-License-Identifier: BSL-1.0
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -46,7 +46,7 @@ function(catch_add_sharded_tests TARGET)
|
|||||||
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
|
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(shard_impl_script_file "${CMAKE_CURRENT_LIST_DIR}/CatchShardTestsImpl.cmake")
|
set(shard_impl_script_file "${_CATCH_DISCOVER_SHARD_TESTS_IMPL_SCRIPT}")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${TARGET} POST_BUILD
|
TARGET ${TARGET} POST_BUILD
|
||||||
@@ -64,3 +64,11 @@ function(catch_add_sharded_tests TARGET)
|
|||||||
|
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
set(_CATCH_DISCOVER_SHARD_TESTS_IMPL_SCRIPT
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/CatchShardTestsImpl.cmake
|
||||||
|
CACHE INTERNAL "Catch2 full path to CatchShardTestsImpl.cmake helper file"
|
||||||
|
)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# Copyright Catch2 Authors
|
# Copyright Catch2 Authors
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
# SPDX-License-Identifier: BSL-1.0
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
10
meson.build
10
meson.build
@@ -1,6 +1,6 @@
|
|||||||
# Copyright Catch2 Authors
|
# Copyright Catch2 Authors
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
# SPDX-License-Identifier: BSL-1.0
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -8,10 +8,12 @@
|
|||||||
project(
|
project(
|
||||||
'catch2',
|
'catch2',
|
||||||
'cpp',
|
'cpp',
|
||||||
version: '3.1.1', # CML version placeholder, don't delete
|
version: '3.4.0', # CML version placeholder, don't delete
|
||||||
license: 'BSL-1.0',
|
license: 'BSL-1.0',
|
||||||
meson_version: '>=0.49.0',
|
meson_version: '>=0.54.1',
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('src/catch2')
|
subdir('src/catch2')
|
||||||
subdir('tests')
|
if get_option('tests')
|
||||||
|
subdir('tests')
|
||||||
|
endif
|
||||||
|
1
meson_options.txt
Normal file
1
meson_options.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
option('tests', type: 'boolean', value: true, description: 'Build the unit tests')
|
@@ -7,293 +7,338 @@ include(CatchMiscFunctions)
|
|||||||
set(Catch2_GUID_CMAKE "8d538cbe-01bf-4a2e-a98a-6c368fdf13d7" CACHE INTERNAL "Project GUID")
|
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")
|
set(Catch2WithMain_GUID_CMAKE "8bd3552a-2cfb-4a59-ab15-2031b97ada1e" CACHE INTERNAL "Project GUID")
|
||||||
|
|
||||||
# Please keep these ordered alphabetically
|
|
||||||
set(BENCHMARK_HEADERS
|
set(BENCHMARK_HEADERS
|
||||||
${SOURCES_DIR}/benchmark/catch_benchmark.hpp
|
${SOURCES_DIR}/benchmark/catch_benchmark.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_benchmark_all.hpp
|
${SOURCES_DIR}/benchmark/catch_benchmark_all.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_chronometer.hpp
|
${SOURCES_DIR}/benchmark/catch_chronometer.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_clock.hpp
|
${SOURCES_DIR}/benchmark/catch_clock.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_constructor.hpp
|
${SOURCES_DIR}/benchmark/catch_constructor.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_environment.hpp
|
${SOURCES_DIR}/benchmark/catch_environment.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_estimate.hpp
|
${SOURCES_DIR}/benchmark/catch_estimate.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_execution_plan.hpp
|
${SOURCES_DIR}/benchmark/catch_execution_plan.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_optimizer.hpp
|
${SOURCES_DIR}/benchmark/catch_optimizer.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_outlier_classification.hpp
|
${SOURCES_DIR}/benchmark/catch_outlier_classification.hpp
|
||||||
${SOURCES_DIR}/benchmark/catch_sample_analysis.hpp
|
${SOURCES_DIR}/benchmark/catch_sample_analysis.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_analyse.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_analyse.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_complete_invoke.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_benchmark_stats.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_estimate_clock.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_benchmark_stats_fwd.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_measure.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_complete_invoke.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_repeat.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_estimate_clock.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_measure.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_stats.hpp
|
${SOURCES_DIR}/benchmark/detail/catch_repeat.hpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_timing.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
|
set(BENCHMARK_SOURCES
|
||||||
${SOURCES_DIR}/benchmark/catch_chronometer.cpp
|
${SOURCES_DIR}/benchmark/catch_chronometer.cpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp
|
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp
|
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp
|
||||||
${SOURCES_DIR}/benchmark/detail/catch_stats.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
|
set(IMPL_HEADERS
|
||||||
"${CMAKE_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
"${PROJECT_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
||||||
"${SOURCES_DIR}/catch_user_config.hpp.in"
|
${SOURCES_DIR}/catch_user_config.hpp.in
|
||||||
${SOURCES_DIR}/catch_all.hpp
|
${SOURCES_DIR}/catch_all.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_all.hpp
|
${SOURCES_DIR}/catch_approx.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators_all.hpp
|
${SOURCES_DIR}/catch_assertion_info.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_all.hpp
|
${SOURCES_DIR}/catch_assertion_result.hpp
|
||||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp
|
${SOURCES_DIR}/catch_config.hpp
|
||||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.hpp
|
${SOURCES_DIR}/catch_get_random_seed.hpp
|
||||||
${SOURCES_DIR}/internal/catch_console_width.hpp
|
${SOURCES_DIR}/catch_message.hpp
|
||||||
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
${SOURCES_DIR}/catch_section_info.hpp
|
||||||
${SOURCES_DIR}/internal/catch_noncopyable.hpp
|
${SOURCES_DIR}/catch_session.hpp
|
||||||
${SOURCES_DIR}/catch_approx.hpp
|
${SOURCES_DIR}/catch_tag_alias.hpp
|
||||||
${SOURCES_DIR}/internal/catch_assertion_handler.hpp
|
${SOURCES_DIR}/catch_tag_alias_autoregistrar.hpp
|
||||||
${SOURCES_DIR}/catch_assertion_info.hpp
|
${SOURCES_DIR}/catch_template_test_macros.hpp
|
||||||
${SOURCES_DIR}/catch_assertion_result.hpp
|
${SOURCES_DIR}/catch_test_case_info.hpp
|
||||||
${SOURCES_DIR}/internal/catch_test_macro_impl.hpp
|
${SOURCES_DIR}/catch_test_macros.hpp
|
||||||
${SOURCES_DIR}/internal/catch_test_failure_exception.hpp
|
${SOURCES_DIR}/catch_test_spec.hpp
|
||||||
${SOURCES_DIR}/internal/catch_case_sensitive.hpp
|
${SOURCES_DIR}/catch_timer.hpp
|
||||||
${SOURCES_DIR}/internal/catch_clara.hpp
|
${SOURCES_DIR}/catch_tostring.hpp
|
||||||
${SOURCES_DIR}/internal/catch_commandline.hpp
|
${SOURCES_DIR}/catch_totals.hpp
|
||||||
${SOURCES_DIR}/internal/catch_source_line_info.hpp
|
${SOURCES_DIR}/catch_translate_exception.hpp
|
||||||
${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
|
${SOURCES_DIR}/catch_version.hpp
|
||||||
${SOURCES_DIR}/catch_config.hpp
|
${SOURCES_DIR}/catch_version_macros.hpp
|
||||||
${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
|
${SOURCES_DIR}/internal/catch_assertion_handler.hpp
|
||||||
${SOURCES_DIR}/internal/catch_config_counter.hpp
|
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.hpp
|
||||||
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
${SOURCES_DIR}/internal/catch_case_sensitive.hpp
|
||||||
${SOURCES_DIR}/internal/catch_config_wchar.hpp
|
${SOURCES_DIR}/internal/catch_clara.hpp
|
||||||
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
${SOURCES_DIR}/internal/catch_commandline.hpp
|
||||||
${SOURCES_DIR}/internal/catch_context.hpp
|
${SOURCES_DIR}/internal/catch_compare_traits.hpp
|
||||||
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
|
||||||
${SOURCES_DIR}/internal/catch_debugger.hpp
|
${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
|
||||||
${SOURCES_DIR}/internal/catch_decomposer.hpp
|
${SOURCES_DIR}/internal/catch_config_counter.hpp
|
||||||
${SOURCES_DIR}/internal/catch_enforce.hpp
|
${SOURCES_DIR}/internal/catch_config_static_analysis_support.hpp
|
||||||
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
|
||||||
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
${SOURCES_DIR}/internal/catch_config_wchar.hpp
|
||||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
|
${SOURCES_DIR}/internal/catch_console_colour.hpp
|
||||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
|
${SOURCES_DIR}/internal/catch_console_width.hpp
|
||||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.hpp
|
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
||||||
${SOURCES_DIR}/internal/catch_istream.hpp
|
${SOURCES_DIR}/internal/catch_context.hpp
|
||||||
${SOURCES_DIR}/internal/catch_unique_name.hpp
|
${SOURCES_DIR}/internal/catch_debug_console.hpp
|
||||||
${SOURCES_DIR}/internal/catch_sharding.hpp
|
${SOURCES_DIR}/internal/catch_debugger.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generator_exception.hpp
|
${SOURCES_DIR}/internal/catch_decomposer.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators.hpp
|
${SOURCES_DIR}/internal/catch_enforce.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators_adapters.hpp
|
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators_random.hpp
|
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators_range.hpp
|
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.hpp
|
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.hpp
|
${SOURCES_DIR}/internal/catch_floating_point_helpers.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_enum_values_registry.hpp
|
${SOURCES_DIR}/internal/catch_getenv.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.hpp
|
${SOURCES_DIR}/internal/catch_istream.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.hpp
|
${SOURCES_DIR}/internal/catch_is_permutation.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.hpp
|
${SOURCES_DIR}/internal/catch_lazy_expr.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.hpp
|
${SOURCES_DIR}/internal/catch_leak_detector.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.hpp
|
${SOURCES_DIR}/internal/catch_list.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.hpp
|
${SOURCES_DIR}/internal/catch_logical_traits.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_tag_alias_registry.hpp
|
${SOURCES_DIR}/internal/catch_message_info.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp
|
${SOURCES_DIR}/internal/catch_meta.hpp
|
||||||
${SOURCES_DIR}/internal/catch_lazy_expr.hpp
|
${SOURCES_DIR}/internal/catch_move_and_forward.hpp
|
||||||
${SOURCES_DIR}/internal/catch_leak_detector.hpp
|
${SOURCES_DIR}/internal/catch_noncopyable.hpp
|
||||||
${SOURCES_DIR}/internal/catch_list.hpp
|
${SOURCES_DIR}/internal/catch_optional.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers.hpp
|
${SOURCES_DIR}/internal/catch_output_redirect.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_container_properties.hpp
|
${SOURCES_DIR}/internal/catch_parse_numbers.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_contains.hpp
|
${SOURCES_DIR}/internal/catch_platform.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_exception.hpp
|
${SOURCES_DIR}/internal/catch_polyfills.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_floating_point.hpp
|
${SOURCES_DIR}/internal/catch_preprocessor.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_predicate.hpp
|
${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.hpp
|
${SOURCES_DIR}/internal/catch_random_number_generator.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_string.hpp
|
${SOURCES_DIR}/internal/catch_random_seed_generation.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_templated.hpp
|
${SOURCES_DIR}/internal/catch_reporter_registry.hpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_vector.hpp
|
${SOURCES_DIR}/internal/catch_reporter_spec_parser.hpp
|
||||||
${SOURCES_DIR}/catch_message.hpp
|
${SOURCES_DIR}/internal/catch_result_type.hpp
|
||||||
${SOURCES_DIR}/internal/catch_message_info.hpp
|
${SOURCES_DIR}/internal/catch_reusable_string_stream.hpp
|
||||||
${SOURCES_DIR}/internal/catch_meta.hpp
|
${SOURCES_DIR}/internal/catch_run_context.hpp
|
||||||
${SOURCES_DIR}/internal/catch_move_and_forward.hpp
|
${SOURCES_DIR}/internal/catch_section.hpp
|
||||||
${SOURCES_DIR}/internal/catch_optional.hpp
|
${SOURCES_DIR}/internal/catch_sharding.hpp
|
||||||
${SOURCES_DIR}/internal/catch_output_redirect.hpp
|
${SOURCES_DIR}/internal/catch_singletons.hpp
|
||||||
${SOURCES_DIR}/internal/catch_platform.hpp
|
${SOURCES_DIR}/internal/catch_source_line_info.hpp
|
||||||
${SOURCES_DIR}/internal/catch_polyfills.hpp
|
${SOURCES_DIR}/internal/catch_startup_exception_registry.hpp
|
||||||
${SOURCES_DIR}/internal/catch_preprocessor.hpp
|
${SOURCES_DIR}/internal/catch_stdstreams.hpp
|
||||||
${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp
|
${SOURCES_DIR}/internal/catch_stream_end_stop.hpp
|
||||||
${SOURCES_DIR}/internal/catch_random_number_generator.hpp
|
${SOURCES_DIR}/internal/catch_string_manip.hpp
|
||||||
${SOURCES_DIR}/internal/catch_random_seed_generation.hpp
|
${SOURCES_DIR}/internal/catch_stringref.hpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_registry.hpp
|
${SOURCES_DIR}/internal/catch_tag_alias_registry.hpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.hpp
|
${SOURCES_DIR}/internal/catch_template_test_registry.hpp
|
||||||
${SOURCES_DIR}/internal/catch_result_type.hpp
|
${SOURCES_DIR}/internal/catch_test_case_info_hasher.hpp
|
||||||
${SOURCES_DIR}/internal/catch_run_context.hpp
|
${SOURCES_DIR}/internal/catch_test_case_registry_impl.hpp
|
||||||
${SOURCES_DIR}/internal/catch_section.hpp
|
${SOURCES_DIR}/internal/catch_test_case_tracker.hpp
|
||||||
${SOURCES_DIR}/internal/catch_stdstreams.hpp
|
${SOURCES_DIR}/internal/catch_test_failure_exception.hpp
|
||||||
${SOURCES_DIR}/catch_section_info.hpp
|
${SOURCES_DIR}/internal/catch_test_macro_impl.hpp
|
||||||
${SOURCES_DIR}/catch_session.hpp
|
${SOURCES_DIR}/internal/catch_test_registry.hpp
|
||||||
${SOURCES_DIR}/internal/catch_singletons.hpp
|
${SOURCES_DIR}/internal/catch_test_run_info.hpp
|
||||||
${SOURCES_DIR}/internal/catch_startup_exception_registry.hpp
|
${SOURCES_DIR}/internal/catch_test_spec_parser.hpp
|
||||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.hpp
|
${SOURCES_DIR}/internal/catch_textflow.hpp
|
||||||
${SOURCES_DIR}/internal/catch_stream_end_stop.hpp
|
${SOURCES_DIR}/internal/catch_to_string.hpp
|
||||||
${SOURCES_DIR}/internal/catch_string_manip.hpp
|
${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp
|
||||||
${SOURCES_DIR}/internal/catch_stringref.hpp
|
${SOURCES_DIR}/internal/catch_unique_name.hpp
|
||||||
${SOURCES_DIR}/catch_tag_alias.hpp
|
${SOURCES_DIR}/internal/catch_unique_ptr.hpp
|
||||||
${SOURCES_DIR}/catch_get_random_seed.hpp
|
${SOURCES_DIR}/internal/catch_void_type.hpp
|
||||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.hpp
|
${SOURCES_DIR}/internal/catch_wildcard_pattern.hpp
|
||||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.hpp
|
${SOURCES_DIR}/internal/catch_windows_h_proxy.hpp
|
||||||
${SOURCES_DIR}/catch_test_case_info.hpp
|
${SOURCES_DIR}/internal/catch_xmlwriter.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_SOURCES
|
set(IMPL_SOURCES
|
||||||
${SOURCES_DIR}/catch_approx.cpp
|
${SOURCES_DIR}/catch_approx.cpp
|
||||||
${SOURCES_DIR}/internal/catch_assertion_handler.cpp
|
${SOURCES_DIR}/catch_assertion_result.cpp
|
||||||
${SOURCES_DIR}/catch_assertion_result.cpp
|
${SOURCES_DIR}/catch_config.cpp
|
||||||
${SOURCES_DIR}/internal/catch_clara.cpp
|
${SOURCES_DIR}/catch_get_random_seed.cpp
|
||||||
${SOURCES_DIR}/internal/catch_commandline.cpp
|
${SOURCES_DIR}/catch_message.cpp
|
||||||
${SOURCES_DIR}/internal/catch_source_line_info.cpp
|
${SOURCES_DIR}/catch_registry_hub.cpp
|
||||||
${SOURCES_DIR}/catch_config.cpp
|
${SOURCES_DIR}/catch_session.cpp
|
||||||
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp
|
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
||||||
${SOURCES_DIR}/internal/catch_console_colour.cpp
|
${SOURCES_DIR}/catch_test_case_info.cpp
|
||||||
${SOURCES_DIR}/internal/catch_context.cpp
|
${SOURCES_DIR}/catch_test_spec.cpp
|
||||||
${SOURCES_DIR}/internal/catch_debug_console.cpp
|
${SOURCES_DIR}/catch_timer.cpp
|
||||||
${SOURCES_DIR}/internal/catch_debugger.cpp
|
${SOURCES_DIR}/catch_tostring.cpp
|
||||||
${SOURCES_DIR}/internal/catch_enforce.cpp
|
${SOURCES_DIR}/catch_totals.cpp
|
||||||
${SOURCES_DIR}/internal/catch_enum_values_registry.cpp
|
${SOURCES_DIR}/catch_translate_exception.cpp
|
||||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
|
${SOURCES_DIR}/catch_version.cpp
|
||||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
|
${SOURCES_DIR}/internal/catch_assertion_handler.cpp
|
||||||
${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp
|
${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp
|
||||||
${SOURCES_DIR}/internal/catch_istream.cpp
|
${SOURCES_DIR}/internal/catch_clara.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.cpp
|
${SOURCES_DIR}/internal/catch_commandline.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
${SOURCES_DIR}/internal/catch_console_colour.cpp
|
||||||
${SOURCES_DIR}/internal/catch_list.cpp
|
${SOURCES_DIR}/internal/catch_context.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_floating_point.cpp
|
${SOURCES_DIR}/internal/catch_debug_console.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.cpp
|
${SOURCES_DIR}/internal/catch_debugger.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_string.cpp
|
${SOURCES_DIR}/internal/catch_decomposer.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_templated.cpp
|
${SOURCES_DIR}/internal/catch_enforce.cpp
|
||||||
${SOURCES_DIR}/catch_message.cpp
|
${SOURCES_DIR}/internal/catch_enum_values_registry.cpp
|
||||||
${SOURCES_DIR}/internal/catch_output_redirect.cpp
|
${SOURCES_DIR}/internal/catch_errno_guard.cpp
|
||||||
${SOURCES_DIR}/catch_registry_hub.cpp
|
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
|
||||||
${SOURCES_DIR}/internal/catch_random_number_generator.cpp
|
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
|
||||||
${SOURCES_DIR}/internal/catch_random_seed_generation.cpp
|
${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_registry.cpp
|
${SOURCES_DIR}/internal/catch_getenv.cpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp
|
${SOURCES_DIR}/internal/catch_istream.cpp
|
||||||
${SOURCES_DIR}/internal/catch_result_type.cpp
|
${SOURCES_DIR}/internal/catch_lazy_expr.cpp
|
||||||
${SOURCES_DIR}/internal/catch_run_context.cpp
|
${SOURCES_DIR}/internal/catch_leak_detector.cpp
|
||||||
${SOURCES_DIR}/internal/catch_section.cpp
|
${SOURCES_DIR}/internal/catch_list.cpp
|
||||||
${SOURCES_DIR}/internal/catch_stdstreams.cpp
|
${SOURCES_DIR}/internal/catch_message_info.cpp
|
||||||
${SOURCES_DIR}/catch_session.cpp
|
${SOURCES_DIR}/internal/catch_output_redirect.cpp
|
||||||
${SOURCES_DIR}/internal/catch_singletons.cpp
|
${SOURCES_DIR}/internal/catch_parse_numbers.cpp
|
||||||
${SOURCES_DIR}/internal/catch_reusable_string_stream.cpp
|
${SOURCES_DIR}/internal/catch_polyfills.cpp
|
||||||
${SOURCES_DIR}/internal/catch_stringref.cpp
|
${SOURCES_DIR}/internal/catch_random_number_generator.cpp
|
||||||
${SOURCES_DIR}/internal/catch_string_manip.cpp
|
${SOURCES_DIR}/internal/catch_random_seed_generation.cpp
|
||||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
|
${SOURCES_DIR}/internal/catch_reporter_registry.cpp
|
||||||
${SOURCES_DIR}/catch_test_case_info.cpp
|
${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp
|
||||||
${SOURCES_DIR}/internal/catch_test_case_registry_impl.cpp
|
${SOURCES_DIR}/internal/catch_result_type.cpp
|
||||||
${SOURCES_DIR}/internal/catch_test_case_tracker.cpp
|
${SOURCES_DIR}/internal/catch_reusable_string_stream.cpp
|
||||||
${SOURCES_DIR}/internal/catch_test_registry.cpp
|
${SOURCES_DIR}/internal/catch_run_context.cpp
|
||||||
${SOURCES_DIR}/internal/catch_textflow.cpp
|
${SOURCES_DIR}/internal/catch_section.cpp
|
||||||
${SOURCES_DIR}/catch_test_spec.cpp
|
${SOURCES_DIR}/internal/catch_singletons.cpp
|
||||||
${SOURCES_DIR}/internal/catch_test_spec_parser.cpp
|
${SOURCES_DIR}/internal/catch_source_line_info.cpp
|
||||||
${SOURCES_DIR}/catch_timer.cpp
|
${SOURCES_DIR}/internal/catch_startup_exception_registry.cpp
|
||||||
${SOURCES_DIR}/catch_tostring.cpp
|
${SOURCES_DIR}/internal/catch_stdstreams.cpp
|
||||||
${SOURCES_DIR}/catch_totals.cpp
|
${SOURCES_DIR}/internal/catch_string_manip.cpp
|
||||||
${SOURCES_DIR}/catch_version.cpp
|
${SOURCES_DIR}/internal/catch_stringref.cpp
|
||||||
${SOURCES_DIR}/internal/catch_wildcard_pattern.cpp
|
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
|
||||||
${SOURCES_DIR}/internal/catch_xmlwriter.cpp
|
${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp
|
||||||
${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp
|
${SOURCES_DIR}/internal/catch_test_case_registry_impl.cpp
|
||||||
${SOURCES_DIR}/generators/catch_generators_random.cpp
|
${SOURCES_DIR}/internal/catch_test_case_tracker.cpp
|
||||||
${SOURCES_DIR}/generators/catch_generator_exception.cpp
|
${SOURCES_DIR}/internal/catch_test_failure_exception.cpp
|
||||||
${SOURCES_DIR}/generators/catch_generators.cpp
|
${SOURCES_DIR}/internal/catch_test_registry.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers.cpp
|
${SOURCES_DIR}/internal/catch_test_spec_parser.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_container_properties.cpp
|
${SOURCES_DIR}/internal/catch_textflow.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_exception.cpp
|
${SOURCES_DIR}/internal/catch_uncaught_exceptions.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_predicate.cpp
|
${SOURCES_DIR}/internal/catch_wildcard_pattern.cpp
|
||||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.cpp
|
${SOURCES_DIR}/internal/catch_xmlwriter.cpp
|
||||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
|
||||||
${SOURCES_DIR}/catch_get_random_seed.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
|
|
||||||
)
|
)
|
||||||
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_tag_alias_registry.hpp
|
||||||
|
${SOURCES_DIR}/interfaces/catch_interfaces_test_invoker.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_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_range_equals.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
|
set(REPORTER_HEADERS
|
||||||
${SOURCES_DIR}/reporters/catch_reporters_all.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_automake.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_automake.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_common_base.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_common_base.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_compact.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_compact.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_console.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_console.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_junit.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_junit.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_multi.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_multi.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_registrars.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_registrars.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_tap.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_tap.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp
|
${SOURCES_DIR}/reporters/catch_reporter_xml.hpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_xml.hpp
|
${SOURCES_DIR}/reporters/catch_reporters_all.hpp
|
||||||
)
|
)
|
||||||
set(REPORTER_SOURCES
|
set(REPORTER_SOURCES
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_automake.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_automake.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_common_base.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_common_base.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_compact.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_compact.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_console.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_console.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_event_listener.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_helpers.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_junit.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_junit.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_multi.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_multi.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_registrars.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_registrars.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_tap.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_tap.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp
|
||||||
${SOURCES_DIR}/reporters/catch_reporter_xml.cpp
|
${SOURCES_DIR}/reporters/catch_reporter_xml.cpp
|
||||||
)
|
)
|
||||||
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
||||||
|
|
||||||
add_library(Catch2
|
set(ALL_FILES
|
||||||
|
${BENCHMARK_FILES}
|
||||||
|
${GENERATOR_FILES}
|
||||||
${REPORTER_FILES}
|
${REPORTER_FILES}
|
||||||
|
${INTERFACE_FILES}
|
||||||
${INTERNAL_FILES}
|
${INTERNAL_FILES}
|
||||||
${BENCHMARK_HEADERS}
|
${MATCHER_FILES}
|
||||||
${BENCHMARK_SOURCES}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(FILTERED_FILES ${ALL_FILES})
|
||||||
|
list(REMOVE_ITEM FILTERED_FILES "${PROJECT_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp")
|
||||||
|
source_group(
|
||||||
|
TREE ${SOURCES_DIR}
|
||||||
|
PREFIX sources
|
||||||
|
FILES ${FILTERED_FILES}
|
||||||
|
)
|
||||||
|
source_group("generated headers"
|
||||||
|
FILES
|
||||||
|
"${PROJECT_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(Catch2 ${ALL_FILES})
|
||||||
add_build_reproducibility_settings(Catch2)
|
add_build_reproducibility_settings(Catch2)
|
||||||
add_library(Catch2::Catch2 ALIAS Catch2)
|
add_library(Catch2::Catch2 ALIAS Catch2)
|
||||||
|
|
||||||
@@ -301,7 +346,7 @@ if (ANDROID)
|
|||||||
target_link_libraries(Catch2 INTERFACE log)
|
target_link_libraries(Catch2 INTERFACE log)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(Catch2 PROPERTIES
|
set_target_properties(Catch2 PROPERTIES
|
||||||
DEBUG_POSTFIX "d"
|
DEBUG_POSTFIX "d"
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_VERSION})
|
SOVERSION ${PROJECT_VERSION})
|
||||||
@@ -333,13 +378,13 @@ target_compile_features(Catch2
|
|||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
"${SOURCES_DIR}/catch_user_config.hpp.in"
|
"${SOURCES_DIR}/catch_user_config.hpp.in"
|
||||||
"${CMAKE_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
"${PROJECT_BINARY_DIR}/generated-includes/catch2/catch_user_config.hpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(Catch2
|
target_include_directories(Catch2
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
||||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated-includes>
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/generated-includes>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -366,7 +411,7 @@ if (NOT_SUBPROJECT)
|
|||||||
Catch2WithMain
|
Catch2WithMain
|
||||||
EXPORT
|
EXPORT
|
||||||
Catch2Targets
|
Catch2Targets
|
||||||
LIBRARY DESTINATION
|
LIBRARY DESTINATION
|
||||||
${CMAKE_INSTALL_LIBDIR}
|
${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION
|
ARCHIVE DESTINATION
|
||||||
${CMAKE_INSTALL_LIBDIR}
|
${CMAKE_INSTALL_LIBDIR}
|
||||||
@@ -387,7 +432,7 @@ if (NOT_SUBPROJECT)
|
|||||||
install(
|
install(
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
"${SOURCES_DIR}"
|
"${SOURCES_DIR}"
|
||||||
"${CMAKE_BINARY_DIR}/generated-includes/catch2" # Also install the generated header
|
"${PROJECT_BINARY_DIR}/generated-includes/catch2" # Also install the generated header
|
||||||
DESTINATION
|
DESTINATION
|
||||||
"${CMAKE_INSTALL_INCLUDEDIR}"
|
"${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
@@ -401,17 +446,14 @@ endif()
|
|||||||
if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||||
add_library(Catch2_buildall_interface INTERFACE)
|
add_library(Catch2_buildall_interface INTERFACE)
|
||||||
target_sources(Catch2_buildall_interface INTERFACE
|
target_sources(Catch2_buildall_interface INTERFACE
|
||||||
${REPORTER_FILES}
|
${ALL_FILES}
|
||||||
${INTERNAL_FILES}
|
|
||||||
${BENCHMARK_HEADERS}
|
|
||||||
${BENCHMARK_SOURCES}
|
|
||||||
# Also include main entry point
|
# Also include main entry point
|
||||||
${SOURCES_DIR}/internal/catch_main.cpp
|
${SOURCES_DIR}/internal/catch_main.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(Catch2_buildall_interface
|
target_include_directories(Catch2_buildall_interface
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
||||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated-includes>
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/generated-includes>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
)
|
)
|
||||||
target_compile_definitions(Catch2_buildall_interface
|
target_compile_definitions(Catch2_buildall_interface
|
||||||
@@ -451,12 +493,10 @@ set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|
|||||||
# so we want to check & warn users if they do this. However, we won't abort
|
# so we want to check & warn users if they do this. However, we won't abort
|
||||||
# the configuration step so that we don't have to also provide an override.
|
# the configuration step so that we don't have to also provide an override.
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
if (MSVC)
|
set_target_properties(Catch2 Catch2WithMain
|
||||||
set_target_properties(Catch2 Catch2WithMain
|
PROPERTIES
|
||||||
PROPERTIES
|
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
||||||
WINDOWS_EXPORT_ALL_SYMBOLS ON
|
)
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_target_property(_VisPreset Catch2 CXX_VISIBILITY_PRESET)
|
get_target_property(_VisPreset Catch2 CXX_VISIBILITY_PRESET)
|
||||||
if (NOT MSVC AND _VisPreset STREQUAL "hidden")
|
if (NOT MSVC AND _VisPreset STREQUAL "hidden")
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -10,23 +10,27 @@
|
|||||||
#ifndef CATCH_BENCHMARK_HPP_INCLUDED
|
#ifndef CATCH_BENCHMARK_HPP_INCLUDED
|
||||||
#define CATCH_BENCHMARK_HPP_INCLUDED
|
#define CATCH_BENCHMARK_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
#include <catch2/catch_user_config.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/internal/catch_context.hpp>
|
#include <catch2/internal/catch_context.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
|
||||||
#include <catch2/internal/catch_unique_name.hpp>
|
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
#include <catch2/benchmark/catch_chronometer.hpp>
|
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||||
|
#include <catch2/internal/catch_unique_name.hpp>
|
||||||
|
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||||
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||||
|
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
||||||
|
#include <catch2/benchmark/detail/catch_benchmark_stats.hpp>
|
||||||
#include <catch2/benchmark/catch_clock.hpp>
|
#include <catch2/benchmark/catch_clock.hpp>
|
||||||
#include <catch2/benchmark/catch_environment.hpp>
|
#include <catch2/benchmark/catch_environment.hpp>
|
||||||
#include <catch2/benchmark/catch_execution_plan.hpp>
|
#include <catch2/benchmark/catch_execution_plan.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_estimate_clock.hpp>
|
#include <catch2/benchmark/detail/catch_estimate_clock.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
|
||||||
#include <catch2/benchmark/detail/catch_analyse.hpp>
|
#include <catch2/benchmark/detail/catch_analyse.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
#include <exception>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -64,7 +68,7 @@ namespace Catch {
|
|||||||
});
|
});
|
||||||
|
|
||||||
BenchmarkInfo info {
|
BenchmarkInfo info {
|
||||||
name,
|
CATCH_MOVE(name),
|
||||||
plan.estimated_duration.count(),
|
plan.estimated_duration.count(),
|
||||||
plan.iterations_per_sample,
|
plan.iterations_per_sample,
|
||||||
cfg->benchmarkSamples(),
|
cfg->benchmarkSamples(),
|
||||||
@@ -80,9 +84,9 @@ namespace Catch {
|
|||||||
});
|
});
|
||||||
|
|
||||||
auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
|
auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
|
||||||
BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
|
BenchmarkStats<FloatDuration<Clock>> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
|
||||||
getResultCapture().benchmarkEnded(stats);
|
getResultCapture().benchmarkEnded(stats);
|
||||||
} CATCH_CATCH_ANON (TestFailureException) {
|
} CATCH_CATCH_ANON (TestFailureException const&) {
|
||||||
getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr);
|
getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr);
|
||||||
} CATCH_CATCH_ALL{
|
} CATCH_CATCH_ALL{
|
||||||
getResultCapture().benchmarkFailed(translateActiveException());
|
getResultCapture().benchmarkFailed(translateActiveException());
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -33,6 +33,8 @@
|
|||||||
#include <catch2/benchmark/catch_sample_analysis.hpp>
|
#include <catch2/benchmark/catch_sample_analysis.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_analyse.hpp>
|
#include <catch2/benchmark/detail/catch_analyse.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
||||||
|
#include <catch2/benchmark/detail/catch_benchmark_stats.hpp>
|
||||||
|
#include <catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_estimate_clock.hpp>
|
#include <catch2/benchmark/detail/catch_estimate_clock.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_measure.hpp>
|
#include <catch2/benchmark/detail/catch_measure.hpp>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include <catch2/benchmark/catch_clock.hpp>
|
#include <catch2/benchmark/catch_clock.hpp>
|
||||||
#include <catch2/benchmark/catch_optimizer.hpp>
|
#include <catch2/benchmark/catch_optimizer.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
|
||||||
#include <catch2/internal/catch_meta.hpp>
|
#include <catch2/internal/catch_meta.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -17,8 +17,7 @@
|
|||||||
#include <catch2/benchmark/detail/catch_repeat.hpp>
|
#include <catch2/benchmark/detail/catch_repeat.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <vector>
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Benchmark {
|
namespace Benchmark {
|
||||||
@@ -41,14 +40,17 @@ namespace Catch {
|
|||||||
Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(now<Clock>{}));
|
Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(now<Clock>{}));
|
||||||
|
|
||||||
std::vector<FloatDuration<Clock>> times;
|
std::vector<FloatDuration<Clock>> times;
|
||||||
times.reserve(cfg.benchmarkSamples());
|
const auto num_samples = cfg.benchmarkSamples();
|
||||||
std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] {
|
times.reserve( num_samples );
|
||||||
|
for ( size_t i = 0; i < num_samples; ++i ) {
|
||||||
Detail::ChronometerModel<Clock> model;
|
Detail::ChronometerModel<Clock> model;
|
||||||
this->benchmark(Chronometer(model, iterations_per_sample));
|
this->benchmark( Chronometer( model, iterations_per_sample ) );
|
||||||
auto sample_time = model.elapsed() - env.clock_cost.mean;
|
auto sample_time = model.elapsed() - env.clock_cost.mean;
|
||||||
if (sample_time < FloatDuration<Clock>::zero()) sample_time = FloatDuration<Clock>::zero();
|
if ( sample_time < FloatDuration<Clock>::zero() ) {
|
||||||
return sample_time / iterations_per_sample;
|
sample_time = FloatDuration<Clock>::zero();
|
||||||
});
|
}
|
||||||
|
times.push_back(sample_time / iterations_per_sample);
|
||||||
|
}
|
||||||
return times;
|
return times;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#ifndef CATCH_OPTIMIZER_HPP_INCLUDED
|
#ifndef CATCH_OPTIMIZER_HPP_INCLUDED
|
||||||
#define CATCH_OPTIMIZER_HPP_INCLUDED
|
#define CATCH_OPTIMIZER_HPP_INCLUDED
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
# include <atomic> // atomic_thread_fence
|
# include <atomic> // atomic_thread_fence
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -32,16 +32,23 @@ namespace Catch {
|
|||||||
namespace Detail {
|
namespace Detail {
|
||||||
inline void optimizer_barrier() { keep_memory(); }
|
inline void optimizer_barrier() { keep_memory(); }
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC__)
|
||||||
|
|
||||||
|
#if defined(_MSVC_VER)
|
||||||
#pragma optimize("", off)
|
#pragma optimize("", off)
|
||||||
|
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||||
|
// For IAR the pragma only affects the following function
|
||||||
|
#pragma optimize=disable
|
||||||
|
#endif
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void keep_memory(T* p) {
|
inline void keep_memory(T* p) {
|
||||||
// thanks @milleniumbug
|
// thanks @milleniumbug
|
||||||
*reinterpret_cast<char volatile*>(p) = *reinterpret_cast<char const volatile*>(p);
|
*reinterpret_cast<char volatile*>(p) = *reinterpret_cast<char const volatile*>(p);
|
||||||
}
|
}
|
||||||
// TODO equivalent keep_memory()
|
// TODO equivalent keep_memory()
|
||||||
|
#if defined(_MSVC_VER)
|
||||||
#pragma optimize("", on)
|
#pragma optimize("", on)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
inline void optimizer_barrier() {
|
inline void optimizer_barrier() {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -10,14 +10,11 @@
|
|||||||
#ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED
|
#ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED
|
||||||
#define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED
|
#define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/benchmark/catch_clock.hpp>
|
|
||||||
#include <catch2/benchmark/catch_estimate.hpp>
|
#include <catch2/benchmark/catch_estimate.hpp>
|
||||||
#include <catch2/benchmark/catch_outlier_classification.hpp>
|
#include <catch2/benchmark/catch_outlier_classification.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Benchmark {
|
namespace Benchmark {
|
||||||
@@ -33,7 +30,9 @@ namespace Catch {
|
|||||||
operator SampleAnalysis<Duration2>() const {
|
operator SampleAnalysis<Duration2>() const {
|
||||||
std::vector<Duration2> samples2;
|
std::vector<Duration2> samples2;
|
||||||
samples2.reserve(samples.size());
|
samples2.reserve(samples.size());
|
||||||
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); });
|
for (auto const& d : samples) {
|
||||||
|
samples2.push_back(Duration2(d));
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
CATCH_MOVE(samples2),
|
CATCH_MOVE(samples2),
|
||||||
mean,
|
mean,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -10,15 +10,12 @@
|
|||||||
#ifndef CATCH_ANALYSE_HPP_INCLUDED
|
#ifndef CATCH_ANALYSE_HPP_INCLUDED
|
||||||
#define CATCH_ANALYSE_HPP_INCLUDED
|
#define CATCH_ANALYSE_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/benchmark/catch_clock.hpp>
|
|
||||||
#include <catch2/benchmark/catch_environment.hpp>
|
#include <catch2/benchmark/catch_environment.hpp>
|
||||||
#include <catch2/benchmark/catch_sample_analysis.hpp>
|
#include <catch2/benchmark/catch_sample_analysis.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_stats.hpp>
|
#include <catch2/benchmark/detail/catch_stats.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iterator>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@@ -29,7 +26,9 @@ namespace Catch {
|
|||||||
if (!cfg.benchmarkNoAnalysis()) {
|
if (!cfg.benchmarkNoAnalysis()) {
|
||||||
std::vector<double> samples;
|
std::vector<double> samples;
|
||||||
samples.reserve(static_cast<size_t>(last - first));
|
samples.reserve(static_cast<size_t>(last - first));
|
||||||
std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); });
|
for (auto current = first; current != last; ++current) {
|
||||||
|
samples.push_back( current->count() );
|
||||||
|
}
|
||||||
|
|
||||||
auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end());
|
auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end());
|
||||||
auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end());
|
auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end());
|
||||||
@@ -44,7 +43,10 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
std::vector<Duration> samples2;
|
std::vector<Duration> samples2;
|
||||||
samples2.reserve(samples.size());
|
samples2.reserve(samples.size());
|
||||||
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); });
|
for (auto s : samples) {
|
||||||
|
samples2.push_back( Duration( s ) );
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
CATCH_MOVE(samples2),
|
CATCH_MOVE(samples2),
|
||||||
wrap_estimate(analysis.mean),
|
wrap_estimate(analysis.mean),
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
#define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED
|
#define CATCH_BENCHMARK_FUNCTION_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/benchmark/catch_chronometer.hpp>
|
#include <catch2/benchmark/catch_chronometer.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
|
||||||
#include <catch2/internal/catch_meta.hpp>
|
#include <catch2/internal/catch_meta.hpp>
|
||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
64
src/catch2/benchmark/detail/catch_benchmark_stats.hpp
Normal file
64
src/catch2/benchmark/detail/catch_benchmark_stats.hpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
// 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_BENCHMARK_STATS_HPP_INCLUDED
|
||||||
|
#define CATCH_BENCHMARK_STATS_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
#include <catch2/benchmark/catch_estimate.hpp>
|
||||||
|
#include <catch2/benchmark/catch_outlier_classification.hpp>
|
||||||
|
// The fwd decl & default specialization needs to be seen by VS2017 before
|
||||||
|
// BenchmarkStats itself, or VS2017 will report compilation error.
|
||||||
|
#include <catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
struct BenchmarkInfo {
|
||||||
|
std::string name;
|
||||||
|
double estimatedDuration;
|
||||||
|
int iterations;
|
||||||
|
unsigned int samples;
|
||||||
|
unsigned int resamples;
|
||||||
|
double clockResolution;
|
||||||
|
double clockCost;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Duration>
|
||||||
|
struct BenchmarkStats {
|
||||||
|
BenchmarkInfo info;
|
||||||
|
|
||||||
|
std::vector<Duration> samples;
|
||||||
|
Benchmark::Estimate<Duration> mean;
|
||||||
|
Benchmark::Estimate<Duration> standardDeviation;
|
||||||
|
Benchmark::OutlierClassification outliers;
|
||||||
|
double outlierVariance;
|
||||||
|
|
||||||
|
template <typename Duration2>
|
||||||
|
operator BenchmarkStats<Duration2>() const {
|
||||||
|
std::vector<Duration2> samples2;
|
||||||
|
samples2.reserve(samples.size());
|
||||||
|
for (auto const& sample : samples) {
|
||||||
|
samples2.push_back(Duration2(sample));
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
info,
|
||||||
|
CATCH_MOVE(samples2),
|
||||||
|
mean,
|
||||||
|
standardDeviation,
|
||||||
|
outliers,
|
||||||
|
outlierVariance,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
#endif // CATCH_BENCHMARK_STATS_HPP_INCLUDED
|
23
src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp
Normal file
23
src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
// 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_BENCHMARK_STATS_FWD_HPP_INCLUDED
|
||||||
|
#define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
// We cannot forward declare the type with default template argument
|
||||||
|
// multiple times, so it is split out into a separate header so that
|
||||||
|
// we can prevent multiple declarations in dependees
|
||||||
|
template <typename Duration = std::chrono::duration<double, std::nano>>
|
||||||
|
struct BenchmarkStats;
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
#endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -10,14 +10,9 @@
|
|||||||
#ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED
|
#ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED
|
||||||
#define CATCH_COMPLETE_INVOKE_HPP_INCLUDED
|
#define CATCH_COMPLETE_INVOKE_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
|
||||||
#include <catch2/internal/catch_meta.hpp>
|
#include <catch2/internal/catch_meta.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Benchmark {
|
namespace Benchmark {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@@ -30,26 +29,29 @@ namespace Catch {
|
|||||||
std::vector<double> resolution(int k) {
|
std::vector<double> resolution(int k) {
|
||||||
std::vector<TimePoint<Clock>> times;
|
std::vector<TimePoint<Clock>> times;
|
||||||
times.reserve(static_cast<size_t>(k + 1));
|
times.reserve(static_cast<size_t>(k + 1));
|
||||||
std::generate_n(std::back_inserter(times), k + 1, now<Clock>{});
|
for ( int i = 0; i < k + 1; ++i ) {
|
||||||
|
times.push_back( Clock::now() );
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<double> deltas;
|
std::vector<double> deltas;
|
||||||
deltas.reserve(static_cast<size_t>(k));
|
deltas.reserve(static_cast<size_t>(k));
|
||||||
std::transform(std::next(times.begin()), times.end(), times.begin(),
|
for ( size_t idx = 1; idx < times.size(); ++idx ) {
|
||||||
std::back_inserter(deltas),
|
deltas.push_back( static_cast<double>(
|
||||||
[](TimePoint<Clock> a, TimePoint<Clock> b) { return static_cast<double>((a - b).count()); });
|
( times[idx] - times[idx - 1] ).count() ) );
|
||||||
|
}
|
||||||
|
|
||||||
return deltas;
|
return deltas;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto warmup_iterations = 10000;
|
constexpr auto warmup_iterations = 10000;
|
||||||
const auto warmup_time = std::chrono::milliseconds(100);
|
constexpr auto warmup_time = std::chrono::milliseconds(100);
|
||||||
const auto minimum_ticks = 1000;
|
constexpr auto minimum_ticks = 1000;
|
||||||
const auto warmup_seed = 10000;
|
constexpr auto warmup_seed = 10000;
|
||||||
const auto clock_resolution_estimation_time = std::chrono::milliseconds(500);
|
constexpr auto clock_resolution_estimation_time = std::chrono::milliseconds(500);
|
||||||
const auto clock_cost_estimation_time_limit = std::chrono::seconds(1);
|
constexpr auto clock_cost_estimation_time_limit = std::chrono::seconds(1);
|
||||||
const auto clock_cost_estimation_tick_limit = 100000;
|
constexpr auto clock_cost_estimation_tick_limit = 100000;
|
||||||
const auto clock_cost_estimation_time = std::chrono::milliseconds(10);
|
constexpr auto clock_cost_estimation_time = std::chrono::milliseconds(10);
|
||||||
const auto clock_cost_estimation_iterations = 10000;
|
constexpr auto clock_cost_estimation_iterations = 10000;
|
||||||
|
|
||||||
template <typename Clock>
|
template <typename Clock>
|
||||||
int warmup() {
|
int warmup() {
|
||||||
@@ -84,9 +86,11 @@ namespace Catch {
|
|||||||
std::vector<double> times;
|
std::vector<double> times;
|
||||||
int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed));
|
int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed));
|
||||||
times.reserve(static_cast<size_t>(nsamples));
|
times.reserve(static_cast<size_t>(nsamples));
|
||||||
std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] {
|
for ( int s = 0; s < nsamples; ++s ) {
|
||||||
return static_cast<double>((time_clock(r.iterations) / r.iterations).count());
|
times.push_back( static_cast<double>(
|
||||||
});
|
( time_clock( r.iterations ) / r.iterations )
|
||||||
|
.count() ) );
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
FloatDuration<Clock>(mean(times.begin(), times.end())),
|
FloatDuration<Clock>(mean(times.begin(), times.end())),
|
||||||
classify_outliers(times.begin(), times.end()),
|
classify_outliers(times.begin(), times.end()),
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
#ifndef CATCH_MEASURE_HPP_INCLUDED
|
#ifndef CATCH_MEASURE_HPP_INCLUDED
|
||||||
#define CATCH_MEASURE_HPP_INCLUDED
|
#define CATCH_MEASURE_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/benchmark/catch_clock.hpp>
|
|
||||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_timing.hpp>
|
#include <catch2/benchmark/detail/catch_timing.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
||||||
#include <exception>
|
|
||||||
#include <catch2/internal/catch_enforce.hpp>
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Benchmark {
|
namespace Benchmark {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <numeric>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
|
||||||
@@ -21,117 +21,172 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace Catch {
|
||||||
|
namespace Benchmark {
|
||||||
|
namespace Detail {
|
||||||
|
namespace {
|
||||||
|
|
||||||
using Catch::Benchmark::Detail::sample;
|
template <typename URng, typename Estimator>
|
||||||
|
static sample
|
||||||
|
resample( URng& rng,
|
||||||
|
unsigned int resamples,
|
||||||
|
std::vector<double>::const_iterator first,
|
||||||
|
std::vector<double>::const_iterator last,
|
||||||
|
Estimator& estimator ) {
|
||||||
|
auto n = static_cast<size_t>( last - first );
|
||||||
|
std::uniform_int_distribution<decltype( n )> dist( 0,
|
||||||
|
n - 1 );
|
||||||
|
|
||||||
template <typename URng, typename Estimator>
|
sample out;
|
||||||
sample resample(URng& rng, unsigned int resamples, std::vector<double>::iterator first, std::vector<double>::iterator last, Estimator& estimator) {
|
out.reserve( resamples );
|
||||||
auto n = static_cast<size_t>(last - first);
|
// We allocate the vector outside the loop to avoid realloc
|
||||||
std::uniform_int_distribution<decltype(n)> dist(0, n - 1);
|
// per resample
|
||||||
|
std::vector<double> resampled;
|
||||||
|
resampled.reserve( n );
|
||||||
|
for ( size_t i = 0; i < resamples; ++i ) {
|
||||||
|
resampled.clear();
|
||||||
|
for ( size_t s = 0; s < n; ++s ) {
|
||||||
|
resampled.push_back(
|
||||||
|
first[static_cast<std::ptrdiff_t>(
|
||||||
|
dist( rng ) )] );
|
||||||
|
}
|
||||||
|
const auto estimate =
|
||||||
|
estimator( resampled.begin(), resampled.end() );
|
||||||
|
out.push_back( estimate );
|
||||||
|
}
|
||||||
|
std::sort( out.begin(), out.end() );
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
sample out;
|
static double outlier_variance( Estimate<double> mean,
|
||||||
out.reserve(resamples);
|
Estimate<double> stddev,
|
||||||
std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] {
|
int n ) {
|
||||||
std::vector<double> resampled;
|
double sb = stddev.point;
|
||||||
resampled.reserve(n);
|
double mn = mean.point / n;
|
||||||
std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[static_cast<std::ptrdiff_t>(dist(rng))]; });
|
double mg_min = mn / 2.;
|
||||||
return estimator(resampled.begin(), resampled.end());
|
double sg = (std::min)( mg_min / 4., sb / std::sqrt( n ) );
|
||||||
});
|
double sg2 = sg * sg;
|
||||||
std::sort(out.begin(), out.end());
|
double sb2 = sb * sb;
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
auto c_max = [n, mn, sb2, sg2]( double x ) -> double {
|
||||||
|
double k = mn - x;
|
||||||
|
double d = k * k;
|
||||||
|
double nd = n * d;
|
||||||
|
double k0 = -n * nd;
|
||||||
|
double k1 = sb2 - n * sg2 + nd;
|
||||||
|
double det = k1 * k1 - 4 * sg2 * k0;
|
||||||
|
return static_cast<int>( -2. * k0 /
|
||||||
|
( k1 + std::sqrt( det ) ) );
|
||||||
|
};
|
||||||
|
|
||||||
double erf_inv(double x) {
|
auto var_out = [n, sb2, sg2]( double c ) {
|
||||||
// Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2
|
double nc = n - c;
|
||||||
double w, p;
|
return ( nc / n ) * ( sb2 - nc * sg2 );
|
||||||
|
};
|
||||||
|
|
||||||
w = -log((1.0 - x) * (1.0 + x));
|
return (std::min)( var_out( 1 ),
|
||||||
|
var_out(
|
||||||
|
(std::min)( c_max( 0. ),
|
||||||
|
c_max( mg_min ) ) ) ) /
|
||||||
|
sb2;
|
||||||
|
}
|
||||||
|
|
||||||
if (w < 6.250000) {
|
static double erf_inv( double x ) {
|
||||||
w = w - 3.125000;
|
// Code accompanying the article "Approximating the erfinv
|
||||||
p = -3.6444120640178196996e-21;
|
// function" in GPU Computing Gems, Volume 2
|
||||||
p = -1.685059138182016589e-19 + p * w;
|
double w, p;
|
||||||
p = 1.2858480715256400167e-18 + p * w;
|
|
||||||
p = 1.115787767802518096e-17 + p * w;
|
|
||||||
p = -1.333171662854620906e-16 + p * w;
|
|
||||||
p = 2.0972767875968561637e-17 + p * w;
|
|
||||||
p = 6.6376381343583238325e-15 + p * w;
|
|
||||||
p = -4.0545662729752068639e-14 + p * w;
|
|
||||||
p = -8.1519341976054721522e-14 + p * w;
|
|
||||||
p = 2.6335093153082322977e-12 + p * w;
|
|
||||||
p = -1.2975133253453532498e-11 + p * w;
|
|
||||||
p = -5.4154120542946279317e-11 + p * w;
|
|
||||||
p = 1.051212273321532285e-09 + p * w;
|
|
||||||
p = -4.1126339803469836976e-09 + p * w;
|
|
||||||
p = -2.9070369957882005086e-08 + p * w;
|
|
||||||
p = 4.2347877827932403518e-07 + p * w;
|
|
||||||
p = -1.3654692000834678645e-06 + p * w;
|
|
||||||
p = -1.3882523362786468719e-05 + p * w;
|
|
||||||
p = 0.0001867342080340571352 + p * w;
|
|
||||||
p = -0.00074070253416626697512 + p * w;
|
|
||||||
p = -0.0060336708714301490533 + p * w;
|
|
||||||
p = 0.24015818242558961693 + p * w;
|
|
||||||
p = 1.6536545626831027356 + p * w;
|
|
||||||
} else if (w < 16.000000) {
|
|
||||||
w = sqrt(w) - 3.250000;
|
|
||||||
p = 2.2137376921775787049e-09;
|
|
||||||
p = 9.0756561938885390979e-08 + p * w;
|
|
||||||
p = -2.7517406297064545428e-07 + p * w;
|
|
||||||
p = 1.8239629214389227755e-08 + p * w;
|
|
||||||
p = 1.5027403968909827627e-06 + p * w;
|
|
||||||
p = -4.013867526981545969e-06 + p * w;
|
|
||||||
p = 2.9234449089955446044e-06 + p * w;
|
|
||||||
p = 1.2475304481671778723e-05 + p * w;
|
|
||||||
p = -4.7318229009055733981e-05 + p * w;
|
|
||||||
p = 6.8284851459573175448e-05 + p * w;
|
|
||||||
p = 2.4031110387097893999e-05 + p * w;
|
|
||||||
p = -0.0003550375203628474796 + p * w;
|
|
||||||
p = 0.00095328937973738049703 + p * w;
|
|
||||||
p = -0.0016882755560235047313 + p * w;
|
|
||||||
p = 0.0024914420961078508066 + p * w;
|
|
||||||
p = -0.0037512085075692412107 + p * w;
|
|
||||||
p = 0.005370914553590063617 + p * w;
|
|
||||||
p = 1.0052589676941592334 + p * w;
|
|
||||||
p = 3.0838856104922207635 + p * w;
|
|
||||||
} else {
|
|
||||||
w = sqrt(w) - 5.000000;
|
|
||||||
p = -2.7109920616438573243e-11;
|
|
||||||
p = -2.5556418169965252055e-10 + p * w;
|
|
||||||
p = 1.5076572693500548083e-09 + p * w;
|
|
||||||
p = -3.7894654401267369937e-09 + p * w;
|
|
||||||
p = 7.6157012080783393804e-09 + p * w;
|
|
||||||
p = -1.4960026627149240478e-08 + p * w;
|
|
||||||
p = 2.9147953450901080826e-08 + p * w;
|
|
||||||
p = -6.7711997758452339498e-08 + p * w;
|
|
||||||
p = 2.2900482228026654717e-07 + p * w;
|
|
||||||
p = -9.9298272942317002539e-07 + p * w;
|
|
||||||
p = 4.5260625972231537039e-06 + p * w;
|
|
||||||
p = -1.9681778105531670567e-05 + p * w;
|
|
||||||
p = 7.5995277030017761139e-05 + p * w;
|
|
||||||
p = -0.00021503011930044477347 + p * w;
|
|
||||||
p = -0.00013871931833623122026 + p * w;
|
|
||||||
p = 1.0103004648645343977 + p * w;
|
|
||||||
p = 4.8499064014085844221 + p * w;
|
|
||||||
}
|
|
||||||
return p * x;
|
|
||||||
}
|
|
||||||
|
|
||||||
double standard_deviation(std::vector<double>::iterator first, std::vector<double>::iterator last) {
|
w = -log( ( 1.0 - x ) * ( 1.0 + x ) );
|
||||||
auto m = Catch::Benchmark::Detail::mean(first, last);
|
|
||||||
double variance = std::accumulate( first,
|
|
||||||
last,
|
|
||||||
0.,
|
|
||||||
[m]( double a, double b ) {
|
|
||||||
double diff = b - m;
|
|
||||||
return a + diff * diff;
|
|
||||||
} ) /
|
|
||||||
( last - first );
|
|
||||||
return std::sqrt( variance );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if ( w < 6.250000 ) {
|
||||||
|
w = w - 3.125000;
|
||||||
|
p = -3.6444120640178196996e-21;
|
||||||
|
p = -1.685059138182016589e-19 + p * w;
|
||||||
|
p = 1.2858480715256400167e-18 + p * w;
|
||||||
|
p = 1.115787767802518096e-17 + p * w;
|
||||||
|
p = -1.333171662854620906e-16 + p * w;
|
||||||
|
p = 2.0972767875968561637e-17 + p * w;
|
||||||
|
p = 6.6376381343583238325e-15 + p * w;
|
||||||
|
p = -4.0545662729752068639e-14 + p * w;
|
||||||
|
p = -8.1519341976054721522e-14 + p * w;
|
||||||
|
p = 2.6335093153082322977e-12 + p * w;
|
||||||
|
p = -1.2975133253453532498e-11 + p * w;
|
||||||
|
p = -5.4154120542946279317e-11 + p * w;
|
||||||
|
p = 1.051212273321532285e-09 + p * w;
|
||||||
|
p = -4.1126339803469836976e-09 + p * w;
|
||||||
|
p = -2.9070369957882005086e-08 + p * w;
|
||||||
|
p = 4.2347877827932403518e-07 + p * w;
|
||||||
|
p = -1.3654692000834678645e-06 + p * w;
|
||||||
|
p = -1.3882523362786468719e-05 + p * w;
|
||||||
|
p = 0.0001867342080340571352 + p * w;
|
||||||
|
p = -0.00074070253416626697512 + p * w;
|
||||||
|
p = -0.0060336708714301490533 + p * w;
|
||||||
|
p = 0.24015818242558961693 + p * w;
|
||||||
|
p = 1.6536545626831027356 + p * w;
|
||||||
|
} else if ( w < 16.000000 ) {
|
||||||
|
w = sqrt( w ) - 3.250000;
|
||||||
|
p = 2.2137376921775787049e-09;
|
||||||
|
p = 9.0756561938885390979e-08 + p * w;
|
||||||
|
p = -2.7517406297064545428e-07 + p * w;
|
||||||
|
p = 1.8239629214389227755e-08 + p * w;
|
||||||
|
p = 1.5027403968909827627e-06 + p * w;
|
||||||
|
p = -4.013867526981545969e-06 + p * w;
|
||||||
|
p = 2.9234449089955446044e-06 + p * w;
|
||||||
|
p = 1.2475304481671778723e-05 + p * w;
|
||||||
|
p = -4.7318229009055733981e-05 + p * w;
|
||||||
|
p = 6.8284851459573175448e-05 + p * w;
|
||||||
|
p = 2.4031110387097893999e-05 + p * w;
|
||||||
|
p = -0.0003550375203628474796 + p * w;
|
||||||
|
p = 0.00095328937973738049703 + p * w;
|
||||||
|
p = -0.0016882755560235047313 + p * w;
|
||||||
|
p = 0.0024914420961078508066 + p * w;
|
||||||
|
p = -0.0037512085075692412107 + p * w;
|
||||||
|
p = 0.005370914553590063617 + p * w;
|
||||||
|
p = 1.0052589676941592334 + p * w;
|
||||||
|
p = 3.0838856104922207635 + p * w;
|
||||||
|
} else {
|
||||||
|
w = sqrt( w ) - 5.000000;
|
||||||
|
p = -2.7109920616438573243e-11;
|
||||||
|
p = -2.5556418169965252055e-10 + p * w;
|
||||||
|
p = 1.5076572693500548083e-09 + p * w;
|
||||||
|
p = -3.7894654401267369937e-09 + p * w;
|
||||||
|
p = 7.6157012080783393804e-09 + p * w;
|
||||||
|
p = -1.4960026627149240478e-08 + p * w;
|
||||||
|
p = 2.9147953450901080826e-08 + p * w;
|
||||||
|
p = -6.7711997758452339498e-08 + p * w;
|
||||||
|
p = 2.2900482228026654717e-07 + p * w;
|
||||||
|
p = -9.9298272942317002539e-07 + p * w;
|
||||||
|
p = 4.5260625972231537039e-06 + p * w;
|
||||||
|
p = -1.9681778105531670567e-05 + p * w;
|
||||||
|
p = 7.5995277030017761139e-05 + p * w;
|
||||||
|
p = -0.00021503011930044477347 + p * w;
|
||||||
|
p = -0.00013871931833623122026 + p * w;
|
||||||
|
p = 1.0103004648645343977 + p * w;
|
||||||
|
p = 4.8499064014085844221 + p * w;
|
||||||
|
}
|
||||||
|
return p * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double
|
||||||
|
standard_deviation( std::vector<double>::const_iterator first,
|
||||||
|
std::vector<double>::const_iterator last ) {
|
||||||
|
auto m = Catch::Benchmark::Detail::mean( first, last );
|
||||||
|
double variance =
|
||||||
|
std::accumulate( first,
|
||||||
|
last,
|
||||||
|
0.,
|
||||||
|
[m]( double a, double b ) {
|
||||||
|
double diff = b - m;
|
||||||
|
return a + diff * diff;
|
||||||
|
} ) /
|
||||||
|
( last - first );
|
||||||
|
return std::sqrt( variance );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace Detail
|
||||||
|
} // namespace Benchmark
|
||||||
|
} // namespace Catch
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Benchmark {
|
namespace Benchmark {
|
||||||
@@ -161,6 +216,47 @@ namespace Catch {
|
|||||||
return xj + g * (xj1 - xj);
|
return xj + g * (xj1 - xj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutlierClassification
|
||||||
|
classify_outliers( std::vector<double>::const_iterator first,
|
||||||
|
std::vector<double>::const_iterator last ) {
|
||||||
|
std::vector<double> copy( first, last );
|
||||||
|
|
||||||
|
auto q1 = weighted_average_quantile( 1, 4, copy.begin(), copy.end() );
|
||||||
|
auto q3 = weighted_average_quantile( 3, 4, copy.begin(), copy.end() );
|
||||||
|
auto iqr = q3 - q1;
|
||||||
|
auto los = q1 - ( iqr * 3. );
|
||||||
|
auto lom = q1 - ( iqr * 1.5 );
|
||||||
|
auto him = q3 + ( iqr * 1.5 );
|
||||||
|
auto his = q3 + ( iqr * 3. );
|
||||||
|
|
||||||
|
OutlierClassification o;
|
||||||
|
for ( ; first != last; ++first ) {
|
||||||
|
const double t = *first;
|
||||||
|
if ( t < los ) {
|
||||||
|
++o.low_severe;
|
||||||
|
} else if ( t < lom ) {
|
||||||
|
++o.low_mild;
|
||||||
|
} else if ( t > his ) {
|
||||||
|
++o.high_severe;
|
||||||
|
} else if ( t > him ) {
|
||||||
|
++o.high_mild;
|
||||||
|
}
|
||||||
|
++o.samples_seen;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
double mean( std::vector<double>::const_iterator first,
|
||||||
|
std::vector<double>::const_iterator last ) {
|
||||||
|
auto count = last - first;
|
||||||
|
double sum = 0.;
|
||||||
|
while (first != last) {
|
||||||
|
sum += *first;
|
||||||
|
++first;
|
||||||
|
}
|
||||||
|
return sum / static_cast<double>(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double erfc_inv(double x) {
|
double erfc_inv(double x) {
|
||||||
return erf_inv(1.0 - x);
|
return erf_inv(1.0 - x);
|
||||||
@@ -182,35 +278,10 @@ namespace Catch {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bootstrap_analysis analyse_samples(double confidence_level,
|
||||||
double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n) {
|
unsigned int n_resamples,
|
||||||
double sb = stddev.point;
|
std::vector<double>::iterator first,
|
||||||
double mn = mean.point / n;
|
std::vector<double>::iterator last) {
|
||||||
double mg_min = mn / 2.;
|
|
||||||
double sg = (std::min)(mg_min / 4., sb / std::sqrt(n));
|
|
||||||
double sg2 = sg * sg;
|
|
||||||
double sb2 = sb * sb;
|
|
||||||
|
|
||||||
auto c_max = [n, mn, sb2, sg2](double x) -> double {
|
|
||||||
double k = mn - x;
|
|
||||||
double d = k * k;
|
|
||||||
double nd = n * d;
|
|
||||||
double k0 = -n * nd;
|
|
||||||
double k1 = sb2 - n * sg2 + nd;
|
|
||||||
double det = k1 * k1 - 4 * sg2 * k0;
|
|
||||||
return static_cast<int>(-2. * k0 / (k1 + std::sqrt(det)));
|
|
||||||
};
|
|
||||||
|
|
||||||
auto var_out = [n, sb2, sg2](double c) {
|
|
||||||
double nc = n - c;
|
|
||||||
return (nc / n) * (sb2 - nc * sg2);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last) {
|
|
||||||
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
|
||||||
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
|
||||||
static std::random_device entropy;
|
static std::random_device entropy;
|
||||||
@@ -218,11 +289,12 @@ namespace Catch {
|
|||||||
|
|
||||||
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
|
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
|
||||||
|
|
||||||
auto mean = &Detail::mean<std::vector<double>::iterator>;
|
auto mean = &Detail::mean;
|
||||||
auto stddev = &standard_deviation;
|
auto stddev = &standard_deviation;
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_USE_ASYNC)
|
#if defined(CATCH_CONFIG_USE_ASYNC)
|
||||||
auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) {
|
auto Estimate = [=](double(*f)(std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator)) {
|
||||||
auto seed = entropy();
|
auto seed = entropy();
|
||||||
return std::async(std::launch::async, [=] {
|
return std::async(std::launch::async, [=] {
|
||||||
std::mt19937 rng(seed);
|
std::mt19937 rng(seed);
|
||||||
@@ -237,7 +309,8 @@ namespace Catch {
|
|||||||
auto mean_estimate = mean_future.get();
|
auto mean_estimate = mean_future.get();
|
||||||
auto stddev_estimate = stddev_future.get();
|
auto stddev_estimate = stddev_future.get();
|
||||||
#else
|
#else
|
||||||
auto Estimate = [=](double(*f)(std::vector<double>::iterator, std::vector<double>::iterator)) {
|
auto Estimate = [=](double(*f)(std::vector<double>::const_iterator,
|
||||||
|
std::vector<double>::const_iterator)) {
|
||||||
auto seed = entropy();
|
auto seed = entropy();
|
||||||
std::mt19937 rng(seed);
|
std::mt19937 rng(seed);
|
||||||
auto resampled = resample(rng, n_resamples, first, last, f);
|
auto resampled = resample(rng, n_resamples, first, last, f);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <numeric>
|
|
||||||
#include <tuple>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@@ -30,39 +28,17 @@ namespace Catch {
|
|||||||
|
|
||||||
double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last);
|
double weighted_average_quantile(int k, int q, std::vector<double>::iterator first, std::vector<double>::iterator last);
|
||||||
|
|
||||||
template <typename Iterator>
|
OutlierClassification
|
||||||
OutlierClassification classify_outliers(Iterator first, Iterator last) {
|
classify_outliers( std::vector<double>::const_iterator first,
|
||||||
std::vector<double> copy(first, last);
|
std::vector<double>::const_iterator last );
|
||||||
|
|
||||||
auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end());
|
double mean( std::vector<double>::const_iterator first,
|
||||||
auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end());
|
std::vector<double>::const_iterator last );
|
||||||
auto iqr = q3 - q1;
|
|
||||||
auto los = q1 - (iqr * 3.);
|
|
||||||
auto lom = q1 - (iqr * 1.5);
|
|
||||||
auto him = q3 + (iqr * 1.5);
|
|
||||||
auto his = q3 + (iqr * 3.);
|
|
||||||
|
|
||||||
OutlierClassification o;
|
template <typename Estimator>
|
||||||
for (; first != last; ++first) {
|
sample jackknife(Estimator&& estimator,
|
||||||
auto&& t = *first;
|
std::vector<double>::iterator first,
|
||||||
if (t < los) ++o.low_severe;
|
std::vector<double>::iterator last) {
|
||||||
else if (t < lom) ++o.low_mild;
|
|
||||||
else if (t > his) ++o.high_severe;
|
|
||||||
else if (t > him) ++o.high_mild;
|
|
||||||
++o.samples_seen;
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Iterator>
|
|
||||||
double mean(Iterator first, Iterator last) {
|
|
||||||
auto count = last - first;
|
|
||||||
double sum = std::accumulate(first, last, 0.);
|
|
||||||
return sum / static_cast<double>(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Estimator, typename Iterator>
|
|
||||||
sample jackknife(Estimator&& estimator, Iterator first, Iterator last) {
|
|
||||||
auto n = static_cast<size_t>(last - first);
|
auto n = static_cast<size_t>(last - first);
|
||||||
auto second = first;
|
auto second = first;
|
||||||
++second;
|
++second;
|
||||||
@@ -85,8 +61,12 @@ namespace Catch {
|
|||||||
|
|
||||||
double normal_quantile(double p);
|
double normal_quantile(double p);
|
||||||
|
|
||||||
template <typename Iterator, typename Estimator>
|
template <typename Estimator>
|
||||||
Estimate<double> bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) {
|
Estimate<double> bootstrap( double confidence_level,
|
||||||
|
std::vector<double>::iterator first,
|
||||||
|
std::vector<double>::iterator last,
|
||||||
|
sample const& resample,
|
||||||
|
Estimator&& estimator ) {
|
||||||
auto n_samples = last - first;
|
auto n_samples = last - first;
|
||||||
|
|
||||||
double point = estimator(first, last);
|
double point = estimator(first, last);
|
||||||
@@ -95,13 +75,13 @@ namespace Catch {
|
|||||||
|
|
||||||
sample jack = jackknife(estimator, first, last);
|
sample jack = jackknife(estimator, first, last);
|
||||||
double jack_mean = mean(jack.begin(), jack.end());
|
double jack_mean = mean(jack.begin(), jack.end());
|
||||||
double sum_squares, sum_cubes;
|
double sum_squares = 0, sum_cubes = 0;
|
||||||
std::tie(sum_squares, sum_cubes) = std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair<double, double> sqcb, double x) -> std::pair<double, double> {
|
for (double x : jack) {
|
||||||
auto d = jack_mean - x;
|
auto difference = jack_mean - x;
|
||||||
auto d2 = d * d;
|
auto square = difference * difference;
|
||||||
auto d3 = d2 * d;
|
auto cube = square * difference;
|
||||||
return { sqcb.first + d2, sqcb.second + d3 };
|
sum_squares += square; sum_cubes += cube;
|
||||||
});
|
}
|
||||||
|
|
||||||
double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5));
|
double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5));
|
||||||
long n = static_cast<long>(resample.size());
|
long n = static_cast<long>(resample.size());
|
||||||
@@ -128,15 +108,16 @@ namespace Catch {
|
|||||||
return { point, resample[lo], resample[hi], confidence_level };
|
return { point, resample[lo], resample[hi], confidence_level };
|
||||||
}
|
}
|
||||||
|
|
||||||
double outlier_variance(Estimate<double> mean, Estimate<double> stddev, int n);
|
|
||||||
|
|
||||||
struct bootstrap_analysis {
|
struct bootstrap_analysis {
|
||||||
Estimate<double> mean;
|
Estimate<double> mean;
|
||||||
Estimate<double> standard_deviation;
|
Estimate<double> standard_deviation;
|
||||||
double outlier_variance;
|
double outlier_variance;
|
||||||
};
|
};
|
||||||
|
|
||||||
bootstrap_analysis analyse_samples(double confidence_level, unsigned int n_resamples, std::vector<double>::iterator first, std::vector<double>::iterator last);
|
bootstrap_analysis analyse_samples(double confidence_level,
|
||||||
|
unsigned int n_resamples,
|
||||||
|
std::vector<double>::iterator first,
|
||||||
|
std::vector<double>::iterator last);
|
||||||
} // namespace Detail
|
} // namespace Detail
|
||||||
} // namespace Benchmark
|
} // namespace Benchmark
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -50,9 +50,11 @@
|
|||||||
#include <catch2/internal/catch_case_sensitive.hpp>
|
#include <catch2/internal/catch_case_sensitive.hpp>
|
||||||
#include <catch2/internal/catch_clara.hpp>
|
#include <catch2/internal/catch_clara.hpp>
|
||||||
#include <catch2/internal/catch_commandline.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_compiler_capabilities.hpp>
|
||||||
#include <catch2/internal/catch_config_android_logwrite.hpp>
|
#include <catch2/internal/catch_config_android_logwrite.hpp>
|
||||||
#include <catch2/internal/catch_config_counter.hpp>
|
#include <catch2/internal/catch_config_counter.hpp>
|
||||||
|
#include <catch2/internal/catch_config_static_analysis_support.hpp>
|
||||||
#include <catch2/internal/catch_config_uncaught_exceptions.hpp>
|
#include <catch2/internal/catch_config_uncaught_exceptions.hpp>
|
||||||
#include <catch2/internal/catch_config_wchar.hpp>
|
#include <catch2/internal/catch_config_wchar.hpp>
|
||||||
#include <catch2/internal/catch_console_colour.hpp>
|
#include <catch2/internal/catch_console_colour.hpp>
|
||||||
@@ -68,19 +70,24 @@
|
|||||||
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
||||||
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
||||||
#include <catch2/internal/catch_floating_point_helpers.hpp>
|
#include <catch2/internal/catch_floating_point_helpers.hpp>
|
||||||
|
#include <catch2/internal/catch_getenv.hpp>
|
||||||
|
#include <catch2/internal/catch_is_permutation.hpp>
|
||||||
#include <catch2/internal/catch_istream.hpp>
|
#include <catch2/internal/catch_istream.hpp>
|
||||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||||
#include <catch2/internal/catch_leak_detector.hpp>
|
#include <catch2/internal/catch_leak_detector.hpp>
|
||||||
#include <catch2/internal/catch_list.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_message_info.hpp>
|
||||||
#include <catch2/internal/catch_meta.hpp>
|
#include <catch2/internal/catch_meta.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
#include <catch2/internal/catch_noncopyable.hpp>
|
#include <catch2/internal/catch_noncopyable.hpp>
|
||||||
#include <catch2/internal/catch_optional.hpp>
|
#include <catch2/internal/catch_optional.hpp>
|
||||||
#include <catch2/internal/catch_output_redirect.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_platform.hpp>
|
||||||
#include <catch2/internal/catch_polyfills.hpp>
|
#include <catch2/internal/catch_polyfills.hpp>
|
||||||
#include <catch2/internal/catch_preprocessor.hpp>
|
#include <catch2/internal/catch_preprocessor.hpp>
|
||||||
|
#include <catch2/internal/catch_preprocessor_internal_stringify.hpp>
|
||||||
#include <catch2/internal/catch_preprocessor_remove_parens.hpp>
|
#include <catch2/internal/catch_preprocessor_remove_parens.hpp>
|
||||||
#include <catch2/internal/catch_random_number_generator.hpp>
|
#include <catch2/internal/catch_random_number_generator.hpp>
|
||||||
#include <catch2/internal/catch_random_seed_generation.hpp>
|
#include <catch2/internal/catch_random_seed_generation.hpp>
|
||||||
@@ -106,6 +113,7 @@
|
|||||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||||
#include <catch2/internal/catch_test_registry.hpp>
|
#include <catch2/internal/catch_test_registry.hpp>
|
||||||
|
#include <catch2/internal/catch_test_run_info.hpp>
|
||||||
#include <catch2/internal/catch_test_spec_parser.hpp>
|
#include <catch2/internal/catch_test_spec_parser.hpp>
|
||||||
#include <catch2/internal/catch_textflow.hpp>
|
#include <catch2/internal/catch_textflow.hpp>
|
||||||
#include <catch2/internal/catch_to_string.hpp>
|
#include <catch2/internal/catch_to_string.hpp>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#include <catch2/catch_assertion_result.hpp>
|
#include <catch2/catch_assertion_result.hpp>
|
||||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||||
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@@ -26,9 +27,9 @@ namespace Catch {
|
|||||||
return reconstructedExpression;
|
return reconstructedExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
|
AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData&& data )
|
||||||
: m_info( info ),
|
: m_info( info ),
|
||||||
m_resultData( data )
|
m_resultData( CATCH_MOVE(data) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Result was a success
|
// Result was a success
|
||||||
@@ -67,16 +68,15 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string AssertionResult::getExpressionInMacro() const {
|
std::string AssertionResult::getExpressionInMacro() const {
|
||||||
std::string expr;
|
if ( m_info.macroName.empty() ) {
|
||||||
if( m_info.macroName.empty() )
|
return static_cast<std::string>( m_info.capturedExpression );
|
||||||
expr = static_cast<std::string>(m_info.capturedExpression);
|
|
||||||
else {
|
|
||||||
expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );
|
|
||||||
expr += m_info.macroName;
|
|
||||||
expr += "( ";
|
|
||||||
expr += m_info.capturedExpression;
|
|
||||||
expr += " )";
|
|
||||||
}
|
}
|
||||||
|
std::string expr;
|
||||||
|
expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );
|
||||||
|
expr += m_info.macroName;
|
||||||
|
expr += "( ";
|
||||||
|
expr += m_info.capturedExpression;
|
||||||
|
expr += " )";
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -35,7 +35,7 @@ namespace Catch {
|
|||||||
class AssertionResult {
|
class AssertionResult {
|
||||||
public:
|
public:
|
||||||
AssertionResult() = delete;
|
AssertionResult() = delete;
|
||||||
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
|
AssertionResult( AssertionInfo const& info, AssertionResultData&& data );
|
||||||
|
|
||||||
bool isOk() const;
|
bool isOk() const;
|
||||||
bool succeeded() const;
|
bool succeeded() const;
|
||||||
|
@@ -1,46 +1,89 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#include <catch2/catch_config.hpp>
|
#include <catch2/catch_config.hpp>
|
||||||
#include <catch2/catch_user_config.hpp>
|
#include <catch2/catch_user_config.hpp>
|
||||||
#include <catch2/internal/catch_enforce.hpp>
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
#include <catch2/internal/catch_platform.hpp>
|
#include <catch2/internal/catch_parse_numbers.hpp>
|
||||||
|
#include <catch2/internal/catch_stdstreams.hpp>
|
||||||
#include <catch2/internal/catch_stringref.hpp>
|
#include <catch2/internal/catch_stringref.hpp>
|
||||||
#include <catch2/internal/catch_string_manip.hpp>
|
#include <catch2/internal/catch_string_manip.hpp>
|
||||||
#include <catch2/internal/catch_test_spec_parser.hpp>
|
#include <catch2/internal/catch_test_spec_parser.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
|
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
|
||||||
|
#include <catch2/internal/catch_getenv.hpp>
|
||||||
|
|
||||||
namespace {
|
#include <fstream>
|
||||||
bool provideBazelReporterOutput() {
|
|
||||||
#if defined(CATCH_CONFIG_BAZEL_SUPPORT)
|
|
||||||
return true;
|
|
||||||
#elif defined(CATCH_PLATFORM_WINDOWS_UWP)
|
|
||||||
// UWP does not support environment variables
|
|
||||||
return false;
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Catch {
|
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,
|
bool operator==( ProcessedReporterSpec const& lhs,
|
||||||
ProcessedReporterSpec const& rhs ) {
|
ProcessedReporterSpec const& rhs ) {
|
||||||
return lhs.name == rhs.name &&
|
return lhs.name == rhs.name &&
|
||||||
@@ -62,18 +105,7 @@ namespace Catch {
|
|||||||
elem = trim(elem);
|
elem = trim(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert the default reporter if user hasn't asked for a specific one
|
||||||
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() ) {
|
if ( m_data.reporterSpecifications.empty() ) {
|
||||||
m_data.reporterSpecifications.push_back( {
|
m_data.reporterSpecifications.push_back( {
|
||||||
#if defined( CATCH_CONFIG_DEFAULT_REPORTER )
|
#if defined( CATCH_CONFIG_DEFAULT_REPORTER )
|
||||||
@@ -85,29 +117,21 @@ namespace Catch {
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(CATCH_PLATFORM_WINDOWS_UWP)
|
if ( enableBazelEnvSupport() ) {
|
||||||
if(provideBazelReporterOutput()){
|
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.
|
// Bazel support can modify the test specs, so parsing has to happen
|
||||||
// This allows the XML output file to contain higher level of detail
|
// after reading Bazel env vars.
|
||||||
// than what is possible otherwise.
|
TestSpecParser parser( ITagAliasRegistry::get() );
|
||||||
# if defined( _MSC_VER )
|
if ( !m_data.testsOrTags.empty() ) {
|
||||||
// On Windows getenv throws a warning as there is no input validation,
|
m_hasTestFilters = true;
|
||||||
// since the key is hardcoded, this should not be an issue.
|
for ( auto const& testOrTags : m_data.testsOrTags ) {
|
||||||
# pragma warning( push )
|
parser.parse( testOrTags );
|
||||||
# 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 ), {}, {} } );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
m_testSpec = parser.testSpec();
|
||||||
|
|
||||||
|
|
||||||
// We now fixup the reporter specs to handle default output spec,
|
// We now fixup the reporter specs to handle default output spec,
|
||||||
// default colour spec, etc
|
// default colour spec, etc
|
||||||
@@ -187,4 +211,37 @@ namespace Catch {
|
|||||||
unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; }
|
unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; }
|
||||||
std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); }
|
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
|
} // end namespace Catch
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -140,6 +140,9 @@ namespace Catch {
|
|||||||
std::chrono::milliseconds benchmarkWarmupTime() const override;
|
std::chrono::milliseconds benchmarkWarmupTime() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Reads Bazel env vars and applies them to the config
|
||||||
|
void readBazelEnvVars();
|
||||||
|
|
||||||
ConfigData m_data;
|
ConfigData m_data;
|
||||||
std::vector<ProcessedReporterSpec> m_processedReporterSpecs;
|
std::vector<ProcessedReporterSpec> m_processedReporterSpecs;
|
||||||
TestSpec m_testSpec;
|
TestSpec m_testSpec;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -19,8 +19,8 @@ namespace Catch {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
ScopedMessage::ScopedMessage( MessageBuilder const& builder ):
|
ScopedMessage::ScopedMessage( MessageBuilder&& builder ):
|
||||||
m_info( builder.m_info ) {
|
m_info( CATCH_MOVE(builder.m_info) ) {
|
||||||
m_info.message = builder.m_stream.str();
|
m_info.message = builder.m_stream.str();
|
||||||
getResultCapture().pushScopedMessage( m_info );
|
getResultCapture().pushScopedMessage( m_info );
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {
|
Capturer::Capturer( StringRef macroName,
|
||||||
|
SourceLineInfo const& lineInfo,
|
||||||
|
ResultWas::OfType resultType,
|
||||||
|
StringRef names ):
|
||||||
|
m_resultCapture( getResultCapture() ) {
|
||||||
auto trimmed = [&] (size_t start, size_t end) {
|
auto trimmed = [&] (size_t start, size_t end) {
|
||||||
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
|
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
|
||||||
++start;
|
++start;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||||
#include <catch2/internal/catch_stream_end_stop.hpp>
|
#include <catch2/internal/catch_stream_end_stop.hpp>
|
||||||
#include <catch2/internal/catch_message_info.hpp>
|
#include <catch2/internal/catch_message_info.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
|
||||||
#include <catch2/catch_tostring.hpp>
|
#include <catch2/catch_tostring.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -21,6 +20,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct SourceLineInfo;
|
struct SourceLineInfo;
|
||||||
|
class IResultCapture;
|
||||||
|
|
||||||
struct MessageStream {
|
struct MessageStream {
|
||||||
|
|
||||||
@@ -39,11 +39,10 @@ namespace Catch {
|
|||||||
ResultWas::OfType type ):
|
ResultWas::OfType type ):
|
||||||
m_info(macroName, lineInfo, type) {}
|
m_info(macroName, lineInfo, type) {}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MessageBuilder& operator << ( T const& value ) {
|
MessageBuilder&& operator << ( T const& value ) && {
|
||||||
m_stream << value;
|
m_stream << value;
|
||||||
return *this;
|
return CATCH_MOVE(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageInfo m_info;
|
MessageInfo m_info;
|
||||||
@@ -51,7 +50,7 @@ namespace Catch {
|
|||||||
|
|
||||||
class ScopedMessage {
|
class ScopedMessage {
|
||||||
public:
|
public:
|
||||||
explicit ScopedMessage( MessageBuilder const& builder );
|
explicit ScopedMessage( MessageBuilder&& builder );
|
||||||
ScopedMessage( ScopedMessage& duplicate ) = delete;
|
ScopedMessage( ScopedMessage& duplicate ) = delete;
|
||||||
ScopedMessage( ScopedMessage&& old ) noexcept;
|
ScopedMessage( ScopedMessage&& old ) noexcept;
|
||||||
~ScopedMessage();
|
~ScopedMessage();
|
||||||
@@ -62,7 +61,7 @@ namespace Catch {
|
|||||||
|
|
||||||
class Capturer {
|
class Capturer {
|
||||||
std::vector<MessageInfo> m_messages;
|
std::vector<MessageInfo> m_messages;
|
||||||
IResultCapture& m_resultCapture = getResultCapture();
|
IResultCapture& m_resultCapture;
|
||||||
size_t m_captured = 0;
|
size_t m_captured = 0;
|
||||||
public:
|
public:
|
||||||
Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names );
|
Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names );
|
||||||
@@ -98,12 +97,15 @@ namespace Catch {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \
|
#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \
|
||||||
Catch::Capturer varName( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \
|
Catch::Capturer varName( macroName##_catch_sr, \
|
||||||
|
CATCH_INTERNAL_LINEINFO, \
|
||||||
|
Catch::ResultWas::Info, \
|
||||||
|
#__VA_ARGS__##_catch_sr ); \
|
||||||
varName.captureValues( 0, __VA_ARGS__ )
|
varName.captureValues( 0, __VA_ARGS__ )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_INFO( macroName, log ) \
|
#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 ) \
|
#define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
#include <catch2/internal/catch_noncopyable.hpp>
|
#include <catch2/internal/catch_noncopyable.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@@ -31,7 +34,7 @@ namespace Catch {
|
|||||||
|
|
||||||
public: // IRegistryHub
|
public: // IRegistryHub
|
||||||
RegistryHub() = default;
|
RegistryHub() = default;
|
||||||
IReporterRegistry const& getReporterRegistry() const override {
|
ReporterRegistry const& getReporterRegistry() const override {
|
||||||
return m_reporterRegistry;
|
return m_reporterRegistry;
|
||||||
}
|
}
|
||||||
ITestCaseRegistry const& getTestCaseRegistry() const override {
|
ITestCaseRegistry const& getTestCaseRegistry() const override {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -13,13 +13,13 @@
|
|||||||
#include <catch2/internal/catch_run_context.hpp>
|
#include <catch2/internal/catch_run_context.hpp>
|
||||||
#include <catch2/catch_test_spec.hpp>
|
#include <catch2/catch_test_spec.hpp>
|
||||||
#include <catch2/catch_version.hpp>
|
#include <catch2/catch_version.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
|
||||||
#include <catch2/internal/catch_startup_exception_registry.hpp>
|
#include <catch2/internal/catch_startup_exception_registry.hpp>
|
||||||
#include <catch2/internal/catch_sharding.hpp>
|
#include <catch2/internal/catch_sharding.hpp>
|
||||||
|
#include <catch2/internal/catch_test_case_registry_impl.hpp>
|
||||||
#include <catch2/internal/catch_textflow.hpp>
|
#include <catch2/internal/catch_textflow.hpp>
|
||||||
#include <catch2/internal/catch_windows_h_proxy.hpp>
|
#include <catch2/internal/catch_windows_h_proxy.hpp>
|
||||||
#include <catch2/reporters/catch_reporter_multi.hpp>
|
#include <catch2/reporters/catch_reporter_multi.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
|
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
#include <catch2/internal/catch_stdstreams.hpp>
|
#include <catch2/internal/catch_stdstreams.hpp>
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <exception>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@@ -341,6 +342,12 @@ namespace Catch {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( totals.testCases.total() > 0 &&
|
||||||
|
totals.testCases.total() == totals.testCases.skipped
|
||||||
|
&& !m_config->zeroTestsCountAsSuccess() ) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
// Note that on unices only the lower 8 bits are usually used, clamping
|
// Note that on unices only the lower 8 bits are usually used, clamping
|
||||||
// the return value to 255 prevents false negative when some multiple
|
// the return value to 255 prevents false negative when some multiple
|
||||||
// of 256 tests has failed
|
// of 256 tests has failed
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -139,12 +139,20 @@ namespace Catch {
|
|||||||
for (size_t idx = 0; idx < originalTags.size(); ++idx) {
|
for (size_t idx = 0; idx < originalTags.size(); ++idx) {
|
||||||
auto c = originalTags[idx];
|
auto c = originalTags[idx];
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
assert(!inTag);
|
CATCH_ENFORCE(
|
||||||
|
!inTag,
|
||||||
|
"Found '[' inside a tag while registering test case '"
|
||||||
|
<< _nameAndTags.name << "' at " << _lineInfo );
|
||||||
|
|
||||||
inTag = true;
|
inTag = true;
|
||||||
tagStart = idx;
|
tagStart = idx;
|
||||||
}
|
}
|
||||||
if (c == ']') {
|
if (c == ']') {
|
||||||
assert(inTag);
|
CATCH_ENFORCE(
|
||||||
|
inTag,
|
||||||
|
"Found unmatched ']' while registering test case '"
|
||||||
|
<< _nameAndTags.name << "' at " << _lineInfo );
|
||||||
|
|
||||||
inTag = false;
|
inTag = false;
|
||||||
tagEnd = idx;
|
tagEnd = idx;
|
||||||
assert(tagStart < tagEnd);
|
assert(tagStart < tagEnd);
|
||||||
@@ -153,7 +161,11 @@ namespace Catch {
|
|||||||
// it over to backing storage and actually reference the
|
// it over to backing storage and actually reference the
|
||||||
// backing storage in the saved tags
|
// backing storage in the saved tags
|
||||||
StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1);
|
StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1);
|
||||||
CATCH_ENFORCE(!tagStr.empty(), "Empty tags are not allowed");
|
CATCH_ENFORCE( !tagStr.empty(),
|
||||||
|
"Found an empty tag while registering test case '"
|
||||||
|
<< _nameAndTags.name << "' at "
|
||||||
|
<< _lineInfo );
|
||||||
|
|
||||||
enforceNotReservedTag(tagStr, lineInfo);
|
enforceNotReservedTag(tagStr, lineInfo);
|
||||||
properties |= parseSpecialTag(tagStr);
|
properties |= parseSpecialTag(tagStr);
|
||||||
// When copying a tag to the backing storage, we need to
|
// When copying a tag to the backing storage, we need to
|
||||||
@@ -167,8 +179,12 @@ namespace Catch {
|
|||||||
// the tags.
|
// the tags.
|
||||||
internalAppendTag(tagStr);
|
internalAppendTag(tagStr);
|
||||||
}
|
}
|
||||||
(void)inTag; // Silence "set-but-unused" warning in release mode.
|
|
||||||
}
|
}
|
||||||
|
CATCH_ENFORCE( !inTag,
|
||||||
|
"Found an unclosed tag while registering test case '"
|
||||||
|
<< _nameAndTags.name << "' at " << _lineInfo );
|
||||||
|
|
||||||
|
|
||||||
// Add [.] if relevant
|
// Add [.] if relevant
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
internalAppendTag("."_sr);
|
internalAppendTag("."_sr);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||||
#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||||
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||||
|
#define CATCH_SKIP( ... ) INTERNAL_CATCH_MSG( "SKIP", Catch::ResultWas::ExplicitSkip, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||||
|
|
||||||
|
|
||||||
#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
|
#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
|
||||||
@@ -102,6 +103,7 @@
|
|||||||
#define CATCH_FAIL( ... ) (void)(0)
|
#define CATCH_FAIL( ... ) (void)(0)
|
||||||
#define CATCH_FAIL_CHECK( ... ) (void)(0)
|
#define CATCH_FAIL_CHECK( ... ) (void)(0)
|
||||||
#define CATCH_SUCCEED( ... ) (void)(0)
|
#define CATCH_SUCCEED( ... ) (void)(0)
|
||||||
|
#define CATCH_SKIP( ... ) (void)(0)
|
||||||
|
|
||||||
#define CATCH_STATIC_REQUIRE( ... ) (void)(0)
|
#define CATCH_STATIC_REQUIRE( ... ) (void)(0)
|
||||||
#define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0)
|
#define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0)
|
||||||
@@ -146,6 +148,7 @@
|
|||||||
#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||||
#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||||
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||||
|
#define SKIP( ... ) INTERNAL_CATCH_MSG( "SKIP", Catch::ResultWas::ExplicitSkip, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||||
|
|
||||||
|
|
||||||
#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
|
#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
|
||||||
@@ -198,6 +201,7 @@
|
|||||||
#define FAIL( ... ) (void)(0)
|
#define FAIL( ... ) (void)(0)
|
||||||
#define FAIL_CHECK( ... ) (void)(0)
|
#define FAIL_CHECK( ... ) (void)(0)
|
||||||
#define SUCCEED( ... ) (void)(0)
|
#define SUCCEED( ... ) (void)(0)
|
||||||
|
#define SKIP( ... ) (void)(0)
|
||||||
|
|
||||||
#define STATIC_REQUIRE( ... ) (void)(0)
|
#define STATIC_REQUIRE( ... ) (void)(0)
|
||||||
#define STATIC_REQUIRE_FALSE( ... ) (void)(0)
|
#define STATIC_REQUIRE_FALSE( ... ) (void)(0)
|
||||||
|
@@ -1,17 +1,21 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#include <catch2/catch_test_spec.hpp>
|
#include <catch2/catch_test_spec.hpp>
|
||||||
|
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
||||||
|
#include <catch2/internal/catch_test_case_registry_impl.hpp>
|
||||||
|
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||||
#include <catch2/internal/catch_string_manip.hpp>
|
#include <catch2/internal/catch_string_manip.hpp>
|
||||||
#include <catch2/catch_test_case_info.hpp>
|
#include <catch2/catch_test_case_info.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@@ -35,6 +39,10 @@ namespace Catch {
|
|||||||
return m_wildcardPattern.matches( testCase.name );
|
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 )
|
TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString )
|
||||||
: Pattern( filterString )
|
: Pattern( filterString )
|
||||||
@@ -47,6 +55,10 @@ namespace Catch {
|
|||||||
Tag( m_tag ) ) != end( testCase.tags );
|
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 TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {
|
||||||
bool should_use = !testCase.isHidden();
|
bool should_use = !testCase.isHidden();
|
||||||
for (auto const& pattern : m_required) {
|
for (auto const& pattern : m_required) {
|
||||||
@@ -63,18 +75,31 @@ namespace Catch {
|
|||||||
return should_use;
|
return should_use;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TestSpec::Filter::name() const {
|
void TestSpec::Filter::serializeTo( std::ostream& out ) const {
|
||||||
std::string name;
|
bool first = true;
|
||||||
for (auto const& p : m_required) {
|
for ( auto const& pattern : m_required ) {
|
||||||
name += p->name();
|
if ( !first ) {
|
||||||
|
out << ' ';
|
||||||
|
}
|
||||||
|
out << *pattern;
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
for (auto const& p : m_forbidden) {
|
for ( auto const& pattern : m_forbidden ) {
|
||||||
name += p->name();
|
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 {
|
bool TestSpec::hasFilters() const {
|
||||||
return !m_filters.empty();
|
return !m_filters.empty();
|
||||||
}
|
}
|
||||||
@@ -83,16 +108,18 @@ namespace Catch {
|
|||||||
return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } );
|
return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const
|
TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const {
|
||||||
{
|
Matches matches;
|
||||||
Matches matches( m_filters.size() );
|
matches.reserve( m_filters.size() );
|
||||||
std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){
|
for ( auto const& filter : m_filters ) {
|
||||||
std::vector<TestCaseHandle const*> currentMatches;
|
std::vector<TestCaseHandle const*> currentMatches;
|
||||||
for( auto const& test : testCases )
|
for ( auto const& test : testCases )
|
||||||
if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) )
|
if ( isThrowSafe( test, config ) &&
|
||||||
|
filter.matches( test.getTestCaseInfo() ) )
|
||||||
currentMatches.emplace_back( &test );
|
currentMatches.emplace_back( &test );
|
||||||
return FilterMatch{ filter.name(), currentMatches };
|
matches.push_back(
|
||||||
} );
|
FilterMatch{ extractFilterName( filter ), currentMatches } );
|
||||||
|
}
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,4 +127,15 @@ namespace Catch {
|
|||||||
return m_invalidSpecs;
|
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
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
#include <catch2/internal/catch_wildcard_pattern.hpp>
|
#include <catch2/internal/catch_wildcard_pattern.hpp>
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -34,6 +35,14 @@ namespace Catch {
|
|||||||
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
||||||
std::string const& name() const;
|
std::string const& name() const;
|
||||||
private:
|
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;
|
std::string const m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,6 +51,8 @@ namespace Catch {
|
|||||||
explicit NamePattern( std::string const& name, std::string const& filterString );
|
explicit NamePattern( std::string const& name, std::string const& filterString );
|
||||||
bool matches( TestCaseInfo const& testCase ) const override;
|
bool matches( TestCaseInfo const& testCase ) const override;
|
||||||
private:
|
private:
|
||||||
|
void serializeTo( std::ostream& out ) const override;
|
||||||
|
|
||||||
WildcardPattern m_wildcardPattern;
|
WildcardPattern m_wildcardPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,6 +61,8 @@ namespace Catch {
|
|||||||
explicit TagPattern( std::string const& tag, std::string const& filterString );
|
explicit TagPattern( std::string const& tag, std::string const& filterString );
|
||||||
bool matches( TestCaseInfo const& testCase ) const override;
|
bool matches( TestCaseInfo const& testCase ) const override;
|
||||||
private:
|
private:
|
||||||
|
void serializeTo( std::ostream& out ) const override;
|
||||||
|
|
||||||
std::string m_tag;
|
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_required;
|
||||||
std::vector<Detail::unique_ptr<Pattern>> m_forbidden;
|
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;
|
bool matches( TestCaseInfo const& testCase ) const;
|
||||||
std::string name() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::string extractFilterName( Filter const& filter );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct FilterMatch {
|
struct FilterMatch {
|
||||||
std::string name;
|
std::string name;
|
||||||
@@ -77,7 +99,16 @@ namespace Catch {
|
|||||||
private:
|
private:
|
||||||
std::vector<Filter> m_filters;
|
std::vector<Filter> m_filters;
|
||||||
std::vector<std::string> m_invalidSpecs;
|
std::vector<std::string> m_invalidSpecs;
|
||||||
|
|
||||||
friend class TestSpecParser;
|
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
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
// Copyright Catch2 Authors
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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)
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// 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