Commit Graph
76 Commits
Author SHA1 Message Date
Martin Hořeňovský a4ac07d104 Split out default CATCH_CONFIG_CONSOLE_WIDTH into its own header
This means that code that uses it no longer has to include all of
catch_config.hpp, which seems to provide significant reduction in
size of unoptimized compilation of the final static library.
2020-08-03 22:57:43 +02:00
Martin Hořeňovský c5037743e6 Avoid copying SectionInfo while construction Section 2020-07-29 21:51:10 +02:00
Martin Hořeňovský 9d6ac62aff Remove unused member from Section 2020-07-29 21:51:08 +02:00
Martin Hořeňovský ed0ea30149 Apply some IWYU suggestions
This is not nearly all of them, because IWYU does not support the
way Catch2 manages includes -- it expects that non-system includes
are done using `#include "foo/bar/baz.hpp"`, while Catch2 uses
`<foo/bar/baz.hpp>`. This causes trouble, because IWYU suggests
removing every single internal header, and then adding them again,
but using `""` in the include directive... the resulting suggestions
cannot be used without a lot of manual work, as they are largely
bogus.

For bonus points, IWYU also _loves_ to suggest kinda-random stdlib
headers for `size_t` and similar. Still, the resulting inclusion
graph is somewhat better than it was before.
2020-07-29 21:51:05 +02:00
Martin Hořeňovský 35098a62d8 Sanitize includes in random_number_generator.cpp
I have no idea how those got there, but now its dependency graph
is much saner.
2020-07-29 14:58:14 +02:00
Martin Hořeňovský ba57c17310 Remove some extraneous includes from run_context.hpp 2020-07-29 14:54:55 +02:00
Martin Hořeňovský 4e0af77e29 Push includes for TestCaseInfo down into reporter TUs 2020-07-29 14:43:05 +02:00
Martin Hořeňovský d218d6f9e2 Avoid recalculating string-literal size on root tracker construction
This is a tiiiiiiny performance optimization, but it's free.
2020-07-27 20:08:44 +02:00
Martin Hořeňovský ef92178058 Devirtualize nested tracker handling 2020-07-27 19:53:54 +02:00
Martin Hořeňovský 125d4b4164 Devirtualize test case registration 2020-07-27 08:49:49 +02:00
Martin Hořeňovský 5f6990d746 Only start Section's timer if the duration will be used
This is a small potential runtime optimization on systems with
virtual syscalls, and a significant runtime optimization on systems
without.
2020-07-26 21:33:49 +02:00
Martin Hořeňovský 4565b826cf Modify generator tracking to allow GENERATEs between SECTIONs
This means that code such as

```cpp
TEST_CASE() {
    SECTION("first") { SUCCEED(); }
    auto _ = GENERATE(1, 2);
    SECTION("second") { SUCCEED(); }
}
```

will run and report 3 assertions, 1 from section "first" and 2
from section "second". This also applies for greater and potentially
more confusing nesting, but fundamentally it is up to the user to
avoid overly complex and confusing nestings, just as with `SECTION`s.

The old behaviour of `GENERATE` as first thing in a `TEST_CASE`,
`GENERATE` not followed by a `SECTION`, etc etc should be unchanged.

Closes #1938
2020-07-26 11:35:06 +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
George Rhoten a25c1a24af Fix for macOS on ARM 2020-07-24 22:34:22 +02:00
Martin Hořeňovský b74996a29c Devirtualize NameAndLocation query on trackers 2020-07-22 21:23:12 +02:00
Martin Hořeňovský de53773e46 Fix copy paste error in 7-arg TEMPLATE_TEST_CASE_SIG implementation
Closes #1954
2020-07-22 21:18:52 +02:00
Matthias Blankertz 9221a6ff65 Hide std::exception_ptr and friends if exceptions disabled
Some compilers, e.g. the Green Hills C++ compiler, react badly to the
appearance of std::exception_ptr, std::current_exception,
std::rethrow_exception and std::uncaught_exception(s). To allow usage of
Catch2 with these compilers when exceptions are disabled, hide the usage
of std::exception_ptr etc. when compiling with
CATCH_CONFIG_DISABLE_EXCEPTIONS.
2020-07-22 21:18:47 +02:00
Martin Hořeňovský 657ebf5db2 Replace stray tabs with spaces 2020-07-22 20:46:58 +02:00
Martin Hořeňovský 480f3f418b Improved generator tracking
* Successive executions of the same `GENERATE` macro (e.g. because
of a for loop) no longer lead to multiple nested generators.
* The same line can now contain multiple `GENERATE` macros without
issues.

Fixes #1913
2020-07-22 20:44:22 +02:00
bogdasar1985 3ceaad7d66 fixing UB 2020-07-22 17:17:33 +02:00
Martin Hořeňovský 7dae3efad2 Silence clang-tidy's hicpp-vararg (alias of coreguidelines vararg)
Ideally, clang-tidy would be smart that if one alias of a warning
is suppressed, then the other one is suppressed as well, but as of
right now, it isn't. This means that for now we have to suppress
both aliases of this warning. Opened upstream issue to fix this:
https://bugs.llvm.org/show_bug.cgi?id=45859

Obviously, ideally clang-tidy would also not warn that we are calling
a vararg function when it is an unevaluated magic builtin, but that
also is not happening right now and I opened an issue for it:
https://bugs.llvm.org/show_bug.cgi?id=45860

Closes #1921
2020-07-12 20:59:29 +02:00
Corentin Jabot a71721801e Remove extra semi-colons 2020-07-10 13:40:42 +02:00
Corentin Jabot 2cd5e70012 Silence a -Wsign-conversio warning in Clara under GCC 2020-07-09 12:24:25 +02:00
Martin Hořeňovský 317145514f Add op+(StringRef, StringRef) -> std::string 2020-05-31 22:30:41 +02:00
Martin Hořeňovský f2b9508081 Remove last vestiges of shared ptr use with IConfig 2020-05-31 15:25:14 +02:00
Martin Hořeňovský 1d1ccf8f3c Replace all uses of std::unique_ptr with Catch::Detail::unique_ptr
Doing some benchmarking with ClangBuildAnalyzer suggests that
compiling Catch2's `SelfTest` spends 10% of the time instantiating
`std::unique_ptr` for some interface types required for registering
and running tests.

The lesser compilation overhead of `Catch::Detail::unique_ptr` should
significantly reduce that time.

The compiled implementation was also changed to use the custom impl,
to avoid having to convert between using `std::unique_ptr` and
`Catch::Detail::unique_ptr`. This will likely also improve the compile
times of the implementation, but that is less important than improving
compilation times of the user's TUs with tests.
2020-05-31 15:20:24 +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ý 66ab942903 Refactor StreamEndStop slightly 2020-05-30 15:44:46 +02:00
Martin Hořeňovský 1356788ea8 Avoid using std::result_of when std::invoke_result is available 2020-05-21 22:58:33 +02:00
Martin Hořeňovský 21d284df34 Session now holds Config in unique_ptr instead of shared_ptr 2020-05-20 20:25:51 +02:00
Martin Hořeňovský 668454b36b Do not share ownership of Config in RunContext 2020-05-20 20:25:49 +02:00
Martin Hořeňovský 458241cc90 Do not use shared_ptr<Config> when listing things 2020-05-20 20:25:48 +02:00
Martin Hořeňovský fa160cf3f2 Keep reporter pointer around in TestGroup 2020-05-20 20:25:45 +02:00
Martin Hořeňovský a17b9f754a Remove unused function 2020-05-20 20:25:43 +02:00
Martin Hořeňovský c2852c9944 Remove some uses of std::shared_ptr 2020-05-20 20:25:40 +02:00
Martin Hořeňovský 39e093021c Remove some superfluous includes 2020-05-18 20:55:21 +02:00
Martin Hořeňovský 29d4b3768c Add Wsuggest-override to warning flags 2020-05-13 16:09:34 +02:00
Martin Hořeňovský 03ef6b9f9a Explicitly default smfs when relevant to avoid Wdeprecated-copy-dtor 2020-05-12 23:56:34 +02:00
Martin Hořeňovský 579dcd1a76 Ignore Wdeprecated for Clara 2020-05-12 23:56:24 +02:00
Martin Hořeňovský 601ca1c670 Refactor some uses of virtual -> override 2020-05-11 16:34:55 +02:00
Martin Hořeňovský f64487bf70 Move LazyExpr's and MessageInfo's implementation to the combined TU
Some of the implementations were inlined instead.
2020-05-10 20:21:04 +02:00
Martin Hořeňovský 27f1756d8e Split out LazyExpr into its own header
This enables us to avoid `catch_reporter_bases.hpp` being indirectly
dependent on `catch_tostring.hpp`, cutting apart quite a bit indirect
inclusions.
2020-05-10 20:21:02 +02:00
Martin Hořeňovský 824ffe6525 Inline and default LazyExpression's constructor 2020-05-10 20:20:59 +02:00
Martin Hořeňovský d5e08a4beb Rename catch_assertionhandler -> catch_assertion_handler 2020-05-10 20:20:56 +02:00
Martin Hořeňovský ed967fd7fc Split MessageInfo into its own header
This is first step towards splitting apart reporter implementation
and `catch_string.hpp`.
2020-05-10 20:20:52 +02:00
Martin Hořeňovský 7efbc83ae0 Introduce combined TUs for compiling small TUs
This should improve the compilation times by decreasing the number
of TUs compiled, without making overly big TUs that would cause
problems with heavy-tailed compilation times.

There is one "combined TU" for the top level part, and each subpart,
except for Reporters, which currently do not have any trivial TUs.
2020-05-10 15:37:29 +02:00
Martin Hořeňovský 9e498278be Move StringRef header to internals 2020-05-10 10:09:01 +02:00
Martin Hořeňovský 14533f5bb6 Make Colour's op<< hidden friend 2020-05-10 07:32:40 +02:00
Martin Hořeňovský 094d840efe Cleanup SourceLineInfo implementation
Special member functions are now implicit, which should make them
both noexcept and constexpr. The `operator<<` has been made into
hidden friend as per best practices.
2020-05-10 06:57:02 +02:00
Martin Hořeňovský b93cf932fb Use UDLs to construct StringRefs for decomposed operators directly 2020-05-09 21:07:55 +02:00