Commit Graph

58 Commits

Author SHA1 Message Date
Martin Hořeňovský
d7341b5dc1
Add parseUInt utility function
There is an increasing number of places where Catch2 wants to parse
strings into numbers, but being stuck in C++14 world, we do not
have good stdlib facilities to do this (`strtoul` and `stoul`
are both bad).
2022-10-21 10:53:50 +02:00
Dimitrij Mijoski
997a7d4165 Fix running the tests with shared library on Windows.
Without this fix, the test executable fails because it can not find
the dll of Catch2.
2022-07-25 21:07:49 +02:00
Martin Hořeňovský
9c9f35068e
Normalize C++ namespace in JUnit's reporter classname field
Closes #2468
2022-07-17 19:15:20 +02:00
Martin Hořeňovský
338e4ec1f8
Force disable console colours for tests that regex check output
Fixes #2458
2022-06-14 23:24:06 +02:00
Martin Hořeňovský
ed6b38b096
Specialize XML reporter's listener listing 2022-05-10 20:58:02 +02:00
Martin Hořeňovský
5a49285e9c
Add --list-listeners option 2022-05-10 20:57:59 +02:00
Martin Hořeňovský
c65e5b6514
Add 'uses-python' label to tests using Python 2022-04-24 13:31:28 +02:00
Daniel Feist
291b35b389
Added --skip-benchmarks command-line option. (#2408)
Closes #2392

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2022-04-23 23:14:49 +02:00
Martin Hořeňovský
17a04f88d9
Always report rng seed from builtin reporters
Not all reporters use a format that supports this, so TeamCity
and Automake reporters still do not report it. The console
reporter now reports it even on successful runs, where before
it only reported the rng seed in the header, which was showed
either for failed run, or for run with `-s`.

CLoses #2065
2022-04-19 10:32:13 +02:00
Martin Hořeňovský
90e6905050
Remove no longer used CATCH_USE_VALGRIND cmake option 2022-04-18 12:14:21 +02:00
Martin Hořeňovský
be948f1fd0
Add COST property to the CMakeConfig tests 2022-04-10 21:55:52 +02:00
Martin Hořeňovský
423e1d2ebb
Integrate the new reporter specs into Catch2
This means that the CLI interface now uses the new key-value oriented
reporter spec, the common reporter base creates the colour implementation
based on the reporter-specific configuration, and it also stores the
custom configuration options for each reporter instance.

Closes #339 as it allows per-reporter forcing of ansi colour codes.
2022-04-07 12:50:08 +02:00
Martin Hořeňovský
c045733d05
Add splitReporterSpec helper 2022-04-05 12:57:33 +02:00
Daniel Feist
78e33ce51f
Added TestCaseInfoHasher and tests. (#2394)
Test case hashing includes tags and class name

As the hasher involves more code now, it was split out into its own file
and it got its own set of tests.

Closes #2304
2022-03-31 16:46:41 +02:00
Martin Hořeňovský
1a8a793178
Refactor colour handling to prepare for per-reporter colour modes
This includes always compiling the ANSI and None colour
implementations, as they don't need to touch any platform
specific APIs, and removing their respective compile-time
configuration options.

Because the Win32 colour implementation requires Win32-specific
APIs, it is still hidden behind a compile-time toggle,
`CATCH_CONFIG_COLOUR_WIN32` (renamed from `..._COLOUR_WINDOWS`).

The commandline options for colours were also changed. The
option now uses different name, and allows to select between
different implementations, rather than changing whether
the compiled-in colour implementation is used through
"yes/no/default" options.
2022-03-28 13:10:13 +02:00
Martin Hořeňovský
6227ca317e
Add tests for ColourGuard 2022-03-24 16:02:56 +01:00
Martin Hořeňovský
715cd25081
Add IStream::isStdOut 2022-02-22 15:45:51 +01:00
Martin Hořeňovský
72f0372664
Add tests for CMake configure toggles passing to Catch2 build 2022-02-20 19:32:30 +01:00
Martin Hořeňovský
a9ed2c235d
Rename MiscFunctions.cmake -> CatchMiscFunctions.cmake 2022-02-07 00:05:11 +01:00
Martin Hořeňovský
dc86d51af2
Update version string to mention Catch2 2022-01-27 20:15:05 +01:00
Martin Hořeňovský
93882f7fab Support '-' as output path for stdout 2022-01-01 14:16:12 +01:00
Martin Hořeňovský
22547a3c5f Add test for stdout pass-through behaviour in MultiReporter 2022-01-01 14:11:49 +01:00
Martin Hořeňovský
f00b6e2019
Add more tests for various less common tag-related cases 2021-12-28 00:22:53 +01:00
Martin Hořeňovský
3cc0c033e4
Allow enabling multiple warnings in one invocation 2021-12-18 20:50:05 +01:00
Martin Hořeňovský
840acedf62
Implement warning for unmatched test specs 2021-12-18 20:50:03 +01:00
Martin Hořeňovský
9f2dca5384
Exit with non-0 return code if no tests were run
A new flag, `--allow-running-no-tests` was added to override this
behaviour if exit code of 0 was desired.

This change also made `-w NoTests` obsolete, and so it has been
removed.
2021-12-18 20:50:00 +01:00
Martin Hořeňovský
08939cc8bb
Error out early if invalid test specs are provided 2021-12-18 20:49:47 +01:00
Martin Hořeňovský
931f41b4d6
Add some tests for TextFlow::Column 2021-11-01 22:51:17 +01:00
Ben Dunkin
3087e19cc7 Allow test sharding for e.g. Bazel test sharding feature
This greatly simplifies running Catch2 tests in single binary
in parallel from external test runners. Instead of having to
shard the tests by tags/test names, an external test runner
can now just ask for test shard 2 (out of X), and execute that
in single process, without having to know what tests are actually
in the shard.

Note that sharding also applies to test listing, and happens after
tests were ordered according to the `--order` feature.
2021-10-27 17:24:30 +02:00
Martin Hořeňovský
1cbbc5d2cb
Add test for !shouldfail and failed benchmarks 2021-08-21 00:06:31 +02:00
Martin Hořeňovský
0a3f511cfe
Fix inconsistencies in reporting benchmarking failures
With these changes, all these benchmarks
```cpp
BENCHMARK("Empty benchmark") {};
BENCHMARK("Throwing benchmark") {
    throw "just a plain literal, bleh";
};
BENCHMARK("Asserting benchmark") {
    REQUIRE(1 == 2);
};
BENCHMARK("FAIL'd benchmark") {
    FAIL("This benchmark only fails, nothing else");
};
```

report the respective failure and mark the outer `TEST_CASE` as
failed. Previously, the first two would not fail the `TEST_CASE`,
and the latter two would break xml reporter's formatting, because
`benchmarkFailed`, `benchmarkEnded` etc would not be be called
properly in failure cases.
2021-08-07 15:16:11 +02:00
Martin Hořeňovský
3d1cf95b32
Fix ulp distance calculation for numbers with different signs
This is a simplification of the fix proposed in #2152, with the
critical function split out so that it can be tested directly,
without having to go through the ULP matcher.

Closes #2152
2021-07-27 21:04:41 +02:00
Martin Hořeňovský
8b27041fbe
Add CMake option to generate surrogate TUs in development build
A surrogate TU is TU that includes 1 specific header, and does
nothing else. This is useful to verify that the header is
self-sufficient and does not require other headers to be included
for compilation to succeed.

Closes #2106
Closes #2166 (this is a better solution)
2021-02-19 23:22:39 +01:00
Martin Hořeňovský
971b1fc32a
--list-* flags write to target specified by the -o flag
Also added tests for the default implementations of list* reporter
helpers.

Closes #2061
2021-01-26 18:36:54 +01:00
Martin Hořeňovský
135103bacf
Arg::parse accepts plain Args as argument 2020-11-07 18:00:27 +01:00
Martin Hořeňovský
7b9bf633be
Tighten the test for matching filenames-as-tags 2020-10-23 23:02:09 +02:00
Martin Hořeňovský
4c8454b5ec
Fix potential infinite loops in generators combined with section filter
The problem was that under specific circumstances, namely that none
of their children progressed, `GeneratorTracker` will not progress.
This was changed recently, to allow for code like this, where a
`SECTION` follows a `GENERATE` at the same level:

```cpp
SECTION("A") {}
auto a = GENERATE(1, 2);
SECTION("B") {}
```

However, this interacted badly with `SECTION` filters (`-c foo`),
as they could deactivate all `SECTION`s below a generator, and thus
stop it from progressing forever. This commit makes GeneratorTracker
check whether there are any filters active, and if they are, it checks
whether its section-children can ever run.

Fixes #2025
2020-10-23 21:21:15 +02:00
Martin Hořeňovský
8878f90323
Fix matching of non-lowercase filename tags
The bug was caused by forgetting to lower-case the filename tag
for matching against test spec.

Fixes #2064
2020-10-22 16:20:41 +02:00
Martin Hořeňovský
923bcc5d6f
Special case --list-tests --verbosity quiet
The new output (mostly) follows the old `--list-test-names-only`
format, with the exception of no longer supporting line output
for `--verbosity high`.

Fixes #2051
2020-10-20 15:09:48 +02:00
Martin Hořeňovský
e6d947f6d4
Refactor tests for duration reporting threshold 2020-07-26 10:47:58 +02:00
John Bytheway
80b0d6975c
Add --min-duration option
A test runner already has a --durations option to print durations.
However, this isn't entirely satisfactory.

When there are many tests, this produces output spam which makes it hard
to find the test failure output.  Nevertheless, it is helpful to be
informed of tests which are unusually slow.

Therefore, introduce a new option --min-duration that causes all
durations above a certain threshold to be printed.  This allows slow
tests to be visible without mentioning every test.
2020-07-26 10:47:53 +02:00
Martin Hořeňovský
41bbaa6d57
Implement a simplified variant of std::unique_ptr<T>
This simplified variant supports only a subset of the functionality
in `std::unique_ptr<T>`. `Catch::Detail::unique_ptr<T>` only supports
single element pointer (no array support) with default deleter.

By removing the support for custom deleters, we also avoid requiring
significant machinery to support EBO, speeding up instantiations of
`unique_ptr<T>` significantly. Catch2 also currently does not need
to support `unique_ptr<T[]>`, so that is not supported either.
2020-05-31 15:08:47 +02:00
Martin Hořeňovský
db32550898
Remove catch_default_main.hpp
There are two reasons for this:

1) It is highly unlikely that someone has use for this header,
which has no customization points and only provides simplest
possible main, and cannot link the static library which also
provides a default main implementation.
2) It being a header was causing extra complications with
the convenience headers, and our checking script. This would either
require special handling in the checking script, or would break user's
of the main convenience header.

All in all, it is simpler and better in the long term to remove it,
than to fix its problems.
2020-05-09 18:00:49 +02:00
Martin Hořeňovský
e78b4f6be7
Remove file list checking from CMake
I do not think we need a safeguard against not including files in
CMake anymore, and as it is, it caused annoying false positive about
the default main implementation.
2020-05-06 21:23:13 +02:00
Martin Hořeňovský
fe405034b8
Add script checking convenience header correctness 2020-05-06 17:53:39 +02:00
Martin Hořeňovský
e83c9fb674
Run unit tests in random order 2020-05-03 09:49:59 +02:00
John Bytheway
630ba26278
Add test for consistent random ordering
-- Fixed up during cherrypicking
2020-05-01 14:30:01 +02:00
Martin Hořeňovský
007efc173a
Add generic Contains matcher
It matches a range iff the range contains a specific element,
or an element in the range matches the provided matcher.
2020-03-27 10:22:25 +01:00
Martin Hořeňovský
0e7e6b210a
Remove obsolete surrogate TUs
They will be returned later, but better organized and covering
_all_ headers.
2020-03-17 23:34:55 +01:00
Martin Hořeňovský
6e270958a2
Add development build option to CMake and enable it on CI
Development build enables warnings and and `Werror` or equivalent.
2020-02-26 16:07:26 +01:00