Commit Graph

4515 Commits

Author SHA1 Message Date
SirNate0
b15158c1db Fix typo in test-cases-and-sections.md 2024-08-13 12:28:03 +02:00
Martin Hořeňovský
8898cc6160
Mark non-const function for TEST_CASE_METHOD as deprecated 2024-08-05 20:13:03 +02:00
Keith Stockdale
f7cd0ba051
TEST_CASE_PERSISTENT_FIXTURE: A new fixture macro for allowing persistent fixtures throughout a TEST_CASE (#2885)
This PR introduces a new `TEST_CASE` macro called `TEST_CASE_PERSISTENT_FIXTURE`. `TEST_CASE_PERSISTENT_FIXTURE` offers the same functionality as `TEST_CASE_METHOD` except for one difference. The object on which the test method is invoked is only created once for all invocations of the test case. The object is created just after the `testCaseStarting` event is broadcast and the object is destroyed just before the `testCaseEnding` event is broadcast.

The main motivation for this new functionality is to allow `TEST_CASE`s to do expensive setup and teardown once per `TEST_CASE`, without having to resort to abusing event listeners or static function variables with manual initialization.


Implements #1602

---------

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2024-08-05 17:01:41 +02:00
Martin Hořeňovský
33e24b14fc
Add missing break to a switch to silence fall-through warning
Closes #2891
2024-07-31 17:38:02 +02:00
Martin Hořeňovský
a40dd478f3
Update docs for REQUIRE_THROWS_MATCHES 2024-07-27 14:02:28 +02:00
Andy Phillips
85b7f3d6ab
Add optional argument to catch_discover_tests to set DYLD_FRAMEWORK_PATH (#2880)
* Added optional argument to catch_discover_tests to set the DYLD_FRAMEWORK_PATH environment variable on Apple platforms.
2024-07-22 19:25:24 +02:00
Martin Hořeňovský
7af96bbb22
Slight improvement to computing clock resolution in benchmarking 2024-07-22 10:54:16 +02:00
Martin Hořeňovský
22e6490325
Remove copyability from BenchmarkFunction
Technically we should be able to remove moveability as well, but
then we would need a larger surgery. This already improves the
compile times and binary sizes by a surprising amount.
2024-07-22 10:54:14 +02:00
Martin Hořeňovský
595bf9864e
Update to macos-12 GHA image
Since the last time, macos-12 has fixed the toolchain's linker
crash bug, so we can update here. macos-13 has a new and exciting
bug when unwinding exceptions in binaries compiled with GCC, so
we cannot update all the way at this time.
2024-07-22 10:47:25 +02:00
Vertexwahn
381f29e974 Bazel support: Update skylib version to 1.6.1 2024-07-22 10:21:44 +02:00
KStocky
37c8b2d2b3 Adding unapproved.txt files to gitignore 2024-07-19 22:21:09 +02:00
KStocky
292d64da32 Ignore all files with the name CMakeUserPresets.json 2024-07-19 22:08:57 +02:00
Martin Hořeňovský
4e8d92bf02
v3.6.0 2024-05-05 20:58:18 +02:00
Jeremy Rifkin
8ce2426e53
Handle ANSI escape sequences when performing column wrapping (#2849)
This PR adds functionality to skip around ANSI escape sequences in catch_textflow so they do not contribute to line length and line wrapping code does not split escape sequences in the middle. I've implemented this by creating a AnsiSkippingString abstraction that has a bidirectional iterator that can skip around escape sequences while iterating. Additionally I refactored Column::const_iterator to be iterator-based rather than index-based so this abstraction is a simple drop-in for std::string.

Currently only color sequences are handled, other escape sequences are left unaffected.

Motivation: Text with ANSI color sequences gets messed up when being output by Catch2 #2833.
2024-05-04 23:43:52 +02:00
Martin Hořeňovský
fa5a53df17
Explicitly silence Wnon-virtual-dtor in Decomposer and MatchExpr
Closes #2854
2024-04-30 23:51:36 +02:00
Martin Hořeňovský
a654e4b038
Don't include numerically unstable tests in approvals 2024-04-30 19:21:27 +02:00
Martin Hořeňovský
ef713582d2
Default StringMaker<FloatingPointType>::precision to max_digits10
`max_digits10` is the number of decimal digits that the type _can_
represent, in other words, the number of decimal digits needed to
disambiguate any two floating point numbers when serialized to
a string.
2024-04-30 17:18:48 +02:00
Martin Hořeňovský
efb39689d9 Add test for handleFatalErrorCondition within JUnit reporter 2024-04-21 21:52:33 +02:00
Altan Birler
42fe78d0ba Handle active Sections for fatal errors
Closes #1210

When a signal is caught, the destructors of Sections will not be called.
Thus, we must call `sectionEndedEarly` manually for those Sections.

Example test case:
```
TEST_CASE("broken") {
   SECTION("section") {
      /// Use illegal cpu instruction
      __asm__ __volatile__("ud2" : : : "memory");
   }
}
```
2024-04-21 21:52:33 +02:00
c8ef
2bce3e276b
add bazel build rule for SelfTest (#2857)
This PR primarily accomplishes two tasks:

1) It adds MODULE.bazel.lock to the .gitignore file.
2) It includes a Bazel build rule for SelfTest, which can be utilized with the command bazel test //tests:catch2_self_test.
2024-04-21 21:05:55 +02:00
Vincent Saulue-Laborde
df04df94db conanfile: fix cmake_target_name of Catch2::Catch2.
The "Catch2 without default main" target is currently unspecified in
Conan, and defaults to catch2::catch2base. This commit switches it back
to Catch2::Catch2, as specified in the docs.
2024-04-20 14:31:04 +02:00
AgostonSzepessy
f2320724a7
Fix build on ARM64EC (#2858)
Remove `#pragma intrinsic(_umul128)` because it doesn't work on
ARM64EC and x64 works without it.

Co-authored-by: Agoston Szepessy <agos@microsoft.com>
2024-04-19 10:36:37 +02:00
Vincent Saulue-Laborde
8e80b8f22c conanfile: set compatibility_cppstr = False.
The Catch libraries have different API/ABI depending on the c++
standard they are compiled with. For example, the following function
isn't in the binary when compiled with C++14, only with C++17 or later:

StringMaker<std::string_view>::convert(std::string_view str);

By default, Conan is allowed to serve Catch libraries compiled in C++14
into a project using C++17/20, potentially causing linker errors
because of missing symbols. This PR overrides this default behaviour:
the C++ standard of the Catch library will exactly match the one of
the requiring project (building Catch from source if necessary).
2024-04-18 21:47:12 +02:00
Ian Bell
53ddf37af4
Use Catch::StringMaker for output in WithinRelMatcher (#2846)
The WithinRelMatcher does not listen to the precision specification; it just naively pipes to stringstream. If you specify the precision, that has no impact on the outputted values when the match fails.

This fix makes the WithinRelMatcher listen to the precision (https://github.com/catchorg/Catch2/blob/devel/docs/tostring.md#floating-point-precision) specified by: Catch::StringMaker<float>::precision
2024-04-15 13:35:39 +02:00
Martin Hořeňovský
029fe3b460
Actually check for x64 target with MSVC 2024-04-13 22:51:17 +02:00
Martin Hořeňovský
65794fd2b8
Fix ARM64 windows builds
Apparently I looked at the docs for umulh when checking availability,
and umul128 is x64 only.
2024-04-12 16:40:06 +02:00
Chris Thrasher
838f8d71cb
Remove unnecessary CMake variables (#2853)
* Remove unnecessary variable

* Remove unused variable
2024-04-11 15:39:08 +02:00
Martin Hořeňovský
b5373dadca
v3.5.4 2024-04-10 12:05:46 +02:00
Martin Hořeňovský
cd8f97e6c7
Explicitly outline TestRegistry destructor into .cpp file
This fixes compilation issue with C++23 mode against libstdc++.

Closes #2852
2024-04-08 13:57:59 +02:00
Martin Hořeňovský
05fb437cbb
Fix & extend tests for comparing const instances of zero lit types 2024-04-08 13:15:35 +02:00
Martin Hořeňovský
71b11c4e33
Fix assertion for const instance of std::ordering
The issue was that `capture_by_value` was meant to be specialized
by plain type, e.g. `capture_by_value<std::weak_ordering>`, but
the TMP in Decomposer did not properly throw away `const` (and
`volatile`) qualifiers, before taking the value of `capture_by_value`.
2024-04-08 11:33:43 +02:00
Martin Hořeňovský
0a6a2ce887
Fix preprocessor check for enabling FP reproducibility tests
This solves warning about the `uniform_fp_test_params` helper
being unused on M1 mac (or any other platform using GCC and not
using SSE2).

Closes #2845
2024-04-06 20:27:15 +02:00
Martin Hořeňovský
355a6e273b
Add M1 MacOS workflow 2024-04-06 20:27:14 +02:00
Martin Hořeňovský
bff6e35e2b
Replace last use of std::uniform_int_distribution with our own
Our implementation should be slightly faster, and has the
advantage of being consistent between platforms. This does not
have immediate user impact, because we currently use random_device
to generate random seed for resampling, but if we decide to change
this in the future, it is one less place to fix.
2024-04-03 13:28:26 +02:00
Martin Hořeňovský
d99eb8bec8
Optimize 64x64 extended multiplication implementation
Now we use intrinsics when possible, and fallback to optimized
implementation in portable C++. The difference is about 4x when
we can use intrinsics and about 2x when we cannot.

This should speed up our Lemire's algorithm implementation nicely.
2024-04-03 13:28:25 +02:00
Martin Hořeňovský
f181de9df4
Use SizedUnsignedType_t to pick UnsignedType for uniform_integer_distribution
The previously used `make_unsigned` approach combined with the overload
set of `extendedMult` caused compilation issues on MacOS platform. By
forcing the selection to be one of `std::uintX_t` types we don't need
to complicate the overload set further.
2024-04-03 13:27:10 +02:00
Martin Hořeňovský
9271083a04
Merge pull request #2850 from jeremy-rifkin/jr/mention-succeed-in-loggingmd
Mention SUCCEED along with FAIL in logging.md
2024-03-30 15:59:43 +01:00
Jeremy
07701f946a
Mention SUCCEED along with FAIL in logging.md 2024-03-29 15:40:18 -05:00
Martin Hořeňovský
7ce3579976
Allow CATCH_CONFIG_DEFAULT_REPORTER to be arbitrary reporter spec
Previously it could be just plain reporter name, e.g. `xml`, but
it could not specify other reporter options. This change is not
particularly useful for the built-in reporters, as it mostly comes
in handy for combining specific custom reporter with custom arguments,
and the built-in reporters do not have those.
2024-03-27 10:03:51 +01:00
Martin Hořeňovský
c0dfe13bb6
Improve example for custom options in reporter spec 2024-03-26 23:28:48 +01:00
Martin Hořeňovský
cad65c5003
Fix insufficiently escaped backslash in docs 2024-03-26 23:23:15 +01:00
Martin Hořeňovský
ad99834c14
Add back g++ 5 and 6 to the CI builds
Previously these were removed in bbba3d8a06,
to allow Decomposer changes that were not compatible with old
GCCs. However, the compatibility was restored in
459ac8562b, and so we can restore
the builds again.
2024-03-26 18:11:01 +01:00
Martin Hořeňovský
3cd90c5c3b Add tests for multiple args to DL_PATHS in catch_discover_tests 2024-03-26 18:04:17 +01:00
Cristian Le
202bdee977 Fix TEST_DL_PATHS to be multi-args
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2024-03-26 18:04:17 +01:00
Chris Thrasher
bfe3ff8f19 Specify minimum C++ version for amalgamated test build
This target previously did not specify its minimum C++ standard.
AppleClang was emitting warnings about the use of C++11 features
which is fixed by telling CMake that this target requires C++14.
Because this target does not link to the existing CMake targets
it never inherited that C++ standard requirement.
2024-03-13 21:12:59 +01:00
Uilian Ries
a2a3c55058
Improve Conan recipe support (#2831)
* Improve Conan recipe support
* export files
* supports c++14
* update Conan client in the CI
* Better compatibility with Conan 1.x
* Manage options and cppstd for Conan 1.x
* copy eveything from extra


Signed-off-by: Uilian Ries <uilianries@gmail.com>
2024-03-12 22:59:28 +01:00
morinmorin
eb8f2c5810 Add workaround for unguarded use of __has_extension 2024-03-12 22:57:59 +01:00
Chris Thrasher
88f4ec3cc5 Ignore C++98 related compiler warnings
Catch2 has long since required a standard newer than C++98 so we
can safely ignore any warnings related to such old standards.
2024-03-12 22:56:37 +01:00
Chris Thrasher
792c3b7549 Stop repeating conditional in endif()
This is not necessary so we can remove it. Most conditionals already
omit this anyways.
2024-03-12 22:55:12 +01:00
Chris Thrasher
1a44e6f661 Use built-in CMake feature for requiring a specific language standard
This feature was added in CMake 3.8. Requiring specific language
features is an outdated approach that CMake stopped supporting in
favor of simply specifyin the specific language standard you want.

https://cmake.org/cmake/help/v3.10/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
2024-03-12 22:54:09 +01:00