Commit Graph

403 Commits

Author SHA1 Message Date
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
Martin Hořeňovský 2c04850f88
Add some constexpr in compact reporter impl 2021-05-29 13:49:33 +02:00
Martin Hořeňovský c9027375a3
Replace std::endl with \n and flush
In some places the `std::flush` was not added, as it was sufficiently
obvious that the flush semantics are not intended. There are likely
other places where the flush semantics aren't intended, but that
is a cleanup for later.
2021-05-29 13:15:46 +02:00
Martin Hořeňovský 2ae28fc852
Use make_unique instead of unique_ptr(new T) in more places 2021-05-28 23:43:15 +02:00
Dimitrij Mijoski 86f86c4c23 Fix compiling with C++17 + Clang 5 + libstdc++ v5
This basically tests the combination where the compiler supports most
of C++17 but the library does not.
2021-05-26 00:34:23 +02:00
Martin Hořeňovský 023b5306b4
Add deep const to unique_ptr::operator-> 2021-05-19 11:00:53 +02:00
Martin Hořeňovský 9137e591fa
Cleanup and optimize stringifying of string-like types
More specifically, made the actual implementation of string-like
type handling take argument as `Catch::StringRef`, instead of
taking `std::string const&`.

This means that string-like types that are not `std::string` no
longer need to pay for an extra construction of `std::string`
(including the potential allocation), before they can be stringified.

The actual string stringification routine is now also better about
reserving sufficient space.
2021-05-18 23:15:22 +02:00
Martin Hořeňovský f50a06affa
Small optimization for stringifying chrono::time_point 2021-05-18 00:17:34 +02:00
Martin Hořeňovský 4cc247cc70
Use constexpr StringRef instance for unprintable strings 2021-05-18 00:17:32 +02:00
Martin Hořeňovský 8ee422d6bf
Remove pointless branch from stringifying matcher assertions 2021-05-15 11:47:02 +02:00
Martin Hořeňovský 0c0f73a48d
Constexprify NameAndTags constructor 2021-05-15 00:02:09 +02:00
Martin Hořeňovský 61e16416a9
Pass other StringRef arguments by value instead of by-ref
Apart from being clearer, it also improves the overall codesize
of the implementation library, and should improve the performance
as well, by removing one level of indirection.
2021-05-14 23:45:59 +02:00
Martin Hořeňovský 074017f5ad
Inline MessageBuilder's constructor 2021-05-14 16:00:15 +02:00
Martin Hořeňovský 0a89e7f0c4
Pass StringRef by value instead of by const-ref 2021-05-14 15:59:42 +02:00
Martin Hořeňovský 28f6698ec8
Remove unneeded interface IRunner 2021-05-13 09:14:26 +02:00
Martin Hořeňovský b36f8daaad
Clarify bunch of default, out of line destructors 2021-05-12 23:55:46 +02:00
Martin Hořeňovský d86cb5f95d
Add override to virtual destructor of derived class 2021-05-12 23:23:02 +02:00
Jozef Grajciar eb911aa995
Suppress failure of CHECKED_IF and CHECKED_ELSE (#2187)
Resolves #1390

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2021-05-10 21:42:47 +02:00
Matteo Beniamino baf0cd0be4
Fixed [dis]engage_platform declarations mismatch 2021-05-09 23:34:17 +02:00
Martin Hořeňovský c0d0a50bdb
Significantly refactor fatal error handling
Because new glibc has changed `MINSIGSTKSZ` to be a syscall instead
of being constant, the signal posix handling needed changes, as it
used the value in constexpr context, for deciding size of an array.
It would be simple to fix it by having the handler determine the
signal handling stack size and allocate the memory every time the
handler is being installed, but that would add another allocation
and a syscall every time a test case is entered.

Instead, I split apart the idea of preparing fatal error handlers,
and engaging them, so that the memory can be allocated only once
and still be guarded by RAII.

Also turns out that Catch2's use of `MINSIGSTKSZ` was wrong, and
we should've been using `SIGSTKSZ` the whole time, which we use now.

Closes #2178
2021-05-09 23:34:15 +02:00
Pavel Kamenov cbcab2dbcd
Add lcc to the list of unwanted compilers that mimic gcc 2021-05-09 18:12:58 +02:00
Scott Hutchinson ea44e73961
Wrap all std::min and std::max calls in parentheses 2021-05-09 18:10:50 +02:00
Rob Boehne d61fe3ecc3
[Issue 2154] Correct error when building with IBM's latest XLC (#2155)
* [Issue 2154] Correct error when building with IBM's latest XLC compiler with xlclang++ front-end.

On AIX, the XLC 16.1.0.1 compiler considers the call to `std::abs` ambigious, so it needs help with a static_cast to the type of the template argument.

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2021-05-09 18:05:39 +02:00
Tom de Geus b325c6d81e
Making target detection on Mac more robust 2021-05-09 18:05:37 +02:00
Martin Hořeňovský d4a3cd9992
Make the static library build reproducible with supported compilers
This is based on bed285af07 from
`v2.x` branch, but done properly for the build in v3 branch,
effectively porting #2141 to devel.
2021-05-09 18:05:34 +02:00
Sergio Losilla cdf4748d1c
Modified hash to make it more independent of the choice of test names. 2021-05-09 18:05:14 +02:00
Julien Brianceau e8cdfdca87
Fix typos in the code base (#2206)
Note that only documentation and comments are impacted by this change.
2021-04-07 20:43:50 +02:00
Martin Hořeňovský a5abec9cb5
Remove superfluous virtual from ExceptionTranslatorRegistry 2021-03-26 21:11:49 +01:00
Martin Hořeňovský f1d7a10e06
Remove StringRef::isNullTerminated and StringRef::c_str
Both of them were fundamentally unsafe to use and shouldn't be used
at all.
2021-03-26 21:11:44 +01:00
Martin Hořeňovský e50e10ef8f
Use std::string instead of StringRef as argument to the makeStream
This is done because `makeStream` was the only place using
`StringRef::c_str()`, which is an error-prone and unsafe API that
I want to remove.
2021-03-26 21:11:42 +01:00
Alexander Shaduri 2c269eb633 Fixed compilation under MinGW - use gmtime_s() instead of gmtime_r(). 2021-03-23 23:46:04 +01:00
Martin Hořeňovský 551946c45b
Split out INTERNAL_CATCH_UNIQUE_NAME into its own header
Also small cleanup of includes of related headers.
2021-02-24 23:14:18 +01:00
Martin Hořeňovský 653764d53b
Simplify workaround for MSVC issue with XmlWriter 2021-02-21 11:19:02 +01:00
Martin Hořeňovský e5e9afad16
Fix headers whose surrogate TUs did not compile 2021-02-19 23:22:43 +01:00
Martin Hořeňovský 477540760a
Use gmtime_r instead of gmtime when compiling for posixy platforms 2021-01-27 11:49:52 +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ý 6798c139a6
Extract the default listing implementation out of reporter interface
Also generalized the implementations to write to the provided
output stream, which will be required for the follow up changes,
where the listings should happen to the location user asked for
by specifying the `-o` flag.
2021-01-26 11:23:37 +01:00
Martin Hořeňovský 7111b2a8e2
Cleanup IStreamingReporter::listTests 2021-01-16 15:50:52 +01:00
Martin Hořeňovský 5509ceff60
Remove superfluous IConfig argument from IStreamingReporter::list*
The previous commit made it so that the `IConfig` is stored in
`IStreamingReporter` and thus always available.
2021-01-16 15:48:29 +01:00
Martin Hořeňovský 74f2f4ba5e
Hold reporter's IConfig instance in the interface
Previously, every base derived from the IStreamingReporter had
its own `IConfig const* m_config` member, so this just centralizes
the handling thereof.

Part of #2061
2021-01-16 15:27:56 +01:00
Martin Hořeňovský 4e8832fc88
Split CATCH_CONFIG_COUNTER into its own header
Part of #2041
2020-12-29 11:07:45 +01:00
Martin Hořeňovský bdd1e5c613
Remove some superfluous includes 2020-12-28 21:11:54 +01:00
Martin Hořeňovský 1d269211bd
Split CATCH_CONFIG_WCHAR into its own header
Part of #2041
2020-12-28 20:51:49 +01:00
Roman Proskuryakov 0acb371b92
Fix Wold-style-cast error (#2125)
* Add Wold-style-cast to cmake flags
* Fix old style cast in catch_stats.hpp
* Fix old style cast in catch_stats.cpp
2020-12-28 14:00:19 +01:00
Martin Hořeňovský 965afc4b2e Split CATCH_CONFIG_ANDROID_LOGWRITE into its own header
Part of #2041
2020-12-28 12:53:52 +01:00
Uriel García Rivas 552af8920d Added AnyMatch, AllMatch and NoneMatch 2020-12-27 20:20:55 +01:00
Martin Hořeňovský a091853f4a
Rename file catch_matchers_floating -> catch_matchers_floating_point
The old name was a legacy of v2 era, where all headers were stitched
into one. With v3 using separate headers, it is better when they have
proper name.
2020-12-13 18:12:20 +01:00
Martin Hořeňovský 4b51d0dd3b
Remove rest of std::shared_ptr usage in Trackers
Closes #2088
2020-12-05 15:19:23 +01:00
Martin Hořeňovský 6350851f9a
Return plain ptr from ITracker::findChild instead of shared_ptr
This is part of wider rework of trackers to avoid `std::shared_ptr`
everywhere.

Related to #2088
2020-12-04 21:37:24 +01:00
cat_mint 21c97f2fad
Use snprintf instead of sprintf (#2111) 2020-12-01 18:59:27 +01:00
Martin Hořeňovský e7740316e3
Split TestFailureException into its own header 2020-11-28 11:18:54 +01:00
Martin Hořeňovský 72525a3053
Rename catch_common.hpp -> catch_source_line_info.hpp
Previous splitting of catch_common.hpp left it containing only one
actual thing, which is the `SourceLineInfo` type. Given that, there
is no reason to keep the old name.

Also found out that it was included in some places for no reason
(primarily Matchers).
2020-11-28 11:18:51 +01:00
Martin Hořeňovský 1982c0d5ee
Split out the StreamEndStop helper into its own header 2020-11-28 11:18:46 +01:00
Martin Hořeňovský c3e8ae642f
Remove pointless virtual in WildcardPattern 2020-11-26 18:35:20 +01:00
Martin Hořeňovský f36e059453
Remove superfluous <memory> include from catch_reporter_cumulative_base.hpp 2020-11-26 18:06:21 +01:00
Martin Hořeňovský 677adf8ade
Replace shared_ptrs with unique_ptrs in CumulativeReporterBase nodes
Closes #2089
2020-11-26 14:45:27 +01:00
Martin Hořeňovský bfe5553416
CumulativeReporterBase doesn't use shared_ptrs for sectionStack 2020-11-26 10:21:12 +01:00
Martin Hořeňovský c673db7a4e
Add explanatory comment to CumulativeReporterBase 2020-11-26 09:45:28 +01:00
Martin Hořeňovský b10a19545b
CumulativeReporterBase stores TestRunNodes directly 2020-11-26 09:43:23 +01:00
Martin Hořeňovský e5ccb79bf8
Remove pointless virtual on StreamingReporterBase::Node destructor 2020-11-25 21:57:30 +01:00
Martin Hořeňovský 3610eb81b1
Explicitly inline trivial function in CumulativeReporterBase impl 2020-11-17 21:02:11 +01:00
Martin Hořeňovský bd1e76cc3a
Untypedef some types for clarity when refactoring 2020-11-17 21:01:35 +01:00
Martin Hořeňovský 166c520598
Remove another unused member variable from CumulativeReporterBase 2020-11-14 16:17:48 +01:00
Martin Hořeňovský a29deeb129
Remove unused member in StreamingReporterBase
Part of #2089
2020-11-14 16:17:39 +01:00
Martin Hořeňovský 1cef51b69b
Default StreamingReporterBase::Node destructor 2020-11-14 16:17:35 +01:00
Martin Hořeňovský 79c1bf9301
Use plain pointer to point to deepest section in CumulativeReporterBase
Part of #2089
2020-11-14 16:17:27 +01:00
Martin Hořeňovský 4f14922aa3
Don't use shared_ptr to store test run info in CumulativeReporterBase
Part of #2089
2020-11-14 16:16:28 +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ý f97436a1f7
Normalize include guard in catch_config_ucnaught_exceptions.hpp 2020-11-06 18:01:27 +01:00
Morwenn dd5652933a Silence -Wuseless-cast warning with GCC10
With GCC 10, the `static_cast<bool>` triggers the -Wuseless-cast warning. This commit changes the cast into `static_cast<const bool&>`: it achieves the same thing but doesn't trigger the warning thanks to the "gratuitous" type conversion to `const bool&`. As per references rules, `const bool&` should bind to anything, be it `const` or not, an rvalue or an lvalue, so I doubt that this change is breaking anything.
2020-11-02 16:01:17 +01: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ý b6a3e2e26b
Merge pull request #2058 from catchorg/devel-generators-cache
Fix types in generators: decay types, properly constrain forwarding
2020-10-20 12:46:31 +02:00
Martin Hořeňovský 6ffac61719
Fix types in generators: decay types, properly constrain forwarding
Fixes #2040
Closes #2012
2020-10-20 10:57:37 +02:00
Michael Vlach 4b2bc8757c Update catch_compiler_capabilities.hpp 2020-10-10 17:56:43 +02:00
Martin Hořeňovský b9853b4b35
Bump version to v3.0.0 preview 3 2020-10-08 15:26:30 +02:00
Martin Hořeňovský 3f9e779542
Improve detection of std::uncaught_exceptions support
The problem was that Catch2 did not reliably include `<exception>`
before it checked for the feature test macro for
`std::uncaught_exceptions`. To avoid overhead of including
`<exception>` everywhere, the configuration check was split out
into a separate header.

Closes #2021
2020-10-08 12:39:50 +02:00
Martin Hořeňovský b601b7faca
Workaround AppleClang bug by renaming TestHasher constructor argument
As far as I understand the standard, if there is a function called
`rng` in the global namespace, and a function argument called `rng`,
then the argument should shadow the function. This then means that
uses of `rng` inside the function should refer to the argument.

This is not the case for AppleClang 12.0.0. Luckily the workaround
is simple enough; just rename the argument. Given that the function
is 3 lines and uncomplicated, the change of the name doesn't really
affect readability.

Still, WTF AppleClang?

Closes #2030
2020-10-08 11:41:05 +02:00
Will Pazner a4dfcf9042
Disable __builtin_constant_p when compiling with nvcc 2020-10-08 11:34:57 +02:00
Travis Wilson b0214ff862
Make experimental capture work on Windows with read-write temp file behavior 2020-10-08 11:28:50 +02:00
Martin Hořeňovský 99d70c0c9d
Remove superfluous whitespace before #include 2020-09-07 20:01:04 +02:00
Dawid Kurek 8f44e09a72
Remove superfluous values
The `0`s were needed for the expansion of parameter pack for the sake of
expander. Now when we have `index++` it is no more needed.
2020-09-07 14:30:58 +02:00
Sean Middleditch 31d4831245
Support sentinel-based ranges in default stringify (#2004) 2020-09-07 14:23:47 +02:00