Commit Graph

4503 Commits

Author SHA1 Message Date
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
Cristian Morales Vega 459ac8562b Fix build with gcc 5.4
The Core Guidelines state "A base class destructor should be either
public and virtual, or protected and non-virtual" so, hopefully, no
static analyser will complain.
2024-03-12 17:15:03 +01:00
Martin Hořeňovský 8ac8190e49
v3.5.3 2024-03-01 22:07:10 +01:00
Martin Jeřábek b20b365fd2 releaseCommon: fix SyntaxWarning: invalid escape sequence '\s' 2024-03-01 21:24:45 +01:00
Martin Jeřábek 4d8affc989 less copies and allocations in replaceInPlace 2024-03-01 21:24:45 +01:00
Martin Jeřábek cde3509664 Fix various useful clang-tidy warnings
* bugprone-branch-clone
* bugprone-copy-constructor-init
* bugprone-empty-catch
* bugprone-sizeof-expression
* bugprone-switch-missing-default-case
* bugprone-unused-local-non-trivial-variable
* clang-analyzer-core.uninitialized.Assign
* clang-analyzer-cplusplus.Move
* clang-analyzer-optin.cplusplus.VirtualCall
* modernize-loop-convert
* modernize-raw-string-literal
* modernize-use-equals-default
* modernize-use-override
* modernize-use-using
* performance-avoid-endl
* performance-inefficient-string-concatenation
* performance-inefficient-vector-operation
* performance-noexcept-move-constructor
* performance-unnecessary-value-param (and improve generator example)
* readability-duplicate-include
* readability-inconsistent-declaration-parameter-name
* readability-non-const-parameter
* readability-redundant-casting
* readability-redundant-member-init
* readability-redundant-smartptr-get
* readability-static-accessed-through-instance
* unused variable in amalgamted tests
2024-03-01 21:24:45 +01:00
Martin Jeřábek 7677c1658e ci: add clang-tidy run 2024-03-01 21:24:45 +01:00
Martin Jeřábek 92d3b23913 add .clang-tidy config 2024-03-01 21:24:45 +01:00
Martin Jeřábek dca87563bb Evaluate argument of TEST_CASE in static-analysis mode 2024-03-01 21:24:45 +01:00
Martin Jeřábek da303cc668 Evaluate argument of (DYNAMIC_)SECTION in static-analysis mode 2024-03-01 21:24:45 +01:00
Martin Hořeňovský c3fd4eb17e
Update outdated tests for stringifying characters
Previously the tests relied purely on output changes in approvals.
Now the stringification output is checked directly as part of the
unit tests.
2024-03-01 15:09:11 +01:00
Sven fb51116d5b
Avoid useless FDuration cast in benchmark analysis (#2823)
Co-authored-by: Sven Johannsen <s.johannsen@bretgeld-engineering.de>
2024-02-26 23:25:58 +01:00
Martin Hořeňovský ed6ac8a629
Update AppVeyor exclusion branch pattern for Github Actions 2024-02-23 20:52:04 +01:00