Skip to content

Commit

Permalink
v3.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed Sep 17, 2024
1 parent 79f2d66 commit fa43b77
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 162 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()

project(Catch2
VERSION 3.7.0 # CML version placeholder, don't delete
VERSION 3.7.1 # CML version placeholder, don't delete
LANGUAGES CXX
# HOMEPAGE_URL is not supported until CMake version 3.12, which
# we do not target yet.
Expand Down
21 changes: 21 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Release notes
**Contents**<br>
[3.7.1](#371)<br>
[3.7.0](#370)<br>
[3.6.0](#360)<br>
[3.5.4](#354)<br>
Expand Down Expand Up @@ -64,6 +65,26 @@
[Even Older versions](#even-older-versions)<br>


## 3.7.1

### Improvements
* Applied the JUnit reporter's optimization from last release to the SonarQube reporter
* Suppressed `-Wuseless-cast` in `CHECK_THROWS_MATCHES` (#2904)
* Standardize exit codes for various failures
* Running no tests is now guaranteed to exit with 2 (without the `--allow-running-no-tests` flag)
* All tests skipped is now always 4 (...)
* Assertion failures are now always 42
* and so on

### Fixes
* Fixed out-of-bounds access when the arg parser encounters single `-` as an argument (#2905)

### Miscellaneous
* Added `catch_config_prefix_messages.hpp` to meson build (#2903)
* `catch_discover_tests` now supports skipped tests (#2873)
* You can get the old behaviour by calling `catch_discover_tests` with `SKIP_IS_FAILURE` option.


## 3.7.0

### Improvements
Expand Down
128 changes: 41 additions & 87 deletions extras/catch_amalgamated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

// SPDX-License-Identifier: BSL-1.0

// Catch v3.7.0
// Generated: 2024-08-14 12:04:53.604337
// Catch v3.7.1
// Generated: 2024-09-17 10:36:45.608896
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
Expand Down Expand Up @@ -627,7 +627,7 @@ std::string StringMaker<Catch::Approx>::convert(Catch::Approx const& value) {

namespace Catch {

AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const& _lazyExpression):
lazyExpression(_lazyExpression),
resultType(_resultType) {}

Expand Down Expand Up @@ -1170,7 +1170,13 @@ namespace Catch {
namespace Catch {

namespace {
const int MaxExitCode = 255;
static constexpr int TestFailureExitCode = 42;
static constexpr int UnspecifiedErrorExitCode = 1;
static constexpr int AllTestsSkippedExitCode = 4;
static constexpr int NoTestsRunExitCode = 2;
static constexpr int UnmatchedTestSpecExitCode = 3;
static constexpr int InvalidTestSpecExitCode = 5;


IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig&& config) {
auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, CATCH_MOVE(config));
Expand Down Expand Up @@ -1334,8 +1340,7 @@ namespace Catch {
}

int Session::applyCommandLine( int argc, char const * const * argv ) {
if( m_startupExceptions )
return 1;
if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; }

auto result = m_cli.parse( Clara::Args( argc, argv ) );

Expand All @@ -1351,7 +1356,7 @@ namespace Catch {
<< TextFlow::Column( result.errorMessage() ).indent( 2 )
<< "\n\n";
errStream->stream() << "Run with -? for usage\n\n" << std::flush;
return MaxExitCode;
return UnspecifiedErrorExitCode;
}

if( m_configData.showHelp )
Expand Down Expand Up @@ -1421,8 +1426,7 @@ namespace Catch {
}

int Session::runInternal() {
if( m_startupExceptions )
return 1;
if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; }

if (m_configData.showHelp || m_configData.libIdentify) {
return 0;
Expand All @@ -1433,7 +1437,7 @@ namespace Catch {
<< ") must be greater than the shard index ("
<< m_configData.shardIndex << ")\n"
<< std::flush;
return 1;
return UnspecifiedErrorExitCode;
}

CATCH_TRY {
Expand All @@ -1456,7 +1460,7 @@ namespace Catch {
for ( auto const& spec : invalidSpecs ) {
reporter->reportInvalidTestSpec( spec );
}
return 1;
return InvalidTestSpecExitCode;
}


Expand All @@ -1470,29 +1474,29 @@ namespace Catch {

if ( tests.hadUnmatchedTestSpecs()
&& m_config->warnAboutUnmatchedTestSpecs() ) {
return 3;
// UnmatchedTestSpecExitCode
return UnmatchedTestSpecExitCode;
}

if ( totals.testCases.total() == 0
&& !m_config->zeroTestsCountAsSuccess() ) {
return 2;
return NoTestsRunExitCode;
}

if ( totals.testCases.total() > 0 &&
totals.testCases.total() == totals.testCases.skipped
&& !m_config->zeroTestsCountAsSuccess() ) {
return 4;
return AllTestsSkippedExitCode;
}

// Note that on unices only the lower 8 bits are usually used, clamping
// the return value to 255 prevents false negative when some multiple
// of 256 tests has failed
return (std::min) (MaxExitCode, static_cast<int>(totals.assertions.failed));
if ( totals.assertions.failed ) { return TestFailureExitCode; }
return 0;

}
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
catch( std::exception& ex ) {
Catch::cerr() << ex.what() << '\n' << std::flush;
return MaxExitCode;
return UnspecifiedErrorExitCode;
}
#endif
}
Expand Down Expand Up @@ -1528,26 +1532,26 @@ namespace Catch {
static_assert(sizeof(TestCaseProperties) == sizeof(TCP_underlying_type),
"The size of the TestCaseProperties is different from the assumed size");

TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) {
constexpr TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) {
return static_cast<TestCaseProperties>(
static_cast<TCP_underlying_type>(lhs) | static_cast<TCP_underlying_type>(rhs)
);
}

TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) {
constexpr TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) {
lhs = static_cast<TestCaseProperties>(
static_cast<TCP_underlying_type>(lhs) | static_cast<TCP_underlying_type>(rhs)
);
return lhs;
}

TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) {
constexpr TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) {
return static_cast<TestCaseProperties>(
static_cast<TCP_underlying_type>(lhs) & static_cast<TCP_underlying_type>(rhs)
);
}

bool applies(TestCaseProperties tcp) {
constexpr bool applies(TestCaseProperties tcp) {
static_assert(static_cast<TCP_underlying_type>(TestCaseProperties::None) == 0,
"TestCaseProperties::None must be equal to 0");
return tcp != TestCaseProperties::None;
Expand Down Expand Up @@ -1586,7 +1590,7 @@ namespace Catch {
return "Anonymous test case " + std::to_string(++counter);
}

StringRef extractFilenamePart(StringRef filename) {
constexpr StringRef extractFilenamePart(StringRef filename) {
size_t lastDot = filename.size();
while (lastDot > 0 && filename[lastDot - 1] != '.') {
--lastDot;
Expand All @@ -1604,7 +1608,7 @@ namespace Catch {
}

// Returns the upper bound on size of extra tags ([#file]+[.])
size_t sizeOfExtraTags(StringRef filepath) {
constexpr size_t sizeOfExtraTags(StringRef filepath) {
// [.] is 3, [#] is another 3
const size_t extras = 3 + 3;
return extractFilenamePart(filepath).size() + extras;
Expand Down Expand Up @@ -1765,10 +1769,6 @@ namespace Catch {
return lhs.tags < rhs.tags;
}

TestCaseInfo const& TestCaseHandle::getTestCaseInfo() const {
return *m_info;
}

} // end namespace Catch


Expand Down Expand Up @@ -1909,7 +1909,7 @@ namespace Catch {

namespace {
static auto getCurrentNanosecondsSinceEpoch() -> uint64_t {
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
}
} // end unnamed namespace

Expand Down Expand Up @@ -2280,7 +2280,7 @@ namespace Catch {
}

Version const& libraryVersion() {
static Version version( 3, 7, 0, "", 0 );
static Version version( 3, 7, 1, "", 0 );
return version;
}

Expand Down Expand Up @@ -2536,8 +2536,8 @@ namespace Catch {
void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
}
void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) {
m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
void AssertionHandler::handleMessage(ResultWas::OfType resultType, std::string&& message) {
m_resultCapture.handleMessage( m_assertionInfo, resultType, CATCH_MOVE(message), m_reaction );
}

auto AssertionHandler::allowThrows() const -> bool {
Expand Down Expand Up @@ -2683,7 +2683,7 @@ namespace Catch {
{ TokenType::Argument,
next.substr( delimiterPos + 1, next.size() ) } );
} else {
if ( next[1] != '-' && next.size() > 2 ) {
if ( next.size() > 1 && next[1] != '-' && next.size() > 2 ) {
// Combined short args, e.g. "-ab" for "-a -b"
for ( size_t i = 1; i < next.size(); ++i ) {
m_tokenBuffer.push_back(
Expand Down Expand Up @@ -3656,12 +3656,6 @@ namespace Catch {
return *Context::currentContext;
}

void Context::setResultCapture( IResultCapture* resultCapture ) {
m_resultCapture = resultCapture;
}

void Context::setConfig( IConfig const* config ) { m_config = config; }

SimplePcg32& sharedRng() {
static SimplePcg32 s_rng;
return s_rng;
Expand Down Expand Up @@ -5547,26 +5541,6 @@ ReporterSpec::ReporterSpec(



namespace Catch {

bool isOk( ResultWas::OfType resultType ) {
return ( resultType & ResultWas::FailureBit ) == 0;
}
bool isJustInfo( int flags ) {
return flags == ResultWas::Info;
}

ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
}

bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }

} // end namespace Catch



#include <cstdio>
#include <sstream>
#include <vector>
Expand Down Expand Up @@ -6232,13 +6206,13 @@ namespace Catch {
void RunContext::handleMessage(
AssertionInfo const& info,
ResultWas::OfType resultType,
StringRef message,
std::string&& message,
AssertionReaction& reaction
) {
m_lastAssertionInfo = info;

AssertionResultData data( resultType, LazyExpression( false ) );
data.message = static_cast<std::string>(message);
data.message = CATCH_MOVE( message );
AssertionResult assertionResult{ m_lastAssertionInfo,
CATCH_MOVE( data ) };

Expand Down Expand Up @@ -7153,7 +7127,7 @@ namespace Catch {
TestType m_testAsFunction;

public:
TestInvokerAsFunction( TestType testAsFunction ) noexcept:
constexpr TestInvokerAsFunction( TestType testAsFunction ) noexcept:
m_testAsFunction( testAsFunction ) {}

void invoke() const override { m_testAsFunction(); }
Expand Down Expand Up @@ -7888,36 +7862,16 @@ namespace {
os.flags(f);
}

bool shouldNewline(XmlFormatting fmt) {
constexpr bool shouldNewline(XmlFormatting fmt) {
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Newline));
}

bool shouldIndent(XmlFormatting fmt) {
constexpr bool shouldIndent(XmlFormatting fmt) {
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Indent));
}

} // anonymous namespace

XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) {
return static_cast<XmlFormatting>(
static_cast<std::underlying_type_t<XmlFormatting>>(lhs) |
static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
);
}

XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) {
return static_cast<XmlFormatting>(
static_cast<std::underlying_type_t<XmlFormatting>>(lhs) &
static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
);
}


XmlEncode::XmlEncode( StringRef str, ForWhat forWhat )
: m_str( str ),
m_forWhat( forWhat )
{}

void XmlEncode::encodeTo( std::ostream& os ) const {
// Apostrophe escaping not necessary if we always use " to write attributes
// (see: http://www.w3.org/TR/xml/#syntax)
Expand Down Expand Up @@ -11050,9 +11004,9 @@ namespace Catch {
if (!rootName.empty())
name = rootName + '/' + name;

if ( sectionNode.hasAnyAssertions()
if ( sectionNode.stats.assertions.total() > 0
|| !sectionNode.stdOut.empty()
|| !sectionNode.stdErr.empty() ) {
|| !sectionNode.stdErr.empty() ) {
XmlWriter::ScopedElement e = xml.scopedElement("testCase");
xml.writeAttribute("name"_sr, name);
xml.writeAttribute("duration"_sr, static_cast<long>(sectionNode.stats.durationInSeconds * 1000));
Expand Down
Loading

0 comments on commit fa43b77

Please sign in to comment.