Commit Graph

4368 Commits

Author SHA1 Message Date
Martin Hořeňovský
4b344f11ea
Document GENERATE's new usage between SECTIONs 2020-07-26 14:06:34 +02:00
Gavin S
87d0197cbd
Update catch_reporter_tap.hpp
TAP format requires all results to be reported.
Removed extraneous preferences function (handled by parent)
Incorporated fix from 3d9e7db2e0
Simplified total printing
2020-07-26 14:00:10 +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
Martin Hořeňovský
250d9b9c72
Fix how testRandomOrder.py builds tag arguments 2020-07-26 10:51:55 +02:00
Martin Hořeňovský
90d6fd849e
Increase tolerances in --min-duration tests
The underpowered and oversubscribed CI servers are hell.
2020-07-26 10:48:03 +02:00
Martin Hořeňovský
13917c44b4
--min-duration is overriden by -d no 2020-07-26 10:48:01 +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
Eric Huber
36131f7ffa
Escaping literal "*" ("times") to fix markdown 2020-07-24 22:36:58 +02:00
Martin Hořeňovský
f52018205d
Cherry pick release notes for v2.12.4 2020-07-24 22:36:13 +02:00
Martin Hořeňovský
b32d2fa016
Update FUNDING file (-Patreon, +PayPal) 2020-07-24 22:35:17 +02:00
George Rhoten
a25c1a24af
Fix for macOS on ARM 2020-07-24 22:34:22 +02:00
Martin Hořeňovský
e28018c659
Cherry pick release notes for v2.12.3 2020-07-24 22:33:59 +02:00
Martin Hořeňovský
2a25a267ea
Cherry pick release notes for v2.12.2 2020-07-24 22:33:26 +02:00
Ryan Pavlik
7f58840163
Add OverallResultsCases element to XML reporter 2020-07-24 22:30:28 +02:00
Martin Hořeňovský
3b0f8c7ff0
Replace a TODO comment in examples 2020-07-22 21:49:58 +02:00
Richard Ash
2840ce1e70
Add an example of using GENERATE(table())
There are some examples on issue #850 of using this feature, but they
are not easily found from the documentation. Adding them here as an
example makes them more findable and ensures they keep working if the
API changes.
2020-07-22 21:49:54 +02:00
Richard Ash
ed9be5a00b
Add notes on compiling the examples.
This took me some time to figure out so document for others.
2020-07-22 21:43:53 +02:00
offa
273111d1a6
Clang-format configuration added.
Some notes on the configuration options chosen:

* We want `AllowShortEnumsOnASingleLine` set to `false`, but that
option is clang-format-11 and up, which is not out yet.
* `IndentPPDirectives` is currently inconsistent, but `AfterHash`
is the preferred style in new code.
* `NamespaceIndentation` is a mess, but `All` is closer to the effect
we want than `Inner`.
* `SpacesInParentheses` set to `true` is not ideal due to it also
introducing extra spaces in preprocessor expressions, but using it
is much closer to the current style than not.

All in all, using this setting globally would reformat pretty much
every line of code in the codebase, but it is as close as possible
to the bespoke style currently used. Still, it should only be used
on the diffs.

Closes #1182
2020-07-22 21:43:30 +02:00
Richard Ash
a862924601
Make scripts/updateDocumentToC.py executable.
On systems where the file system has excute permissions, this script was
not marked as executable in a clean git checkout and so could be run
without first changing the permissions. Fixed by setting the relevant
git flag.
2020-07-22 21:43:16 +02:00
Martin Hořeňovský
0e77adee05
Add explicit test for shortcircuiting behaviour of combined matchers 2020-07-22 21:36:14 +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
Martin Hořeňovský
314bb7e632
Clarify documentation about nested generators
Closes #1947
2020-07-22 21:18:49 +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ý
5c502320e8
Remove obsolete comment in UnorderedEquals vector matcher 2020-07-12 21:28:50 +02:00
Martin Hořeňovský
f3fe2dcb11
Add status attribute to JUnit's section reporting
This brings our output inline with GTest's. We do not handle skipped
tests properly, but that should be currently less important than
having the attribute exist with proper value for non-skipped tests.

Thanks @joda-01.

Closes #1899
2020-07-12 21:22:15 +02:00
Natsu
8b5f6e26d3
Fix compilation failure when using libstdc++10 (#1929)
The issue is caused by deleted `std::__detail::begin` declared in `bits/iterator_concepts.h`. This would be found by ADL, and because it is deleted, compilation would fail. This change makes it so that we SFINAE on `begin(std::declval<T>())` and `end(std::declval<T>())` being well-formed.
2020-07-12 21:01:49 +02:00
Billy Robert O'Neal III
c24f7e5b34
Fix invalid isspace call detected by PREfast
D:\vcpkg\toolsrc\include\catch2\catch.hpp(11285): warning C6330: 'char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'.
D:\vcpkg\toolsrc\include\catch2\catch.hpp(11288): warning C6330: 'char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'.

ISO/IEC 9899:2011:
"7.4 Character handling <ctype.h>"/1
[...] In all cases the argument is an int, the value of which shall be
representable as an unsigned char or shall equal the value of the macro
EOF. If the argument has any other value, the behavior is undefined.

This means if isspace was passed a character like ñ it could corrupt
memory without the static_cast to treat it as a positive value after
integral promotion (and C libraries commonly use the int index supplied
as a key into a table which result in out of bounds access if the
resulting int is negative).
2020-07-12 21:00:25 +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ý
392e44ec21
Minor refactoring of CompactReporter 2020-05-31 22:34:37 +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
Valentin Tolmer
d05a8e2e24 Add Bazel support for the v3 branch 2020-05-26 14:49:49 +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ý
4394d3ae65
Translate exceptions by const reference instead of plain ref 2020-05-20 08:15:27 +02:00