This commit is contained in:
Martin Hořeňovský
2025-08-09 00:30:23 +02:00
parent 03c62cdf2e
commit 644821ce28
7 changed files with 88 additions and 36 deletions

View File

@@ -34,7 +34,7 @@ if(CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif() endif()
project(Catch2 project(Catch2
VERSION 3.9.0 # CML version placeholder, don't delete VERSION 3.9.1 # CML version placeholder, don't delete
LANGUAGES CXX LANGUAGES CXX
HOMEPAGE_URL "https://github.com/catchorg/Catch2" HOMEPAGE_URL "https://github.com/catchorg/Catch2"
DESCRIPTION "A modern, C++-native, unit test framework." DESCRIPTION "A modern, C++-native, unit test framework."

View File

@@ -2,6 +2,7 @@
# Release notes # Release notes
**Contents**<br> **Contents**<br>
[3.9.1](#391)<br>
[3.9.0](#390)<br> [3.9.0](#390)<br>
[3.8.1](#381)<br> [3.8.1](#381)<br>
[3.8.0](#380)<br> [3.8.0](#380)<br>
@@ -68,6 +69,19 @@
[Even Older versions](#even-older-versions)<br> [Even Older versions](#even-older-versions)<br>
## 3.9.1
### Fixes
* Fixed bad error reporting for multiple nested assertions (#1292)
* Fixed W4702 (unreachable code) in the polyfill for std::unreachable (#3007)
* Fixed decomposition of assertions comparing enum-backed bitfields (#3001)
* Fixed StringMaker specialization for `time_point<system_clock>` with non-default duration type (#2685)
### Improvements
* Exceptions thrown during stringification of decomposed expression no longer fail the assertion (#2980)
* The selection logic for `CATCH_TRAP` prefers `__builtin_debugtrap` on all platforms when Catch2 is compiled with Clang
## 3.9.0 ## 3.9.0
### Improvements ### Improvements

View File

@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// Catch v3.9.0 // Catch v3.9.1
// Generated: 2025-07-24 22:00:25.173359 // Generated: 2025-08-09 00:29:21.552225
// ---------------------------------------------------------- // ----------------------------------------------------------
// This file is an amalgamation of multiple different files. // This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly. // You probably shouldn't edit it directly.
@@ -2026,6 +2026,13 @@ namespace Detail {
rss << std::setw(2) << static_cast<unsigned>(bytes[i]); rss << std::setw(2) << static_cast<unsigned>(bytes[i]);
return rss.str(); return rss.str();
} }
std::string makeExceptionHappenedString() {
return "{ stringification failed with an exception: \"" +
translateActiveException() + "\" }";
}
} // end Detail namespace } // end Detail namespace
@@ -2271,7 +2278,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 3, 9, 0, "", 0 ); static Version version( 3, 9, 1, "", 0 );
return version; return version;
} }
@@ -3981,10 +3988,10 @@ namespace Catch {
// To avoid having to handle TFE explicitly everywhere, we just // To avoid having to handle TFE explicitly everywhere, we just
// rethrow it so that it goes back up the caller. // rethrow it so that it goes back up the caller.
catch( TestFailureException& ) { catch( TestFailureException& ) {
std::rethrow_exception(std::current_exception()); return "{ nested assertion failed }";
} }
catch( TestSkipException& ) { catch( TestSkipException& ) {
std::rethrow_exception(std::current_exception()); return "{ nested SKIP() called }";
} }
catch( std::exception const& ex ) { catch( std::exception const& ex ) {
return ex.what(); return ex.what();

View File

@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// Catch v3.9.0 // Catch v3.9.1
// Generated: 2025-07-24 22:00:24.654688 // Generated: 2025-08-09 00:29:20.303175
// ---------------------------------------------------------- // ----------------------------------------------------------
// This file is an amalgamation of multiple different files. // This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly. // You probably shouldn't edit it directly.
@@ -958,7 +958,7 @@ namespace Detail {
} }
explicit operator bool() const { explicit operator bool() const {
return m_ptr; return m_ptr != nullptr;
} }
friend void swap(unique_ptr& lhs, unique_ptr& rhs) { friend void swap(unique_ptr& lhs, unique_ptr& rhs) {
@@ -2151,9 +2151,7 @@ namespace Catch {
auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size()); auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size());
BenchmarkStats<> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; BenchmarkStats<> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
getResultCapture().benchmarkEnded(stats); getResultCapture().benchmarkEnded(stats);
} CATCH_CATCH_ANON (TestFailureException const&) { } CATCH_CATCH_ALL {
getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr);
} CATCH_CATCH_ALL{
getResultCapture().benchmarkFailed(translateActiveException()); getResultCapture().benchmarkFailed(translateActiveException());
// We let the exception go further up so that the // We let the exception go further up so that the
// test case is marked as failed. // test case is marked as failed.
@@ -2566,11 +2564,17 @@ namespace Catch {
namespace Detail { namespace Detail {
std::string makeExceptionHappenedString();
// This function dispatches all stringification requests inside of Catch. // This function dispatches all stringification requests inside of Catch.
// Should be preferably called fully qualified, like ::Catch::Detail::stringify // Should be preferably called fully qualified, like ::Catch::Detail::stringify
template <typename T> template <typename T>
std::string stringify(const T& e) { std::string stringify( const T& e ) {
return ::Catch::StringMaker<std::remove_cv_t<std::remove_reference_t<T>>>::convert(e); CATCH_TRY {
return ::Catch::StringMaker<
std::remove_cv_t<std::remove_reference_t<T>>>::convert( e );
}
CATCH_CATCH_ALL { return makeExceptionHappenedString(); }
} }
template<typename E> template<typename E>
@@ -3053,17 +3057,19 @@ struct ratio_string<std::milli> {
template<typename Duration> template<typename Duration>
struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> { struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> {
static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration> const& time_point) { static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration> const& time_point) {
auto converted = std::chrono::system_clock::to_time_t(time_point); const auto systemish = std::chrono::time_point_cast<
std::chrono::system_clock::duration>( time_point );
const auto as_time_t = std::chrono::system_clock::to_time_t( systemish );
#ifdef _MSC_VER #ifdef _MSC_VER
std::tm timeInfo = {}; std::tm timeInfo = {};
const auto err = gmtime_s(&timeInfo, &converted); const auto err = gmtime_s( &timeInfo, &as_time_t );
if ( err ) { if ( err ) {
return "gmtime from provided timepoint has failed. This " return "gmtime from provided timepoint has failed. This "
"happens e.g. with pre-1970 dates using Microsoft libc"; "happens e.g. with pre-1970 dates using Microsoft libc";
} }
#else #else
std::tm* timeInfo = std::gmtime(&converted); std::tm* timeInfo = std::gmtime( &as_time_t );
#endif #endif
auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
@@ -5238,10 +5244,11 @@ namespace Detail {
* *
* 3) If a type has no linkage, we also cannot capture it by reference. * 3) If a type has no linkage, we also cannot capture it by reference.
* The solution is once again to capture them by value. We handle * The solution is once again to capture them by value. We handle
* the common cases by using `std::is_arithmetic` as the default * the common cases by using `std::is_arithmetic` and `std::is_enum`
* for `Catch::capture_by_value`, but that is only a some-effort * as the default for `Catch::capture_by_value`, but that is only a
* heuristic. But as with 2), users can specialize `capture_by_value` * some-effort heuristic. These combine to capture all possible bitfield
* for their own types as needed. * bases, and also some trait-like types. As with 2), users can
* specialize `capture_by_value` for their own types as needed.
* *
* 4) To support C++20 and make the SFINAE on our decomposing operators * 4) To support C++20 and make the SFINAE on our decomposing operators
* work, the SFINAE has to happen in return type, rather than in * work, the SFINAE has to happen in return type, rather than in
@@ -5293,13 +5300,22 @@ namespace Catch {
using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<T>>; using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<T>>;
} }
// Note: There is nothing that stops us from extending this, // Note: This is about as much as we can currently reasonably support.
// e.g. to `std::is_scalar`, but the more encompassing // In an ideal world, we could capture by value small trivially
// traits are usually also more expensive. For now we // copyable types, but the actual `std::is_trivially_copyable`
// keep this as it used to be and it can be changed later. // trait is a huge mess with standard-violating results on
// GCC and Clang, which are unlikely to be fixed soon due to ABI
// concerns.
// `std::is_scalar` also causes issues due to the `is_pointer`
// component, which causes ambiguity issues with (references-to)
// function pointer. If those are resolved, we still need to
// disambiguate the overload set for arrays, through explicit
// overload for references to sized arrays.
template <typename T> template <typename T>
struct capture_by_value struct capture_by_value
: std::integral_constant<bool, std::is_arithmetic<T>{}> {}; : std::integral_constant<bool,
std::is_arithmetic<T>::value ||
std::is_enum<T>::value> {};
#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS ) #if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS )
template <> template <>
@@ -6241,9 +6257,13 @@ namespace Catch {
__assume( false ); __assume( false );
# elif defined( __GNUC__ ) # elif defined( __GNUC__ )
__builtin_unreachable(); __builtin_unreachable();
# endif # else // vv platform without known optimization hint
# endif // ^^ NDEBUG
std::terminate(); std::terminate();
# endif
# else // ^^ NDEBUG
// For non-release builds, we prefer termination on bug over UB
std::terminate();
# endif //
} }
} // namespace Detail } // namespace Detail
@@ -7447,7 +7467,7 @@ namespace Catch {
#define CATCH_VERSION_MAJOR 3 #define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 9 #define CATCH_VERSION_MINOR 9
#define CATCH_VERSION_PATCH 0 #define CATCH_VERSION_PATCH 1
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED #endif // CATCH_VERSION_MACROS_HPP_INCLUDED
@@ -9500,6 +9520,17 @@ namespace Catch {
bool isDebuggerActive(); bool isDebuggerActive();
} }
#if !defined( CATCH_TRAP ) && defined( __clang__ ) && defined( __has_builtin )
# if __has_builtin( __builtin_debugtrap )
# define CATCH_TRAP() __builtin_debugtrap()
# endif
#endif
#if !defined( CATCH_TRAP ) && defined( _MSC_VER )
# define CATCH_TRAP() __debugbreak()
#endif
#if !defined(CATCH_TRAP) // If we couldn't use compiler-specific impl from above, we get into platform-specific options
#ifdef CATCH_PLATFORM_MAC #ifdef CATCH_PLATFORM_MAC
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
@@ -9535,15 +9566,15 @@ namespace Catch {
#define CATCH_TRAP() raise(SIGTRAP) #define CATCH_TRAP() raise(SIGTRAP)
#endif #endif
#elif defined(_MSC_VER)
#define CATCH_TRAP() __debugbreak()
#elif defined(__MINGW32__) #elif defined(__MINGW32__)
extern "C" __declspec(dllimport) void __stdcall DebugBreak(); extern "C" __declspec(dllimport) void __stdcall DebugBreak();
#define CATCH_TRAP() DebugBreak() #define CATCH_TRAP() DebugBreak()
#endif #endif
#endif // ^^ CATCH_TRAP is not defined yet, so we define it
#ifndef CATCH_BREAK_INTO_DEBUGGER
#ifdef CATCH_TRAP #if !defined(CATCH_BREAK_INTO_DEBUGGER)
#if defined(CATCH_TRAP)
#define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }()
#else #else
#define CATCH_BREAK_INTO_DEBUGGER() []{}() #define CATCH_BREAK_INTO_DEBUGGER() []{}()

View File

@@ -8,7 +8,7 @@
project( project(
'catch2', 'catch2',
'cpp', 'cpp',
version: '3.9.0', # CML version placeholder, don't delete version: '3.9.1', # CML version placeholder, don't delete
license: 'BSL-1.0', license: 'BSL-1.0',
meson_version: '>=0.54.1', meson_version: '>=0.54.1',
) )

View File

@@ -36,7 +36,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 3, 9, 0, "", 0 ); static Version version( 3, 9, 1, "", 0 );
return version; return version;
} }

View File

@@ -10,6 +10,6 @@
#define CATCH_VERSION_MAJOR 3 #define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 9 #define CATCH_VERSION_MINOR 9
#define CATCH_VERSION_PATCH 0 #define CATCH_VERSION_PATCH 1
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED #endif // CATCH_VERSION_MACROS_HPP_INCLUDED