Commit Graph

586 Commits

Author SHA1 Message Date
Martin Hořeňovský
efb54926ee
Don't cache stdout handle in Windows console colour impl
The cached handle would become invalid if some other code, say
a user-provided test code, redirects stdout through `freopen`
or `_dup2`, which would then cause AppVerifier to complain.

Fixes #2345
2022-01-29 23:12:55 +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ý
b6ff2c3dda
Error out reporter registration for reporter names with '::' 2022-01-09 19:01:14 +01:00
Martin Hořeňovský
875299cff0
Remove unused member from Totals
At one point it was inserted there as the simplest way to smuggle
around an extra return value for specific errors in executing
tests. Since then, the error has been changed to be handled
differently, and the member became unused.
2022-01-07 10:34:25 +01:00
Martin Hořeňovský
fff494c10a
Tear out trivial_abi on unique_ptr
Turns out people are bad at not combining code compiled with GCC
and Clang, and the improvement from `trivial_abi` on `unique_ptr`
is not worth the maintenance cost of having this be an opt-in
change.

Closes #2344
2022-01-05 00:04:25 +01:00
Martin Hořeňovský
103cb16696
Rename listening reporter to multi reporter 2022-01-05 00:00:28 +01:00
Martin Hořeňovský
f4af9f6926
Bump version to v3.0.0 preview 4 2022-01-03 23:16:39 +01:00
Alan Jowett
98a6c69e1e Switch from AddVectoredExceptionHandler to SetUnhandledExceptionFilter
This avoids issues with Catch2's handler firing too early, on
structured exceptions that would be handled later. This issue
meant that the old attempts at structured exception handling
were incompatible with Windows's ASan, because it throws
continuable `C0000005` exception, which it then handles.

With the new handling, Catch2 is only notified if nothing else,
including the debugger, has handled the exception.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>

Closes #2332
Closes #2286
Closes #898
2022-01-03 22:50:32 +01:00
Martin Hořeňovský
eeee4a49af
Remove short flags from --list-tests and --list-tags 2022-01-02 21:23:29 +01:00
Martin Hořeňovský
b5547f2ef6 Passthrough stdout/err in multireporter's partial test end
This should provide the same overall stdout/err, but the new
output should feel "faster" for test cases that are entered
and exited multiple times (e.g. due to generators).
2022-01-01 14:20:23 +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ý
fae0be25b3 Improve error handling in parsing reporter specs 2022-01-01 14:16:11 +01:00
Martin Hořeňovský
8baf9c05a3 Add more unit tests
* Call order of listeners/reporters in multireporter
* Adding listeners/reporters properly updates reporter preferences
2022-01-01 14:10:52 +01:00
Martin Jeřábek
ccd67b293d Add support for multiple parallel reporters
This requires a bunch of different changes across the reporter
subsystem.

* We need to handle multiple reporters and their differing
  preferences in `ListeningReporter`, e.g. what to do when
  we mix reporters that capture and don't capture stdout.
* We need to change how the reporter is given output and
  how we parse reporter's output destination from CLI.
* Approval tests need to handle multireporter option
2022-01-01 14:02:23 +01:00
Martin Hořeňovský
6b55f5d780
Don't send full stdout so far to testCasePartialEnded event 2022-01-01 12:21:41 +01:00
Martin Jeřábek
f0a89b7345
Add ops == and != for Optional 2021-12-29 16:58:16 +01:00
Martin Hořeňovský
45577a1f4c
Refactor implementation of case-insensitivity in tags
By not materializing the lower cased tags ahead of time, we
save allocations at the cost of worsened performance when comparing
two tags.

Since there are rarely many tags, and commonly they are not
compared even if present, this is almost always a win. The new
implementation also improves the robustness of the code
responsible for handling tags in a case-insensitive manner.
2021-12-28 00:20:55 +01:00
Martin Hořeňovský
cbb6764fb1
Add CaseInsensitiveEqualTo comparison type 2021-12-26 18:54:47 +01:00
Martin Hořeňovský
156e6fdfa9
CaseInsensitiveLess takes args as StringRefs 2021-12-26 00:52:52 +01:00
Martin Hořeňovský
187bf6db2b
Split out CaseInsensitiveCmp into its own file 2021-12-26 00:35:46 +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ý
602e484f02
Rename reportInvalidArguments -> reportInvalidTestSpec
This is has been what it actually does for a long time, but it
has not been renamed earlier due to API compatibility.
2021-12-18 20:49:50 +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ý
3bfe900bbc
Move shard logic check after help flag check 2021-12-18 20:49:44 +01:00
Martin Hořeňovský
dcf9479c85
Counts internally use uint64_t instead of size_t
This ensures that even for 32 bit platforms, the assertion count
should not plausibly overflow.
2021-12-06 20:42:51 +01:00
Martin Hořeňovský
c49faa62dd
Let users of amalgamated distribution override the default main
Closes #2324
2021-12-02 13:49:16 +01:00
Martin Hořeňovský
153965a655
Delete useless MatcherMethod base class
All of its functionality can be moved into the `MatcherBase` class,
simplifying the code a bit and removing a warning about class with
virtual member functions but no virtual destructor.

Closes #2182 as it is no longer relevant.
2021-11-26 00:38:13 +01:00
Martin Hořeňovský
b9baae6d93
Cleanup StringRef impl a bit 2021-11-23 23:16:46 +01:00
Martin Hořeňovský
c95072408f
Add catch_sharding.hpp to CML 2021-11-23 23:16:17 +01:00
Martin Hořeňovský
8cb8f0b08b
Sweep out some Wsign-conversion warnings 2021-11-23 23:16:08 +01:00
SketchyLizard
2db1cf3404 Fix template args to avoid conversion warnings
Fix avoids a warning about sign conversion when included from a file compiled with -Werror=sign-conversion.
2021-11-20 21:38:01 +01:00
Morwenn
f41d761674
Add STATIC_CHECK and STATIC_CHECK_FALSE (#2318) 2021-11-15 00:28:27 +01:00
Martin Hořeňovský
edc2f6e8a3
Further refactoring of StreamingReporterBase 2021-11-14 11:41:29 +01:00
Martin Hořeňovský
b2ac27423a
Cleanup visibility in StreamingReporterBase 2021-11-14 11:41:27 +01:00
Martin Hořeňovský
a754cb9062
Make TestRunInfo constexpr 2021-11-14 11:41:26 +01:00
Martin Hořeňovský
5f38cc39fa
JUnit/SonarQube reporters use base's stream member 2021-11-14 11:41:25 +01:00
Martin Hořeňovský
b892ab133c
Cleanup visibility in CumulativeReporterBase 2021-11-14 11:41:24 +01:00
Martin Hořeňovský
0c9fe16537
Opt out JUnit/SonarQube reporter from expanding passing assertions
Closes #1966
2021-11-14 11:27:45 +01:00
Martin Hořeňovský
d02ea5adee
Cumulative reporter base can be customized to not expand assertions 2021-11-14 11:27:44 +01:00
Martin Hořeňovský
4d9bfb2951
Avoid static analysis warning in Approx 2021-11-14 11:27:42 +01:00
Martin Hořeňovský
9200b4078b
Move reporter_registrars.hpp to reporters/ 2021-11-10 23:52:59 +01:00
Martin Hořeňovský
6603f1d972
Use case in names of default reporters 2021-11-10 23:32:01 +01:00
Martin Hořeňovský
62d8913d67
Cumulative reporter base records benchmark results 2021-11-09 11:52:50 +01:00
Martin Hořeňovský
8780425385
Make reporter lookup case insensitive, registration case preserving
Previously registration was case preserving, but lookup used
lowercased reporter name, so a reporter whose name contained
upper case character could not be requested by the user.
2021-11-09 11:50:03 +01:00
Martin Hořeňovský
7800fe9708
Lift toLower(char) to header 2021-11-09 11:44:54 +01:00
Martin Hořeňovský
141e384c60
Fix missing include in reporter_registrars.hpp 2021-11-08 11:32:27 +01:00
Martin Hořeňovský
f1239b2045 Add doxygen doccomments to IStreamingReporter 2021-11-05 14:24:22 +01:00
Martin Hořeňovský
912df7df35
Fix quadratic runtime when linebreaking strings without newlines
The problem was that every line would iterate from current line
start position to the end of the string, looking for a newline
to break on, leading to accidentally quadratic runtime. With this
change, the code only ever searches up to the current line's
length and not more.

Credit to @jorgenpt for the fix suggestion.

Closes #2315
2021-11-04 00:23:56 +01:00
Martin Hořeňovský
70c4ec78fb
Improve comments and names in TextFlow::Column 2021-11-01 19:14:37 +01:00
Martin Hořeňovský
455ae0c561 Typedef Column::iterator as Column::const_iterator not vice versa 2021-10-31 13:01:41 +01:00
Martin Hořeňovský
2520ad4b6e Return const_iterator from Column::begin/end const
This is what should normally happen, even if it does not change
anything given that `Column::const_iterator` is currently a typedef
for `Column::iterator`.
2021-10-31 12:59:00 +01:00
Martin Hořeňovský
e539e1cb52
Move strings in Clara's result type 2021-10-29 23:04:24 +02:00
Martin Hořeňovský
12d14a3c63
Add support for multiply calling lambda parsers in Clara
Previously a lambda parser in Clara could only be invoked once,
even if it internally was ok with being invoked multiple times.

With this change, a lambda parser can mark itself as `accept_many`,
in which case it will be invoked multiple times if the appropriate
flag was supplied multiple times by the user.
2021-10-27 20:15:28 +02:00
Martin Hořeňovský
f17725a186
Split void_type into its own header and rename it to void_t 2021-10-27 20:01:13 +02:00
Martin Hořeňovský
5ac1ffe9ee Improve shardIndex/Count cli argument parsing 2021-10-27 17:24:30 +02: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ý
6456ee8b01
Return Clara parsing error message by const-ref 2021-10-27 15:10:52 +02:00
Martin Hořeňovský
905bf438ae
Fix bad indentation calculation in the console reporter
The problem came from the console reporter trying to provide a
fancy linebreaking (primarily for things like `SCENARIO` or the
BDD macros), so that new lines start with extra indentation if
the text being line broken starts as "{text}: ".

The console reporter did not properly take into account cases
where the ": " part would already be in a later line, in which
case it would ask for non-sensical level of indentation (larger
than single line length).

We fixed this by also enforcing that the special indentation case
only triggers if the ": " is found early enough in the line, so
that we also avoid degenerate cases like this:
```
blablabla: F
           a
           n
           c
           y
           .
           .
           .
```

Fixes #2309
2021-10-25 15:21:28 +02:00
Anders Schau Knatten
22750cde0e Disable false positive from clang-tidy
Clang-tidy is smart enough to understand that the conditional is never
updated in the loop body. It will let you get away with it if it can
prove that the conditional is always false, but that is not always
possible.

Here is an example where it's not able to prove it, and thus gives a
false positive. This is a minimal reproduction of an actual case I hit
in production, where `function` is picking the function based on some
`constexpr` logic related to which type argument is currently being
tested.

```
int f();

TEMPLATE_TEST_CASE("reproduction", "", int) {
    const auto function = []() {
        return f;
    }();
    const int error = function();
    REQUIRE(error == 0); // clang-tidy complains: bugprone-infinite-loop
}
```

I did not choose to add this test to the test suite, since we're not
running `clang-tidy` in CI afaik. To run it manually, simply add the
snippet above somewhere and run clang-tidy with
`--checks=bugprone-infinite-loop`. Or see an example at
https://godbolt.org/z/4v8b8WexP.

The reason we get the infinite loop warning in the first place is the
conditional at the end of this `do`-loop. Ideally, this conditional
would just be `while(false)`, but the actual content of the
`REQUIRE`-statement has been included here too in order to not loose
warnings from signed/unsigned comparisons. In short, if you do
`REQUIRE(i < j)`, where `i` is a negative signed integer and `j` is an
unsigned integer, you're supposed to get a warning from
`-Wsign-compare`. Due to the decomposition in Catch2, you lose this
warning, which is why the content of the `REQUIRE` statement has been
added to the conditional to force the compiler to evaluate the actual
comparison as well.

This was discussed on Discord today, and an alternative approach (which
I don't have time to implement) would be to in the decomposition replace
the comparison operators with `cmp_less` and friends. These are C++20
though, and would have to be implemented manually. I am also not sure
it's a good idea to "magically" change the semantics of `<` when it's
used inside a `REQUIRE` macro.

Another alternative approach would be to trigger this warning in a
different way, by including the content of the `REQUIRE` macro in a
different way which doesn't affect the for loop. But I don't have enough
of an overview here to know where would be a good place and how to test
that I didn't break anything.
2021-10-21 22:45:19 +02:00
Martin Hořeňovský
b406ad52a7
Mark !mayfail tests as skipped in the JUnit reporter
Should fix #2116
2021-10-10 22:21:39 +02:00
Martin Hořeňovský
de67278e14
JUnit reporter uses only 3 decimal places when reporting durations
We used to use whatever precision we ended up having from C++'s
stdlib. However, some relatively popular tools, like Jenkins,
use Maven SureFire XML schema to validate JUnit test reports, and
Maven SureFire schema requires the duration to have at most 3
decimal places.

For compatibility, the JUnit reporter will now respect this
limitation.

Closes #2221
2021-10-10 22:10:48 +02:00
Martin Hořeňovský
1d9696d22d
Cleanup reporting of rng seed in existing reporters 2021-10-09 00:02:30 +02:00
Martin Hořeňovský
ed1f343a41
Provide random-device option for --rng-seed and make it default 2021-10-08 21:35:45 +02:00
Martin Hořeňovský
200a487cf2
Add generateRandomSeed utility to generate randomness seed 2021-10-08 21:35:41 +02:00
Martin Hořeňovský
fce42b62ad
Generate random rng seed if user did not specify one
Closes #2161
2021-10-08 21:35:29 +02:00
Martin Hořeňovský
4e6d306742
Rename Catch::Option to Optional 2021-10-05 20:39:28 +02:00
Martin Hořeňovský
c6c46a168f
Add non-empty assertion to Option's deref op 2021-10-05 19:22:22 +02:00
Martin Hořeňovský
48a889859b
Simplify how ratio symbol is returned when stringifying ratios 2021-10-03 20:23:10 +02:00
Martin Hořeňovský
d65ee04b74
Remove double serialization when stringifying std::optional 2021-10-03 20:19:36 +02:00
Martin Hořeňovský
928e198ef2
Demote some single character strings into plain chars 2021-10-03 10:37:30 +02:00
Martin Hořeňovský
3e9c6fec22
Remove XmlWriter::writeBlankLine
There is no good reason to provide a "add empty line" primitive
for writing XML documents, and the fact that it remains unused
after all the time it was provided only confirms this further.
2021-10-02 14:39:54 +02:00
Martin Hořeňovský
13670f535f
Add more tests for XmlWrite::write* members 2021-10-02 14:39:52 +02:00
Martin Hořeňovský
c6640e4f47
Improve documentation of CATCH_MOVE and CATCH_FORWARD 2021-09-30 20:40:24 +02:00
Martin Hořeňovský
23f0d94b4f
Use CATCH_FORWARD in Detail::make_unique 2021-09-30 20:27:38 +02:00
Martin Hořeňovský
77c7e9803e
Improve documentation on Detail::unique_ptr 2021-09-30 20:17:59 +02:00
Martin Hořeňovský
1d79683ea8
Add [[trivial_abi]] to Detail::unique_ptr when compiled with Clang
This decreases code size and improves performance of passing around
`unique_ptr` instances by value somewhat. It virtually guarantees
problems when combining code compiled with Clang and GCC, but that
was never supported anyway.
2021-09-30 20:11:22 +02:00
Anders Schau Knatten
eb452e9b35 Bring back useful comment
In b7b346c3e5 this conditional was simplified to just
`while( false)` rather than the current one. Then in 3a33315ff8, that
change was reverted. I found it hard to understand this
complicated conditional, but after some digging in history I found this
comment which used to be here. It was removed in b7b346c3e5, but not
restored together with the revert in 3a33315ff8. Let's revive it.
2021-09-29 18:19:31 +02:00
Martin Hořeňovský
2deafc33e9
Demote getCurrentNanosecondsSinceEpoch to internal linkage 2021-09-29 11:26:38 +02:00
Martin Hořeňovský
5250cf6d58
Remove getEstimatedClockResolution from Timer
It used to be part of the experimental benchmarking support, but
since that was replaced with proper benchmarking support with its
own timer facilities, it is now a dead code and useless.
2021-09-29 11:24:18 +02:00
Martin Hořeňovský
426954032f
Rename Contains string matcher builder to ContainsSubstring
The problem with the old name was that it collided with the
range matcher `Contains`, and it was not really possible to
disambiguate them just with argument types.

Closes #2131
2021-09-27 21:28:33 +02:00
Martin Hořeňovský
f02c2678a1
Use StringRef for className in TestCaseInfo 2021-09-27 19:07:45 +02:00
Martin Hořeňovský
21b99d6f58
Add StringRef::compare for three way comparison 2021-09-27 18:41:17 +02:00
Martin Hořeňovský
d42e7a23a0
Change startsWith(char) to take StringRef as argument 2021-09-27 14:55:28 +02:00
Martin Hořeňovský
fb4153e05e
Multiple tests can have same name as long as their tags differ
This change also changes it so that test case macros using a
class name can have same name **and** tags as long as the
used class name differs.

Closes #1915
Closes #1999
2021-09-25 21:37:03 +02:00
Martin Hořeňovský
2c82f82ee2
Mark first party reporters final
They are not intended to be derived from, so forbidding it
explicitly improves our ability to refactor them later.
2021-09-15 21:29:18 +02:00
Martin Hořeňovský
785436cd74
Make benchmark* and fatalError reporter events pure virtual 2021-09-15 21:17:39 +02:00
Martin Hořeňovský
f314fa1f8c
assertionEnded event in reporters no longer returns bool 2021-09-15 18:57:56 +02:00
Martin Hořeňovský
013edc208b
Refactor noMatchingTestCases and skipTests reporter methods
They now take `StringRef` as the argument, and are virtual only
in the basic interface.

Also cleaned out the various reporters and their overrides
of these members which were often empty or delegating up.
2021-09-15 18:08:31 +02:00
Martin Hořeňovský
10fb93cce8
Add new reporter event called for each test case enter/exit
This means that e.g. for `TEST_CASE` with two sibling `SECTION`s
the event will fire twice, because the `TEST_CASE` will be entered
twice.

Closes #2107 (the event mentioned there already exists, but this
is its counterpart that we also want to provide to users)
2021-09-14 13:19:45 +02:00
Martin Hořeňovský
4dcf8382c7
Default-implement assertion* events in StreamingReporterBase
This means that a reporter deriving from `StreamingReporterBase`
does not have to override them if it isn't interested in the individual
assertions.
2021-09-14 12:41:24 +02:00
Martin Hořeňovský
12bca890b7
Use StringRefs in SectionTracker's filter bookkeeping 2021-09-09 11:04:34 +02:00
Martin Hořeňovský
317db82396
Use StringRef in more places in reporters 2021-09-09 10:41:09 +02:00
Martin Hořeňovský
cf5ccaa9df
AssertionResult::getMessage returns StringRef to internal string 2021-09-08 10:08:07 +02:00
Martin Hořeňovský
b3a84c7983
Use StringRef in pluralise implementation
This means that it can no longer be safely made ahead of time,
but nothing in our existing code used it like that. Normally it
is constructed and used in the same expression, which is now
more efficient.
2021-09-08 00:24:40 +02:00
Martin Hořeňovský
c0f866c7cf
Make CumulativeReporterBase's members protected 2021-09-08 00:23:37 +02:00
Martin Hořeňovský
29caae5ce5
Pass around the test suite name by StringRef 2021-09-08 00:01:31 +02:00
Martin Hořeňovský
ea49210eae
Remove Config::getProcessName because it was unused 2021-09-08 00:00:16 +02:00
Martin Hořeňovský
290c1b60e6
Store singular TestRunNode in CumulativeReporterBase
There can never be more than one, so there is no reason to provide
genericity over multiple nodes.
2021-09-07 21:18:48 +02:00
Martin Hořeňovský
e5938007f7
Completely remove the testGroup events
This was done because they were 1:1 mapping to testRun events, and
I could not think of a reasonable way to make them their own thing.
2021-09-07 20:00:22 +02:00
Martin Hořeňovský
ab3fe0053d
Remove superfluous warning suppression from console reporter 2021-09-07 19:57:55 +02:00
Roc
9ac9fb164e
Suffix the library name with 'd' for debug builds 2021-08-28 00:47:54 +02:00
Martin Hořeňovský
07018e2fba
Force __cdecl calling convention for wmain
Fixes #2219
2021-08-26 23:13:27 +02:00
Martin Hořeňovský
ff0a5227ca
Make Approx::operator() const
Closes #2273
2021-08-26 21:27:43 +02:00
Martin Hořeňovský
54edab53bf
Add missing include to benchmark/catch_execution_plan.hpp
Fixes #2275
2021-08-26 20:19:25 +02:00
Martin Hořeňovský
0a8516aeea
Use make_unique when registering an exception translator 2021-08-21 21:32:15 +02:00
Martin Hořeňovský
928ecbaccf
Change callable/model::clone to return a unique_ptr 2021-08-21 21:00:00 +02:00
Martin Hořeňovský
7f3297f7e8
Sweep out unused <utility> includes 2021-08-19 21:44:17 +02:00
Martin Hořeňovský
7ff54ebc06
Add _t suffix typedef for internal traits 2021-08-19 21:29:41 +02:00
Martin Hořeňovský
4113a12c69
Fix Wreserved-identifier for UDLs in Catch2
See #578
2021-08-19 19:15:46 +02:00
Martin Hořeňovský
edad4d0af7
Prefer _t over ::type form for std type traits 2021-08-19 00:21:13 +02:00
Martin Hořeňovský
d2ee7100d2
Replace uses of std::move and std::forward with macros
This improves the SelfTest build times by about 3% (measured
with Clang 10 on random Linux box I had lying around).
2021-08-16 16:22:19 +02:00
Martin Hořeňovský
03ce304102
Add std::move/std::forward replacement macros
Using the `CATCH_MOVE` and `CATCH_FORWARD` macros instead of the
`std::move` and `std::forward<T>` utility functions can improve
compilation times and debug build's performance, and thus will
be preferred going forward.
2021-08-16 16:22:16 +02:00
Martin Hořeňovský
2b54f1e7a6
Remove superfluous catch_enforce include from complete_invoke
Also added missing transitive include to `catch_benchmark.hpp`.
2021-08-11 22:52:04 +02:00
Martin Hořeňovský
2c84854b90
Use unique_ptr to hold Environment measurements in benchmarking 2021-08-11 22:52:01 +02:00
Martin Hořeňovský
3579c055c8
Use Detail::make_unique<T> in more places 2021-08-11 22:51:59 +02:00
Martin Hořeňovský
3ec63324a8
Replace owning naked IStream pointers with unique_ptrs 2021-08-11 22:51:57 +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ý
1b1f3a88bc
Don't debug log empty strings 2021-08-06 11:38:54 +02:00
Martin Hořeňovský
02ab64da2e
Cleanup ExceptionTranslatorRegistry::translateActiveException 2021-08-06 00:56:09 +02:00
Martin Hořeňovský
77df08b44d
Better arg name for run_for_at_least 2021-08-06 00:55:31 +02:00
Martin Hořeňovský
340a61af50
Always use 'Detail' for the detail namespace 2021-07-27 21:45:27 +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ý
849002aec0
Move specialization for global op<< to the proper place
In v2 it was placed in a very central header due to the way it was
stitched together. Now that we don't do that, we can move it to the
proper place, removing the potential for confusion given that the
original header was split apart and renamed.
2021-06-20 19:14:56 +02:00
Martin Hořeňovský
4eb9af51af
Use non-reserved identifiers for test autoregistration objects 2021-06-19 23:15:11 +02:00
Martin Hořeňovský
78e4fbdb12
Use non-reserved identifiers for BENCHMARK macro implementation 2021-06-19 23:14:20 +02:00
Martin Hořeňovský
a7533707ff
Use unique_ptr for passing around exception translators 2021-06-19 20:57:06 +02:00
Martin Hořeňovský
28a33497be
Move extractClassName to the single calling TU and make it static 2021-06-18 23:39:07 +02:00
Martin Hořeňovský
70f5392210
Devirtualize more things in trackers 2021-06-18 10:35:02 +02:00
Martin Hořeňovský
61461dfd1d
Move default impls of isFooTracker to the interface 2021-06-18 10:35:01 +02:00
Martin Hořeňovský
c064322a9d
Devirtualize ITracker::parent 2021-06-18 10:34:58 +02:00
Martin Hořeňovský
a14d67cace
ITracker::parent returns pointer not reference
We were already using it mostly to get pointers rather than
references, so this makes it make more sense.
2021-06-18 10:34:55 +02:00
Martin Hořeňovský
4ce8a23edd
Tiny cleanups in tracking 2021-06-18 10:34:43 +02:00
Martin Hořeňovský
c1b59b7071
Mark JUnit reporter's internal members as private 2021-06-18 00:00:24 +02:00
AlCash07
c77ba5314a Fix decomposing in presence of universal ADL-found operators
Closes #2121
2021-06-08 23:36:06 +02:00
Jayesh Badwaik (FZ Juelich)
c71f42cc29
Disable CATCH_INTERNAL_IGNORE_BUT_WARN for NVHPC Compilers
- NVHPC's implementation of `__builtin_constant_p` has a bug which
    results in calls to the immediately evaluated lambda expressions to be
    reported as unevaluated lambdas.

    https://developer.nvidia.com/nvidia_bug/3321845.

  - Hence, we disable CATCH_INTERNAL_IGNORE_BUT_WARN for NVHPC Compilers
2021-06-07 12:28:16 +02:00
Martin Hořeňovský
aee31d0620
Disallow empty tags in test case specification 2021-06-01 00:17:13 +02:00
Martin Hořeňovský
c9371865d4
Use StringRef as the argument to benchmark{Failed,Preparing} 2021-05-31 08:42:03 +02:00
Martin Hořeňovský
0e2895934c
Use precomputed string sizes when constructing std::strings 2021-05-31 08:41:26 +02:00
Martin Hořeňovský
a01073d871
Write single characters directly instead of as C-strings in Sonarqube 2021-05-31 08:41:20 +02:00
Martin Hořeňovský
02839ba934
Remove superfluous usings in the Contains matcher 2021-05-31 08:40:09 +02:00
Martin Hořeňovský
8d6a1c27ef
Use StringRef literals where possible in XML using reporters
This let's us avoid running `strlen` at runtime to convert the
plain string literals to `StringRef`s, by guaranteeing that we
instead have the size available after compilation.

In optimized builds the performance improvement should be even
greater, as the `StringRef` UDL and the related constructor
are both `constexpr`, and thus can be baked completely during
compilation.
2021-05-30 13:59:47 +02:00
Martin Hořeňovský
41ad0fda11
Improve XmlWriter::writeAttribute overload set for string-like types
Previously, string literals and `std::string`s would match the
template variant, which would serialize them into a stream and then
call the `StringRef` overload for resulting string. This caused
bunch of codebloat and unnecessary pessimization for common usage.
2021-05-30 13:06:03 +02:00
Martin Hořeňovský
d9f72868b2
Use StringRef instead of std::string in XmlWriter::ScopedElement 2021-05-29 21:47:12 +02:00
Martin Hořeňovský
c7241bb76e
Use StringRef in XmLWriter when the text is not stored 2021-05-29 21:23:24 +02:00
Martin Hořeňovský
1d04427fcd
Use StringRef through XmlEncode
This introduces a potential lifetime risk when using the API, but
the intended way to use the `XmlEncode` class is to use it directly,
e.g. `out << XmlEncode(some-text-argument)`, not to store it around.

The benefit is that we avoid allocations for strings that do not fit
into SSO for given platform.
2021-05-29 16:41:57 +02:00
Martin Hořeňovský
0221148ac3
Cleanup string escaping in XmlWriter with raw string literals 2021-05-29 14:11:50 +02:00
Martin Hořeňovský
9f091cbe9d
Remove some code duplication from default test listing impl 2021-05-29 14:06:40 +02:00
Martin Hořeňovský
4c1e896d47
Flush less in default test listing impl 2021-05-29 13:52:23 +02:00