Commit Graph

4440 Commits

Author SHA1 Message Date
Martin Hořeňovský
cefa8fcf32
Enable use of UnorderedRangeEquals with iterator+sentinel pairs 2023-02-06 15:34:38 +01:00
Martin Hořeňovský
772fa3f790
Add Catch::Detail::is_permutation that supports sentinels
Also split out helpers for testing matcher ranges (types whose
begin/end/empty/etc require ADL lookup, types whose iteration
uses iterator + sentinel pair, etc) into their own file.
2023-02-06 15:29:01 +01:00
Martin Hořeňovský
f3c0a3cd09
Fix RangeEquals matcher to handle iterator + sentinel ranges
Also added tests for types that require ADL lookup for their
`begin` and `end`.
2023-02-03 18:22:41 +01:00
Martin Hořeňovský
42d9d4533e
Add test for empty result of filter generator 2023-02-01 18:27:41 +01:00
Martin Hořeňovský
618d44c448
Update docs about thread safe assertions 2023-02-01 15:24:47 +01:00
Martin Hořeňovský
388f7e1737
Cleanup unneeded allocations from reporters
The CompactReporter changes save 21 (430764 -> 430743) allocations
when running the SelfTest binary in default configuration. They
save about 500 allocations when running the binary with `-s`.
2023-01-30 15:30:36 +01:00
Martin Hořeňovský
2ab20a0e00
v3.3.1 2023-01-29 23:18:57 +01:00
Martin Hořeňovský
60264b8807
Avoid copying strings in sonarqube when sorting tests by file 2023-01-29 20:45:13 +01:00
Martin Hořeňovský
65ffee5189
Don't take ownership of SECTION's name for inactive sections
This eliminates 1945 (432709 -> 430764) allocations from running
`./tests/SelfTest -o /dev/null`. In general terms, this saves
an allocation every time an unvisited `SECTION` is passed, which
means that the saved allocations are quadratic in number of sibling
(same level) `SECTION`s in a test case.
2023-01-29 10:44:20 +01:00
Martin Hořeňovský
43f02027e4
Avoid allocations when looking for trackers
Now we delay allocating owning `NameAndLocation` instances until
we construct a new tracker (because a tracker's lifetime can be
significantly different from the underlying tracked-thing's name).

This saves 4239 allocations (436948 -> 432709) when running
`./tests/SelfTest -o /dev/null`, at some cost to code clarity
due to introducing a new ref type, `NameAndLocationRef`.
2023-01-29 10:14:20 +01:00
Martin Hořeňovský
906552f8c8
Clean up extraneous copies in Messages
This removes 109 allocations from running `tests/SelfTest`
(437057 -> 436948).
2023-01-28 22:14:37 +01:00
Martin Hořeňovský
356dfc1439
Move name and sample analysis in benchmarks into BenchmarkStats
This always saves 1 allocation per benchmark, and another two
allocations if the benchmark name is longer than the SSO buffer.
2023-01-28 21:40:59 +01:00
Martin Hořeňovský
e5d1eb757f
Move AssertionResultData into AssertionResult in RunContext
When running `./tests/SelfTest -o /dev/null`, this saves 109
allocations (437167 -> 437058).
2023-01-28 19:57:38 +01:00
Martin Hořeňovský
2403f5620e
Move SectionEndInfo into sectionEnded call in SECTION's destructor
When running `./tests/SelfTest -o /dev/null`, this saves 1272
allocations (437439 -> 437167). In general, this saves multiple
allocations per end of an entered `SECTION`, if the section name
was too long for SSO, because `RunContext::sectionEnded` can then
move the section's name further down the callstack.
2023-01-28 13:00:30 +01:00
Martin Hořeňovský
d58491c85a
Move sectionInfo into sectionEndInfo when SECTION ends
When running `./tests/SelfTest -o /dev/null`, this saves 468
allocations (438907 -> 437439). In general, this saves 1 allocation
every time an entered `SECTION` ends and the section name was long
enough to move out of the SSO buffer.
2023-01-28 12:56:29 +01:00
Martin Hořeňovský
c837cb4a8a
v3.3.0 2023-01-22 19:53:12 +01:00
Martin Hořeňovský
8359a6b244
Stop exceptions in generator constructors from aborting the binary
Fixes #2615
2023-01-22 16:04:16 +01:00
Martin Hořeňovský
adf43494e1
Add missing version information to matchers.md 2023-01-22 00:35:32 +01:00
John Beard
efca9a0f18
Added ElementsAre and UnorderedElementsAre (#2377)
Co-authored-by: Garz4 <fancygarz4@gmail.com>
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2023-01-22 00:33:04 +01:00
Martin Hořeňovský
dd36f83b88
Merge pull request #2630 from ChrisThrasher/export_all_symbols
Export symbols for all compilers on Windows
2023-01-21 15:14:24 +01:00
Chris Thrasher
baab9e8d28
Export symbols for all compilers on Windows 2023-01-20 16:16:30 -07:00
Martin Hořeňovský
2d3c9713a3
Remove VS2015 workaround from Detail::generate 2023-01-19 10:34:57 +01:00
Arash Badie-Modiri
956f915e31 Document template macros are in spearate header
Type parametrised and signature parametrised test macros are now in their own header. The documentation should reflect that.
2023-01-18 23:16:55 +01:00
Tommy Carozzani
aa8da505ec Fix compatibility with previous CUDA versions 2023-01-18 11:57:00 +01:00
Martin Hořeňovský
e27bb7198d Fix macro-redefinition issue with MSVC+CUDA
Closes #2603
2023-01-18 11:57:00 +01:00
Martin Hořeňovský
3486f8ed9e
Update generator docs 2023-01-18 11:55:53 +01:00
Sergey Fedorov
b5be642042
catch_debugger.hpp: restore PPC support (#2619) 2023-01-14 00:03:30 +01:00
Martin Hořeňovský
d59572f46f
Reword the SKIP docs a bit 2023-01-12 20:39:03 +01:00
Martin Hořeňovský
16f48f8c7c
Add SUCCEED and FAIL docs next to SKIP docs 2023-01-12 20:38:58 +01:00
Martin Hořeňovský
367c2cb248
Update doc about what counts as unique test case 2023-01-12 15:26:32 +01:00
Philip Salzmann
d548be26e3
Add new SKIP macro for skipping tests at runtime (#2360)
* Add new SKIP macro for skipping tests at runtime

This adds a new `SKIP` macro for dynamically skipping tests at runtime.
The "skipped" status of a test case is treated as a first-class citizen,
like "succeeded" or "failed", and is reported with a new color on the
console.

* Don't show "skipped assertions" in console/compact reporters

Also extend skip tests to cover a few more use cases.

* Return exit code 4 if all test cases are skipped

* Use LightGrey for the skip colour

This isn't great, but is better than the deep blue that was borderline
invisible on dark backgrounds. The fix is to redo the colouring
a bit, including introducing light-blue that is actually visible.

* Add support for explicit skips in all reporters

* --allow-running-no-tests also allows all tests to be skipped

* Add docs for SKIP macro, deprecate IEventListener::skipTest

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2023-01-12 15:01:47 +01:00
Sam James
52066dbc2a Fix build with GCC 13 (add missing <cstdint> include)
GCC 13 (as usual for new compiler releases) shuffles around some
internal includes and so <cstdint> is no longer transitively included.

Explicitly include <cstdint> for uint64_t.

```
FAILED: src/CMakeFiles/Catch2.dir/catch2/internal/catch_clara.cpp.o
/usr/lib/ccache/bin/g++-13  -I/var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1/src/catch2/.. -I/var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1_build/generated-includes  -O2 -pipe
-march=native -fdiagnostics-color=always -frecord-gcc-switches -Wreturn-type -D_GLIBCXX_ASSERTIONS  -ggdb3 -fdiagnostics-color=always
-ffile-prefix-map=/var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1=. -Wall -Wc++20-compat -Wcast-align -Wcatch-value -Wdeprecated -Wexceptions -Wextra -Wextra-semi -Wfloat-equal -Winit-self
-Wmisleading-indentation -Wmismatched-new-delete -Wmismatched-tags -Wmissing-braces -Wmissing-declarations -Wmissing-noreturn -Wnull-dereference -Wold-style-cast -Woverloaded-virtual -Wparentheses
-Wpedantic -Wreorder -Wshadow -Wstrict-aliasing -Wsuggest-override -Wundef -Wuninitialized -Wunreachable-code -Wunused -Wunused-function -Wunused-parameter -Wvla -MD -MT
src/CMakeFiles/Catch2.dir/catch2/internal/catch_clara.cpp.o -MF src/CMakeFiles/Catch2.dir/catch2/internal/catch_clara.cpp.o.d -o src/CMakeFiles/Catch2.dir/catch2/internal/catch_clara.cpp.o -c
/var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1/src/catch2/internal/catch_clara.cpp
In file included from /var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1/src/catch2/internal/catch_clara.cpp:12:
/var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1/src/catch2/../catch2/internal/catch_string_manip.hpp:47:14: error: 'uint64_t' in namespace 'std' does not name a type; did you mean 'wint_t'?
   47 |         std::uint64_t m_count;
      |              ^~~~~~~~
      |              wint_t
/var/tmp/portage/dev-cpp/catch-3.0.1/work/Catch2-3.0.1/src/catch2/../catch2/internal/catch_string_manip.hpp:51:42: error: expected ')' before 'count'
   51 |         constexpr pluralise(std::uint64_t count, StringRef label):
      |                            ~             ^~~~~~
      |                                          )
```
2023-01-08 20:08:58 +01:00
TrueWodzu
cdf604f30e Update command-line.md
Typo in "--list-reporter" link, should be "--list-reporters"
2023-01-08 19:37:16 +01:00
Martin Hořeňovský
04382af4c6
Slightly better clang-format
Notably clang-format will no longer try to place template header
onto the same line as the function declaration.

Sadly it will still do it for attributes, because it took until
clang-format 16 for it to get the relevant option.
2023-01-05 23:02:51 +01:00
Martin Hořeňovský
ac93f19437
Improved path normalization in approvalTests.py
Instead of redoing the whole line where path was found, only the
directory part of the path is removed, instead of removing all
of the line before the path starts.

This results in slight change in how junit and sonarqube approvals
come out, and significant change in how TeamCity reporter approvals
come out. This latter difference is the reason for the change,
as now the lines with `testFailed` and `testIgnored` messages
are not completely butchered.
2023-01-01 20:27:59 +01:00
Martin Hořeňovský
72b60dfd28
Cleanup the Windows GHA builds
* Use CMD as the shell and simplify configure/build steps
* Include plaform in the build name
2022-12-30 23:58:05 +01:00
Martin Hořeňovský
0c62167fea
Merge pull request #2604 from ChrisThrasher/generated_includes_directory
Keep generated headers within project binary directory
2022-12-28 21:19:53 +01:00
Chris Thrasher
1be954ff70
Keep generated headers within project binary directory
This stops them from appearing in the build directories of projects
that may consume Catch2.
2022-12-26 22:44:35 -06:00
Martin Hořeňovský
78bb4fda05
Mention that the benchmarks are not run by default next to example 2022-12-18 21:42:40 +01:00
Martin Hořeňovský
e6ec1c238b
Fix benchmarking example in the main readme
This uses the same fibonacci implementation as is used in the
benchmark test.

Closes #2568
2022-12-18 21:33:45 +01:00
mrbald
477c1f5152 Fixed typo in code example in top level README.md 2022-12-17 21:34:37 +01:00
Martin Hořeňovský
f8b9f77259
Prune Appveyor builds 2022-12-16 22:37:33 +01:00
Martin Hořeňovský
77fbacb03f
Add VS 2019-2022 C+14/17 jobs to GHA
For now I added only the basic build matrix, without coverage
collection and more special builds, like WMAIN.

However, due to GHA being so much faster than AppVeyor, all
these builds are now done against the 'all-tests' prefix, making
the builds more uniform than they were on AppVeyor.
2022-12-16 22:34:33 +01:00
lbckmnn
e3fc97dffb
fix compiler warning in parseUint and catch only relevant exceptions (#2572) 2022-12-12 12:15:42 +01:00
lbckmnn
9c0533a905
Add MessageMatches matcher for exception (#2570) 2022-12-12 00:40:47 +01:00
Martin Hořeňovský
ed02710b83
Make AutoReg in test registration macros const 2022-12-10 21:37:21 +01:00
Sergio Arroutbi
8b84438be4 Avoid usage of master when possible
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
2022-12-09 23:22:10 +01:00
Martin Hořeňovský
ab6c7375be
v3.2.1 2022-12-09 23:10:18 +01:00
Martin Hořeňovský
24607694cb
Move Catch::always_false into decomposer.hpp 2022-12-09 16:18:33 +01:00
Martin Hořeňovský
28e651f152
Move SFINAE in decomposer into return type
This is needed so that we can use conjunction and other logical
type traits to workaround issue with older GCC versions (8 and
below), when they run into types that have ambiguous constructor
from `0`, see e.g. #2571.

However, using conjunction and friends in the SFINAE constraint
in the template parameter breaks for C++20 and up, due to the new
comparison operator rewriting rules. With C++20, when the compiler
see `a == b`, it also tries `b == a` and collects overload set
for both of these expressions.

In Catch2, this means that e.g. `REQUIRE( 1 == 2 )` would lead
the compiler to check overloads for both `ExprLhs<int> == int`
and `int == ExprLhs<int>`. Since the overload set and SFINAE
constraints assume that `ExprLhs<T>` is always on the left side,
when the compiler tries to resolve the template parameters, all
hell breaks loose and the compilation fails.

By moving the SFINAE constraints to the return type, the compiler
can discard the switched expression without having to resolve
the complex SFINAE constraints, and thus everything works the
way it is supposed to.

Fixes #2571
2022-12-09 00:40:01 +01:00