Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Catch2 v3.2.1 #1861

Merged
merged 1 commit into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions thirdParty/CMakeLists.txt
Expand Up @@ -10,7 +10,7 @@

if(BUILD_TESTING)
if(alpaka_USE_INTERNAL_CATCH2)
message(STATUS "Catch2: Using INTERNAL version 3.1.1")
message(STATUS "Catch2: Using INTERNAL version 3.2.1")
# Force Catch2's CMake to pick up the variables we set below
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

Expand All @@ -27,7 +27,7 @@ if(BUILD_TESTING)
add_compile_definitions($<$<CXX_COMPILER_ID:PGI>:__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1>)
add_subdirectory(catch2)
else()
find_package(Catch2 3.1.1 CONFIG REQUIRED)
find_package(Catch2 3.2.1 CONFIG REQUIRED)
j-stephan marked this conversation as resolved.
Show resolved Hide resolved
message(STATUS "Catch2: Found version ${Catch2_VERSION}")
endif()
endif()
endif()
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
17 changes: 17 additions & 0 deletions thirdParty/catch2/.github/workflows/linux-simple-builds.yml
Expand Up @@ -65,6 +65,22 @@ jobs:
build_type: Release
std: 17
other_pkgs: clang-10
- cxx: clang++-10
build_type: Debug
std: 20
other_pkgs: clang-10
- cxx: clang++-10
build_type: Release
std: 20
other_pkgs: clang-10
- cxx: g++-10
build_type: Debug
std: 20
other_pkgs: g++-10
- cxx: g++-10
build_type: Release
std: 20
other_pkgs: g++-10

steps:
- uses: actions/checkout@v2
Expand All @@ -89,6 +105,7 @@ jobs:
cmake -Bbuild -H$GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCATCH_DEVELOPMENT_BUILD=ON \
-G Ninja
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.1 # CML version placeholder, don't delete
LANGUAGES CXX
# HOMEPAGE_URL is not supported until CMake version 3.12, which
# we do not target yet.
Expand Down
69 changes: 58 additions & 11 deletions thirdParty/catch2/README.md
@@ -1,5 +1,5 @@
<a id="top"></a>
![Catch2 logo](data/artwork/catch2-logo-small.png)
![Catch2 logo](data/artwork/catch2-logo-small-with-background.png)

[![Github Releases](https://img.shields.io/github/release/catchorg/catch2.svg)](https://github.com/catchorg/catch2/releases)
[![Linux build status](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml/badge.svg)](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml)
Expand All @@ -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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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