Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel' into catch2-dynamic-lib
Browse files Browse the repository at this point in the history
src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp
src/catch2/interfaces/catch_interfaces_generatortracker.hpp
src/catch2/interfaces/catch_interfaces_registry_hub.hpp
src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp
src/catch2/internal/catch_case_insensitive_comparisons.hpp
src/catch2/internal/catch_fatal_condition_handler.cpp
src/catch2/internal/catch_fatal_condition_handler.hpp
src/catch2/internal/catch_istream.cpp
src/catch2/internal/catch_preprocessor_remove_parens.hpp
src/catch2/internal/catch_reusable_string_stream.hpp
src/catch2/internal/catch_test_case_registry_impl.cpp
src/catch2/internal/catch_test_case_registry_impl.hpp
src/catch2/matchers/catch_matchers_floating_point.hpp
src/catch2/matchers/internal/catch_matchers_combined_tu.cpp
src/catch2/reporters/catch_reporter_cumulative_base.cpp
src/catch2/reporters/catch_reporter_cumulative_base.hpp
src/catch2/reporters/catch_reporter_streaming_base.hpp
tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp
tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp
tests/ExtraTests/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp
tests/ExtraTests/X27-CapturedStdoutInTestCaseEvents.cpp
tests/ExtraTests/X28-ListenersGetEventsBeforeReporters.cpp
tests/SelfTest/Baselines/automake.sw.multi.approved.txt
tests/SelfTest/Baselines/compact.sw.multi.approved.txt
tests/SelfTest/Baselines/console.sw.multi.approved.txt
tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt
tests/SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp
tests/SelfTest/IntrospectiveTests/ColourImpl.tests.cpp
tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
tests/SelfTest/IntrospectiveTests/TestCaseInfoHasher.tests.cpp
  • Loading branch information
codeinred committed Apr 27, 2022
2 parents e6e0d4e + 9dc2296 commit e3bbb01
Show file tree
Hide file tree
Showing 164 changed files with 5,229 additions and 2,565 deletions.
4 changes: 4 additions & 0 deletions .bazelrc
@@ -0,0 +1,4 @@
build:gcc9 --cxxopt=-std=c++2a
build:clang13 --cxxopt=-std=c++17
build:vs2019 --cxxopt=/std:c++17
build:vs2022 --cxxopt=/std:c++17
13 changes: 11 additions & 2 deletions .github/workflows/linux-other-builds.yml
Expand Up @@ -56,9 +56,18 @@ jobs:
build_description: CMake configuration tests
build_type: Debug
std: 14
other_pks: clang-10
other_pkgs: clang-10
cmake_configurations: -DCATCH_ENABLE_CONFIGURE_TESTS=ON

# Valgrind test Clang-10
- cxx: clang++-10
build_description: Valgrind tests
build_type: Debug
std: 14
other_pkgs: clang-10 valgrind
cmake_configurations: -DMEMORYCHECK_COMMAND=`which valgrind` -DMEMORYCHECK_COMMAND_OPTIONS="-q --track-origins=yes --leak-check=full --num-callers=50 --show-leak-kinds=definite --error-exitcode=1"
other_ctest_args: -T memcheck -LE uses-python


steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -91,4 +100,4 @@ jobs:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{runner.workspace}}/build
# Hardcode 2 cores we know are there
run: ctest -C ${{matrix.build_type}} -j 2
run: ctest -C ${{matrix.build_type}} -j 2 ${{matrix.other_ctest_args}}
40 changes: 26 additions & 14 deletions BUILD.bazel
@@ -1,16 +1,15 @@
# Load the cc_library rule.
load("@rules_cc//cc:defs.bzl", "cc_library")

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")

expand_template(
name = "catch_user_config.hpp",
name = "catch_user_config",
out = "catch2/catch_user_config.hpp",
substitutions = {
"#cmakedefine CATCH_CONFIG_ANDROID_LOGWRITE": "",
"#cmakedefine CATCH_CONFIG_COLOUR_ANSI": "",
"#cmakedefine CATCH_CONFIG_COLOUR_NONE": "",
"#cmakedefine CATCH_CONFIG_COLOUR_WINDOWS": "",
"#cmakedefine CATCH_CONFIG_BAZEL_SUPPORT": "#define CATCH_CONFIG_BAZEL_SUPPORT",
"#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "",
"#cmakedefine CATCH_CONFIG_COLOUR_WIN32": "",
"#cmakedefine CATCH_CONFIG_COUNTER": "",
"#cmakedefine CATCH_CONFIG_CPP11_TO_STRING": "",
"#cmakedefine CATCH_CONFIG_CPP17_BYTE": "",
Expand Down Expand Up @@ -57,23 +56,36 @@ expand_template(
template = "src/catch2/catch_user_config.hpp.in",
)

# Generated header library, modifies the include prefix to account for
# generation path so that we can include <catch2/catch_user_config.hpp>
# correctly.
cc_library(
name = "catch2_generated",
hdrs = ["catch2/catch_user_config.hpp"],
include_prefix = ".", # to manipulate -I of dependenices
visibility = ["//visibility:public"],
)

# Static library, without main.
cc_library(
name = "catch2",
hdrs = glob(["src/catch2/**/*.hpp"]) + ["catch_user_config.hpp"],
srcs = glob(["src/catch2/**/*.cpp"],
exclude=[ "src/catch2/internal/catch_main.cpp"]),
visibility = ["//visibility:public"],
linkstatic = True,
srcs = glob(
["src/catch2/**/*.cpp"],
exclude = ["src/catch2/internal/catch_main.cpp"],
),
hdrs = glob(["src/catch2/**/*.hpp"]),
includes = ["src/"],
linkstatic = True,
visibility = ["//visibility:public"],
deps = [":catch2_generated"],
)

# Static library, with main.
cc_library(
name = "catch2_main",
srcs = ["src/catch2/internal/catch_main.cpp"],
deps = [":catch2"],
visibility = ["//visibility:public"],
linkstatic = True,
includes = ["src/"],
)
linkstatic = True,
visibility = ["//visibility:public"],
deps = [":catch2"],
)
5 changes: 2 additions & 3 deletions CMake/CatchConfigOptions.cmake
Expand Up @@ -26,6 +26,8 @@ endmacro()

set(_OverridableOptions
"ANDROID_LOGWRITE"
"BAZEL_SUPPORT"
"COLOUR_WIN32"
"COUNTER"
"CPP11_TO_STRING"
"CPP17_BYTE"
Expand All @@ -45,9 +47,6 @@ foreach(OptionName ${_OverridableOptions})
endforeach()

set(_OtherConfigOptions
"COLOUR_ANSI"
"COLOUR_NONE"
"COLOUR_WINDOWS"
"DISABLE_EXCEPTIONS"
"DISABLE_EXCEPTIONS_CUSTOM_HANDLER"
"DISABLE"
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Expand Up @@ -96,9 +96,6 @@ if (CATCH_DEVELOPMENT_BUILD)
endif()


#option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
#option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON)
#
#set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#
#
Expand Down
11 changes: 7 additions & 4 deletions WORKSPACE
@@ -1,11 +1,14 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
strip_prefix = "bazel-skylib-2a87d4a62af886fb320883aba102255aba87275e",
urls = [
"https://github.com/Vertexwahn/bazel-skylib/archive/b0cd4bbd4bf4af76c380e1f8fafdbe3964161aff.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/archive/2a87d4a62af886fb320883aba102255aba87275e.tar.gz",
],
strip_prefix = "bazel-skylib-b0cd4bbd4bf4af76c380e1f8fafdbe3964161aff",
sha256 = "e57f3ff541c65678f3c2b344c73945531838e86ea0be71c63eea862ab43e792b",
sha256 = "d847b08d6702d2779e9eb399b54ff8920fa7521dc45e3e53572d1d8907767de7",
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()

bazel_skylib_workspace()
95 changes: 74 additions & 21 deletions docs/command-line.md
Expand Up @@ -19,6 +19,7 @@
[Specify a seed for the Random Number Generator](#specify-a-seed-for-the-random-number-generator)<br>
[Identify framework and version according to the libIdentify standard](#identify-framework-and-version-according-to-the-libidentify-standard)<br>
[Wait for key before continuing](#wait-for-key-before-continuing)<br>
[Skip all benchmarks](#skip-all-benchmarks)<br>
[Specify the number of benchmark samples to collect](#specify-the-number-of-benchmark-samples-to-collect)<br>
[Specify the number of resamples for bootstrapping](#specify-the-number-of-resamples-for-bootstrapping)<br>
[Specify the confidence-interval for bootstrapping](#specify-the-confidence-interval-for-bootstrapping)<br>
Expand Down Expand Up @@ -62,12 +63,13 @@ Click one of the following links to take you straight to that option - or scroll
<a href="#rng-seed"> ` --rng-seed`</a><br />
<a href="#libidentify"> ` --libidentify`</a><br />
<a href="#wait-for-keypress"> ` --wait-for-keypress`</a><br />
<a href="#skip-benchmarks"> ` --skip-benchmarks`</a><br />
<a href="#benchmark-samples"> ` --benchmark-samples`</a><br />
<a href="#benchmark-resamples"> ` --benchmark-resamples`</a><br />
<a href="#benchmark-confidence-interval"> ` --benchmark-confidence-interval`</a><br />
<a href="#benchmark-no-analysis"> ` --benchmark-no-analysis`</a><br />
<a href="#benchmark-warmup-time"> ` --benchmark-warmup-time`</a><br />
<a href="#use-colour"> ` --use-colour`</a><br />
<a href="#colour-mode"> ` --colour-mode`</a><br />
<a href="#test-sharding"> ` --shard-count`</a><br />
<a href="#test-sharding"> ` --shard-index`</a><br />
<a href=#no-tests-override> ` --allow-running-no-tests`</a><br />
Expand Down Expand Up @@ -123,22 +125,33 @@ Test names containing special characters, such as `,` or `[` can specify them on
<a id="choosing-a-reporter-to-use"></a>
## Choosing a reporter to use

<pre>-r, --reporter &lt;reporter[::output-file]&gt;</pre>

> Support for providing output-file through the `-r`, `--reporter` flag was [introduced](https://github.com/catchorg/Catch2/pull/2183) in Catch2 X.Y.Z
<pre>-r, --reporter &lt;reporter[::key=value]*&gt;</pre>

Reporters are how the output from Catch2 (results of assertions, tests,
benchmarks and so on) is formatted and written out. The default reporter
is called the "Console" reporter and is intended to provide relatively
verbose and human-friendly output.

Reporters are also individually configurable. To pass configuration options
to the reporter, you append `::key=value` to the reporter specification
as many times as you want, e.g. `--reporter xml::out=someFile.xml`.

The keys must either be prefixed by "X", in which case they are not parsed
by Catch2 and are only passed down to the reporter, or one of options
hardcoded into Catch2. Currently there are only 2,
["out"](#sending-output-to-a-file), and ["colour-mode"](#colour-mode).

_Note that the reporter might still check the X-prefixed options for
validity, and throw an error if they are wrong._

> Support for passing arguments to reporters through the `-r`, `--reporter` flag was introduced in Catch2 X.Y.Z
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)
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
documentation](reporters.md#writing-your-own-reporter).


This option may be passed multiple times to use multiple (different)
reporters at the same time. See the [reporter documentation](reporters.md#multiple-reporters)
for details on what the resulting behaviour is. Also note that at most one
Expand All @@ -148,13 +161,12 @@ the [`-o`, `--out`](#sending-output-to-a-file) option.

> Support for using multiple different reporters at the same time was [introduced](https://github.com/catchorg/Catch2/pull/2183) in Catch2 X.Y.Z
As with the `--out` option, using `-` for the output file name sends the
output to stdout.

_Note: There is currently no way to escape `::` in the reporter spec,
and thus reporter/file names with `::` in them will not work properly.
As `::` in paths is relatively obscure (unlike `:`), we do not consider
this an issue._
and thus the reporter names, or configuration keys and values, cannot
contain `::`. As `::` in paths is relatively obscure (unlike ':'), we do
not consider this an issue._


<a id="breaking-into-the-debugger"></a>
## Breaking into the debugger
Expand Down Expand Up @@ -208,12 +220,24 @@ similar information.
<pre>-o, --out &lt;filename&gt;
</pre>

Use this option to send all output to a file. By default output is sent to stdout (note that uses of stdout and stderr *from within test cases* are redirected and included in the report - so even stderr will effectively end up on stdout).

Using `-` as the filename sends the output to stdout.
Use this option to send all output to a file, instead of stdout. You can
use `-` as the filename to explicitly send the output to stdout (this is
useful e.g. when using multiple reporters).

> Support for `-` as the filename was introduced in Catch2 X.Y.Z
Filenames starting with "%" (percent symbol) are reserved by Catch2 for
meta purposes, e.g. using `%debug` as the filename opens stream that
writes to platform specific debugging/logging mechanism.

Catch2 currently recognizes 3 meta streams:

* `%debug` - writes to platform specific debugging/logging output
* `%stdout` - writes to stdout
* `%stderr` - writes to stderr

> Support for `%stdout` and `%stderr` was introduced in Catch2 X.Y.Z

<a id="naming-a-test-run"></a>
## Naming a test run
Expand Down Expand Up @@ -310,13 +334,19 @@ Lexicographic order. Tests are sorted by their name, their tags are ignored.

### rand

Randomly sorted. The order is dependent on Catch2's random seed (see
Randomly ordered. The order is dependent on Catch2's random seed (see
[`--rng-seed`](#rng-seed)), and is subset invariant. What this means
is that as long as the random seed is fixed, running only some tests
(e.g. via tag) does not change their relative order.

> The subset stability was introduced in Catch2 v2.12.0
Since the random order was made subset stable, we promise that given
the same random seed, the order of test cases will be the same across
different platforms, as long as the tests were compiled against identical
version of Catch2. We reserve the right to change the relative order
of tests cases between Catch2 versions, but it is unlikely to happen often.


<a id="rng-seed"></a>
## Specify a seed for the Random Number Generator
Expand Down Expand Up @@ -348,6 +378,16 @@ See [The LibIdentify repo for more information and examples](https://github.com/
Will cause the executable to print a message and wait until the return/ enter key is pressed before continuing -
either before running any tests, after running all tests - or both, depending on the argument.

<a id="skip-benchmarks"></a>
## Skip all benchmarks
<pre>--skip-benchmarks</pre>

> [Introduced](https://github.com/catchorg/Catch2/issues/2408) in Catch X.Y.Z.
This flag tells Catch2 to skip running all benchmarks. Benchmarks in this
case mean code blocks in `BENCHMARK` and `BENCHMARK_ADVANCED` macros, not
test cases with the `[!benchmark]` tag.

<a id="benchmark-samples"></a>
## Specify the number of benchmark samples to collect
<pre>--benchmark-samples &lt;# of samples&gt;</pre>
Expand Down Expand Up @@ -457,16 +497,29 @@ filename it is found in, with any extension stripped, prefixed with the `#` char

So, for example, tests within the file `~\Dev\MyProject\Ferrets.cpp` would be tagged `[#Ferrets]`.

<a id="use-colour"></a>
<a id="colour-mode"></a>
## Override output colouring
<pre>--use-colour &lt;yes|no|auto&gt;</pre>
<pre>--colour-mode &lt;ansi|win32|none|default&gt;</pre>

> The `--colour-mode` option replaced the old `--colour` option in Catch2 X.Y.Z

Catch2 support two different ways of colouring terminal output, and by
default it attempts to make a good guess on which implementation to use
(and whether to even use it, e.g. Catch2 tries to avoid writing colour
codes when writing the results into a file).

`--colour-mode` allows the user to explicitly select what happens.

* `--colour-mode ansi` tells Catch2 to always use ANSI colour codes, even
when writing to a file
* `--colour-mode win32` tells Catch2 to use colour implementation based
on Win32 terminal API
* `--colour-mode none` tells Catch2 to disable colours completely
* `--colour-mode default` lets Catch2 decide

Catch colours output for terminals, but omits colouring when it detects that
output is being sent to a pipe. This is done to avoid interfering with automated
processing of output.
`--colour-mode default` is the default setting.

`--use-colour yes` forces coloured output, `--use-colour no` disables coloured
output. The default behaviour is `--use-colour auto`.

<a id="test-sharding"></a>
## Test Sharding
Expand Down
24 changes: 15 additions & 9 deletions docs/configuration.md
Expand Up @@ -8,6 +8,7 @@
[stdout](#stdout)<br>
[Fallback stringifier](#fallback-stringifier)<br>
[Default reporter](#default-reporter)<br>
[Bazel support](#bazel-support)<br>
[C++11 toggles](#c11-toggles)<br>
[C++17 toggles](#c17-toggles)<br>
[Other toggles](#other-toggles)<br>
Expand All @@ -31,19 +32,18 @@ To keep test code clean and uncluttered Catch uses short macro names (e.g. ```TE

## Terminal colour

CATCH_CONFIG_COLOUR_NONE // completely disables all text colouring
CATCH_CONFIG_COLOUR_WINDOWS // forces the Win32 console API to be used
CATCH_CONFIG_COLOUR_ANSI // forces ANSI colour codes to be used
CATCH_CONFIG_COLOUR_WIN32 // Force enables compiling colouring impl based on Win32 console API
CATCH_CONFIG_NO_COLOUR_WIN32 // Force disables ...

Yes, I am English, so I will continue to spell "colour" with a 'u'.
Yes, Catch2 uses the british spelling of colour.

When sending output to the terminal, if it detects that it can, Catch will use colourised text. On Windows the Win32 API, ```SetConsoleTextAttribute```, is used. On POSIX systems ANSI colour escape codes are inserted into the stream.
Catch2 attempts to autodetect whether the Win32 console colouring API,
`SetConsoleTextAttribute`, is available, and if it is available it compiles
in a console colouring implementation that uses it.

For finer control you can define one of the above identifiers (these are mutually exclusive - but that is not checked so may behave unexpectedly if you mix them):
This option can be used to override Catch2's autodetection and force the
compilation either ON or OFF.

Note that when ANSI colour codes are used "unistd.h" must be includable - along with a definition of ```isatty()```

Typically you should place the ```#define``` before #including "catch.hpp" in your main source file - but if you prefer you can define it for your whole project by whatever your IDE or build system provides for you to do so.

## Console width

Expand Down Expand Up @@ -97,6 +97,12 @@ This means that defining `CATCH_CONFIG_DEFAULT_REPORTER` to `"console"`
is equivalent with the out-of-the-box experience.


## Bazel support
When `CATCH_CONFIG_BAZEL_SUPPORT` is defined, Catch2 will register a `JUnit`
reporter writing to a path pointed by `XML_OUTPUT_FILE` provided by Bazel.

> `CATCH_CONFIG_BAZEL_SUPPORT` was [introduced](https://github.com/catchorg/Catch2/pull/2399) in Catch2 X.Y.Z.
## C++11 toggles

CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string`
Expand Down

0 comments on commit e3bbb01

Please sign in to comment.