4715 Commits

Author SHA1 Message Date
Martin Hořeňovský 29c9844f68 v3.13.0 v3.13.0 2026-02-15 22:55:48 +01:00
Martin Hořeňovský 56024c04e4 More tests for MapGenerator 2026-02-15 21:53:10 +01:00
Martin Hořeňovský edfed6c04e Efficient skipToNthElementImpl for Take and Map generators 2026-02-15 21:43:54 +01:00
Martin Hořeňovský 75bfcc3f30 Expose skipToNthElement in the GeneratorWrapper 2026-02-15 21:38:14 +01:00
Martin Hořeňovský 056e4fe88d MapGenerator only calls mapping function if the result is used
Previously the mapping was eager on construction and calls to
`next()`. This was fine when generators were always exhausted fully,
but with the new generator filtering, we might not want to call
the map function eagerly; rather we want to call it only once,
after the generator is moved to the target element.
2026-02-15 20:44:21 +01:00
Martin Hořeňovský 3a0cf7e75f Support filtering on both sections and generators (#3069)
Not being able to filter generators to specific element has been regularly
causing problems. It was possible to use a dynamic section to run tests
for specific element in a generator, at least if the element had a nice
string representation, but the test case would still run once per element
in the generator.

With this change, it is possible to have the generator return only one
specific element, and do so based on the index, rather than the string
representation of the element. This enables simple debugging of tests
that fail for specific generator element.
2026-02-15 20:27:15 +01:00
Martin Hořeňovský b6c7b217d4 Improve test for --warn InfiniteGenerators 2026-02-13 21:30:26 +01:00
Martin Hořeňovský 045ac7acce Simplify IGeneratorTracker
* Removed `IGeneratorTracker::hasGenerator`, as it was never used.
* Removed `IGeneratorTracker::setGenerator`, as actually using it
  after the tracker was used would lead to inconsistent behaviour.
  Instead, the tracker is given the generator it guards during
  construction.
2026-02-13 21:17:37 +01:00
Martin Hořeňovský 72671fdbdf Check for infinite generators before we construct generator's tracker 2026-02-13 21:17:06 +01:00
Martin Hořeňovský 120827d4d6 Fix formatting in catch_commandline.cpp 2026-02-13 21:16:03 +01:00
Martin Hořeňovský daadf42a0e Add --warn InfiniteGenerators 2026-02-10 09:37:19 +01:00
Martin Hořeňovský d079ee13ab Allow generators to declare themselves (infinite)
This will be useful later to implement warning on infinitely
running `GENERATE` expressions.
2026-02-10 09:37:15 +01:00
Martin Hořeňovský 0056cd4efb Remove Tuple sponsorship banner - sponsorship has ended 2026-02-09 10:23:43 +01:00
ThePhD de7e863013 🐛 Clang on Windows will define _MSC_VER and trip up these checks -- make it actually Visual C++-specific 2026-01-19 15:14:53 +01:00
Martin Hořeňovský 024aec9729 Add efficient skip forward to Values, Map and Take generators 2026-01-12 22:39:59 +01:00
Martin Hořeňovský 9eca713a1f Add option to skip forward to the generator interface 2026-01-12 16:58:15 +01:00
Martin Hořeňovský 44c597f074 Add Concat generator for combining multiple generators 2026-01-12 14:27:49 +01:00
Martin Hořeňovský 6aedc79870 Remove unused m_used_up member in the ChunkGenerator 2026-01-12 14:27:44 +01:00
dragon-archer fcbf006c78 Fix _NullFile for MinGW 2026-01-12 09:29:19 +01:00
Martin Hořeňovský 2580eadc42 Add UNSCOPED_CAPTURE
Closes #2954
Closes #3010
2026-01-11 14:53:08 +01:00
Martin Hořeňovský b59f4f3522 Rename DEPRECATED -> CATCH_DEPRECATED
Closes #3058
2026-01-06 20:26:08 +01:00
bigmoonbit cd4fc88e2a chore: fix some typos in comments (#3048)
Signed-off-by: bigmoonbit <bigmoonbit@outlook.com>
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2026-01-03 16:05:18 +01:00
Martin Hořeňovský a50ac2f681 Add ASan and TSan builds on Mac 2026-01-03 14:30:07 +01:00
Martin Hořeňovský b81ef2aa2e Add OUTPUT_ON_FAILURE and NO_TESTS_ACTIONS=error to CTest GHA actions 2026-01-03 14:07:25 +01:00
Martin Hořeňovský ec4dcbf9cb Fix Wweak-vtables in benchmarks/assertion_listener.cpp 2026-01-03 13:43:27 +01:00
qerased b66b89374e Add validation for --benchmark-samples to prevent crash with zero value (#3056)
* Add validation for --benchmark-samples to prevent crash with zero samples
* Add automated test for benchmark samples validation
* Update baselines for benchmark-samples validation
* Add missing test for benchmark samples validation

---------

Co-authored-by: Chan Aung <chan@Thinkpad.localdomain>
2026-01-02 23:15:13 +01:00
OliverBeeckAVM b7e31c9ab3 Suppress static analysis warning 26426 for Windows/MSVC builds (#3057)
Suppress `Global initializer calls a non-constexpr function 'Catch::makeTestInvoker' (i.22).`,
which is issued when using macro `TEST_CASE` for windows/MSVC builds.


---------

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2026-01-01 22:56:14 +01:00
Martin Hořeňovský 88abf9bf32 v3.12.0 v3.12.0 2025-12-28 22:31:54 +01:00
Martin Hořeňovský 970ec144f5 Thread safety in assertions is no longer experimental 2025-12-28 21:02:50 +01:00
Martin Hořeňovský eb3811c555 Fix lifetime issues when using UNSCOPED_X message macros
The original implementation of `UNSCOPED_X` message macros used a
clever hack to make the original implementation simpler: construct
an instance of `ScopedMessage` to manage its lifetime, but store
it in a vector, so its lifetime is not actually scope-based, and
we can manage it through the vector instance.

This hack made it so that the lifetime of the vector that manages
the fake `ScopedMessage`s must be outlived by the vector with the
actual messages. Originally this wasn't a problem, because they both
lived inside the run context instance. However, since then these
vectors became globals and thread-local. When this happened, it
still wasn't a problem; the two globals were declared in the right
order, so they were destroyed in the right order as well.

Then, in f80956a43a, these globals
were turned into magic static globals to improve their behaviour
in MSVC's Debug build mode. This caused their lifetimes to be
runtime-dependent; if a specific test thread added its first scoped
message before it added first unscoped message, the lifetimes
would be correct. If it instead added first unscoped message
before adding first scoped message, then there **might** be
invalid reads during thread destruction.

The fix is simple: do things properly and manage the lifetime of
messages in `UNSCOPED_X` explicitly. Then we don't have to deal
with the destruction of fake `ScopedMessage`s while the thread is
being destroyed, and the lifetime of the two vectors is no longer
tied together.

I also threw them both into a new type, to encapsulate some of the
unscoped message logic.
2025-12-26 15:53:30 +01:00
Martin Hořeňovský 343cc059fe Move to newer MacOS GHA runners
Macos-13 runners were deprecated, and macos-15 family brings back
intel runner that is usable by OSS projects.
2025-12-23 16:12:23 +01:00
Masashi Fujita 97091636d0 Fix conditional compilation for FreeBSD to exclude PlayStation platform 2025-12-12 09:38:52 +01:00
Martin Hořeňovský f80956a43a Use magic statics for non-trivial thread-local globals
This avoids calling the global's constructor on threads that will
never interact with them. Calling the constructor can have surprising
overhead, as e.g. MSVC's Debug mode `std::vector` will allocate in
the default constructor.

Closes #3050
2025-12-02 14:19:21 +01:00
Martin Hořeňovský 32eac2d1bb Only use thread_local in builds with thread safety enabled
MSVC cannot dllexport thread_local variables, so we avoid making
globals thread local if we won't support multiple threads anyway.

Closes #3044
2025-12-02 14:01:55 +01:00
Martin Hořeňovský e849735e11 Add tests for assertion thread safety 2025-12-01 10:45:07 +01:00
Martin Hořeňovský d26f763180 Initialize ReusableStringStream cache before user threads can run
The initialization itself is thread unsafe, and as such we cannot
allow it to be delayed until multiple user-spawned threads need it.
2025-12-01 10:44:31 +01:00
Martin Hořeňovský 5e44382423 Fix initialization of AtomicCounts for older standards 2025-12-01 10:42:43 +01:00
Martin Hořeňovský 985a3f4460 Fix lazy removal of unscoped messages also removing still valid msgs 2025-11-30 14:30:19 +01:00
Stefan Haller a1faad9315 Fix the help text for the --order command line argument
It was changed to rand in v3.9.0.
2025-11-07 21:28:41 +01:00
Martin Hořeňovský 31ee3beb0a Small documentation fixes
This includes 2 small typos I found when working on generator skipping,
and 1 typo found by @sfraczek in #3039.

Closes #3039
2025-10-16 20:45:28 +02:00
Martin Hořeňovský 3b853aa9fb Add lifetime attributes to JSON/XML writers 2025-10-16 20:37:05 +02:00
Martin Hořeňovský 49d79e9e9c Fix section filtering to make sense
Specifically, this commit makes the `-c`/`--section` parameter
strictly ordered and hierarchical, unlike how it behaved before,
which was a huge mess -- see #3038 for details.

Closes #3038
2025-10-16 09:16:56 +02:00
ZXShady 33e6fd217a Remove recursion when stringifying std::tuple 2025-10-04 22:10:36 +02:00
ZXShady a58df2d7c5 Outline part of formatting system_clock's time_point into cpp file 2025-10-04 22:10:36 +02:00
ZXShady a9223b2bb3 Outline catch_strnlen's definition into catch_tostring.cpp 2025-10-04 22:10:36 +02:00
Martin Hořeňovský 363ca5af18 Add lifetime annotations to more places using StringRef 2025-10-04 16:38:07 +02:00
Martin Hořeňovský cb6d713774 Add lifetimebound annotation to StringRef 2025-10-04 16:12:17 +02:00
Martin Hořeňovský 8e4ab5dd8f Annotate matcher combinators with CATCH_ATTR_LIFETIMEBOUND
The matcher combinators do not take ownership of the matchers
being combined, which can catch the users off-guard, when code like
this

```cpp
using Catch::Matchers::EndsWith;
using Catch::Matchers::ContainsSubstring;

auto combinedMatcher = EndsWith("as a service")
                       && ContainsSubstring("web scale");

REQUIRE_THAT( getSomeString(), combinedMatcher );
```

leads to use-after-free, as the `combinedMatcher` refers to matcher
temporaries that no longer exists. With this commit, users of Clang,
MSVC or other compiler that understands the `lifetimebound` attribute,
should get a warning.
2025-10-03 22:27:29 +02:00
Martin Hořeňovský 8219ed79f2 Add CATCH_ATTR_LIFETIMEBOUND macro polyfill over lifetimebound attr 2025-10-03 22:15:27 +02:00
Martin Hořeňovský b3fb4b9fea v3.11.0 v3.11.0 2025-09-30 10:54:31 +02:00