Skip to content

Commit

Permalink
Update to Catch2 v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Third Party authored and j-stephan committed Dec 9, 2022
1 parent 4b50b39 commit d0076f1
Show file tree
Hide file tree
Showing 418 changed files with 3,612 additions and 7,421 deletions.
25 changes: 22 additions & 3 deletions thirdParty/catch2/.clang-format
@@ -1,4 +1,26 @@
---
Language: Cpp
Standard: c++14

# Note that we cannot use IncludeIsMainRegex functionality, because it
# does not support includes in angle brackets (<>)
SortIncludes: True
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '<catch2/.*\.hpp>'
Priority: 1
- Regex: '<.*/.*\.hpp>'
Priority: 2
- Regex: '<.*>'
Priority: 3


AllowShortBlocksOnASingleLine: Always
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: Inline

AccessModifierOffset: '-4'
AlignEscapedNewlines: Left
AllowAllConstructorInitializersOnNextLine: 'true'
Expand All @@ -8,17 +30,14 @@ BreakConstructorInitializers: AfterColon
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
DerivePointerAlignment: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWidth: '4'
Language: Cpp
NamespaceIndentation: All
PointerAlignment: Left
SpaceBeforeCtorInitializerColon: 'false'
SpaceInEmptyParentheses: 'false'
SpacesInParentheses: 'true'
Standard: Cpp11
TabWidth: '4'
UseTab: Never

Expand Down
24 changes: 24 additions & 0 deletions thirdParty/catch2/.github/workflows/linux-bazel-builds.yml
@@ -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 changes: 1 addition & 1 deletion thirdParty/catch2/.github/workflows/linux-meson-builds.yml
@@ -1,4 +1,4 @@
name: Linux builds (basic) using meson build system
name: Linux builds (meson)

on: [push, pull_request]

Expand Down
1 change: 1 addition & 0 deletions thirdParty/catch2/.github/workflows/linux-other-builds.yml
Expand Up @@ -86,6 +86,7 @@ jobs:
cmake -Bbuild -H$GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCATCH_DEVELOPMENT_BUILD=ON \
${{matrix.cmake_configurations}} \
Expand Down
Expand Up @@ -89,6 +89,7 @@ jobs:
cmake -Bbuild -H$GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCATCH_DEVELOPMENT_BUILD=ON \
-G Ninja
Expand Down
7 changes: 5 additions & 2 deletions thirdParty/catch2/.github/workflows/mac-builds.yml
Expand Up @@ -33,8 +33,11 @@ jobs:
# This is important
run: |
cmake -Bbuild -H$GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCATCH_DEVELOPMENT_BUILD=ON \
-DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \
-DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}}
- name: Build tests + lib
Expand Down
2 changes: 2 additions & 0 deletions thirdParty/catch2/BUILD.bazel
Expand Up @@ -28,6 +28,7 @@ expand_template(
"#cmakedefine CATCH_CONFIG_EXPERIMENTAL_REDIRECT": "",
"#cmakedefine CATCH_CONFIG_FALLBACK_STRINGIFIER @CATCH_CONFIG_FALLBACK_STRINGIFIER@": "",
"#cmakedefine CATCH_CONFIG_FAST_COMPILE": "",
"#cmakedefine CATCH_CONFIG_GETENV": "",
"#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER": "",
"#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "",
"#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "",
Expand All @@ -38,6 +39,7 @@ expand_template(
"#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW": "",
"#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS": "",
"#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT": "",
"#cmakedefine CATCH_CONFIG_NO_GETENV": "",
"#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "",
"#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "",
"#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "",
Expand Down
3 changes: 2 additions & 1 deletion thirdParty/catch2/CMake/CatchConfigOptions.cmake
@@ -1,7 +1,7 @@

# Copyright Catch2 Authors
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# (See accompanying file LICENSE.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

# SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -40,6 +40,7 @@ set(_OverridableOptions
"USE_ASYNC"
"WCHAR"
"WINDOWS_SEH"
"GETENV"
)

foreach(OptionName ${_OverridableOptions})
Expand Down
4 changes: 2 additions & 2 deletions thirdParty/catch2/CMake/CatchMiscFunctions.cmake
@@ -1,7 +1,7 @@

# Copyright Catch2 Authors
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# (See accompanying file LICENSE.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

# SPDX-License-Identifier: BSL-1.0
Expand All @@ -13,7 +13,7 @@ function(add_cxx_flag_if_supported_to_targets flagname targets)

if (HAVE_FLAG_${flag_identifier})
foreach(target ${targets})
target_compile_options(${target} PUBLIC ${flagname})
target_compile_options(${target} PRIVATE ${flagname})
endforeach()
endif()
endfunction()
Expand Down
2 changes: 1 addition & 1 deletion thirdParty/catch2/CMakeLists.txt
Expand Up @@ -31,7 +31,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()

project(Catch2
VERSION 3.1.1 # CML version placeholder, don't delete
VERSION 3.2.0 # CML version placeholder, don't delete
LANGUAGES CXX
# HOMEPAGE_URL is not supported until CMake version 3.12, which
# we do not target yet.
Expand Down
67 changes: 57 additions & 10 deletions thirdParty/catch2/README.md
Expand Up @@ -11,31 +11,78 @@
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)


## What's the Catch2?
## What is Catch2?

Catch2 is mainly a unit testing framework for C++, but it also
provides basic micro-benchmarking features, and simple BDD macros.

Catch2's main advantage is that using it is both simple and natural.
Tests autoregister themselves and do not have to be named with valid
identifiers, assertions look like normal C++ code, and sections provide
a nice way to share set-up and tear-down code in tests.
Test names do not have to be valid identifiers, assertions look like
normal C++ boolean expressions, and sections provide a nice and local way
to share set-up and tear-down code in tests.

**Example unit test**
```cpp
#include <catch2/catch_test_macros.hpp>

## Catch2 v3 is being developed!
#include <cstdint>

You are on the `devel` branch, where the next major version, v3, of
Catch2 is being developed. As it is a significant rework, you will
find that parts of this documentation are likely still stuck on v2.
uint32_t factorial( uint32_t number ) {
return number <= 1 ? number : factorial(number-1) * number;
}

For stable (and documentation-matching) version of Catch2, [go to the
`v2.x` branch](https://github.com/catchorg/Catch2/tree/v2.x).
TEST_CASE( "Factorials are computed", "[factorial]" ) {
REQUIRE( factorial( 1) == 1 );
REQUIRE( factorial( 2) == 2 );
REQUIRE( factorial( 3) == 6 );
REQUIRE( factorial(10) == 3'628'800 );
}
```
**Example microbenchmark**
```cpp
#include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
#include <cstdint>
uint64_t fibonacci(uint64_t number) {
return number < 2 ? 1 : fibonacci(number - 1) + fibonacci(number - 2);
}
TEST_CASE("Benchmark Fibonacci", "[!benchmark]") {
REQUIRE(Fibonacci(5) == 5);
REQUIRE(Fibonacci(20) == 6'765);
BENCHMARK("Fibonacci 20") {
return Fibonacci(20);
};
REQUIRE(Fibonacci(25) == 75'025);
BENCHMARK("Fibonacci 25") {
return Fibonacci(25);
};
}
```

## Catch2 v3 has been released!

You are on the `devel` branch, where the v3 version is being developed.
v3 brings a bunch of significant changes, the big one being that Catch2
is no longer a single-header library. Catch2 now behaves as a normal
library, with multiple headers and separately compiled implementation.

The documentation is slowly being updated to take these changes into
account, but this work is currently still ongoing.

For migrating from the v2 releases to v3, you should look at [our
documentation](docs/migrate-v2-to-v3.md#top). It provides a simple
guidelines on getting started, and collects most common migration
problems.

For the previous major version of Catch2 [look into the `v2.x` branch
here on GitHub](https://github.com/catchorg/Catch2/tree/v2.x).


## How to use it
This documentation comprises these three parts:
Expand Down
2 changes: 1 addition & 1 deletion thirdParty/catch2/docs/Readme.md
Expand Up @@ -29,7 +29,7 @@ Once you're up and running consider the following reference material.
* [Frequently Asked Questions (FAQ)](faq.md#top)
* [Best practices and other tips](usage-tips.md#top)
* [CMake integration](cmake-integration.md#top)
* [CI and other miscellaneous pieces](ci-and-misc.md#top)
* [Tooling integration (CI, test runners, other)](ci-and-misc.md#top)
* [Known limitations](limitations.md#top)

**Other:**
Expand Down
33 changes: 30 additions & 3 deletions thirdParty/catch2/docs/ci-and-misc.md
@@ -1,8 +1,15 @@
<a id="top"></a>
# CI and other odd pieces
# Tooling integration (CI, test runners and so on)

**Contents**<br>
[Continuous Integration systems](#continuous-integration-systems)<br>
[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

Expand Down Expand Up @@ -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.


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

### CodeCoverage module (GCOV, LCOV...)
Expand Down
2 changes: 1 addition & 1 deletion thirdParty/catch2/docs/comparing-floating-point-numbers.md
Expand Up @@ -16,7 +16,7 @@ this blog post](https://codingnest.com/the-little-things-comparing-floating-poin
## 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
Expand Down
17 changes: 15 additions & 2 deletions thirdParty/catch2/docs/configuration.md
Expand Up @@ -98,13 +98,19 @@ is equivalent with the out-of-the-box experience.


## Bazel support
When `CATCH_CONFIG_BAZEL_SUPPORT` is defined or when `BAZEL_TEST=1` (which is set by the Bazel inside of a test environment),
Catch2 will register a `JUnit` reporter writing to a path pointed by `XML_OUTPUT_FILE` provided by Bazel.

Compiling Catch2 with `CATCH_CONFIG_BAZEL_SUPPORT` force-enables Catch2's
support for Bazel's environment variables (normally Catch2 looks for
`BAZEL_TEST=1` env var first).

This can be useful if you are using older versions of Bazel, that do not
yet have `BAZEL_TEST` env var support.

> `CATCH_CONFIG_BAZEL_SUPPORT` was [introduced](https://github.com/catchorg/Catch2/pull/2399) in Catch2 3.0.1.
> `CATCH_CONFIG_BAZEL_SUPPORT` was [deprecated](https://github.com/catchorg/Catch2/pull/2459) in Catch2 3.1.0.

## C++11 toggles

CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string`
Expand Down Expand Up @@ -149,13 +155,20 @@ by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`.
CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking
CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output
CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter
CATCH_CONFIG_GETENV // System has a working `getenv`

> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch2 2.10.0
> `CATCH_CONFIG_GETENV` was [introduced](https://github.com/catchorg/Catch2/pull/2562) in Catch2 3.2.0
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.

`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`).

`CATCH_CONFIG_GETENV` is on by default, except when Catch2 is compiled for
platforms that lacks working `std::getenv` (currently Windows UWP and
Playstation).

`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's
CRT is used to check for memory leaks, and displays them after the tests
finish running. This option only works when linking against the default
Expand Down
16 changes: 15 additions & 1 deletion thirdParty/catch2/docs/contributing.md
Expand Up @@ -291,7 +291,7 @@ Specifically, every source file should start with the licence header:

// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// (See accompanying file LICENSE.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)

// SPDX-License-Identifier: BSL-1.0
Expand All @@ -303,6 +303,20 @@ be `CATCH_MATCHERS_FOO_HPP_INCLUDED`, for `catch_generators_bar.hpp`, the includ
guard should be `CATCH_GENERATORS_BAR_HPP_INCLUDED`, and so on.


### Adding new `CATCH_CONFIG` option

When adding new `CATCH_CONFIG` option, there are multiple places to edit:
* `CMake/CatchConfigOptions.cmake` - this is used to generate the
configuration options in CMake, so that CMake frontends know about them.
* `docs/configuration.md` - this is where the options are documented
* `src/catch2/catch_user_config.hpp.in` - this is template for generating
`catch_user_config.hpp` which contains the materialized configuration
* `BUILD.bazel` - Bazel does not have configuration support like CMake,
and all expansions need to be done manually
* other files as needed, e.g. `catch2/internal/catch_config_foo.hpp`
for the logic that guards the configuration


## CoC

This project has a [CoC](../CODE_OF_CONDUCT.md). Please adhere to it
Expand Down

0 comments on commit d0076f1

Please sign in to comment.