Skip to content

Commit fa43b77

Browse files
committed
v3.7.1
1 parent 79f2d66 commit fa43b77

File tree

7 files changed

+179
-162
lines changed

7 files changed

+179
-162
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
3333
endif()
3434

3535
project(Catch2
36-
VERSION 3.7.0 # CML version placeholder, don't delete
36+
VERSION 3.7.1 # CML version placeholder, don't delete
3737
LANGUAGES CXX
3838
# HOMEPAGE_URL is not supported until CMake version 3.12, which
3939
# we do not target yet.

docs/release-notes.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Release notes
44
**Contents**<br>
5+
[3.7.1](#371)<br>
56
[3.7.0](#370)<br>
67
[3.6.0](#360)<br>
78
[3.5.4](#354)<br>
@@ -64,6 +65,26 @@
6465
[Even Older versions](#even-older-versions)<br>
6566

6667

68+
## 3.7.1
69+
70+
### Improvements
71+
* Applied the JUnit reporter's optimization from last release to the SonarQube reporter
72+
* Suppressed `-Wuseless-cast` in `CHECK_THROWS_MATCHES` (#2904)
73+
* Standardize exit codes for various failures
74+
* Running no tests is now guaranteed to exit with 2 (without the `--allow-running-no-tests` flag)
75+
* All tests skipped is now always 4 (...)
76+
* Assertion failures are now always 42
77+
* and so on
78+
79+
### Fixes
80+
* Fixed out-of-bounds access when the arg parser encounters single `-` as an argument (#2905)
81+
82+
### Miscellaneous
83+
* Added `catch_config_prefix_messages.hpp` to meson build (#2903)
84+
* `catch_discover_tests` now supports skipped tests (#2873)
85+
* You can get the old behaviour by calling `catch_discover_tests` with `SKIP_IS_FAILURE` option.
86+
87+
6788
## 3.7.0
6889

6990
### Improvements

extras/catch_amalgamated.cpp

Lines changed: 41 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
// SPDX-License-Identifier: BSL-1.0
88

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

628628
namespace Catch {
629629

630-
AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
630+
AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const& _lazyExpression):
631631
lazyExpression(_lazyExpression),
632632
resultType(_resultType) {}
633633

@@ -1170,7 +1170,13 @@ namespace Catch {
11701170
namespace Catch {
11711171

11721172
namespace {
1173-
const int MaxExitCode = 255;
1173+
static constexpr int TestFailureExitCode = 42;
1174+
static constexpr int UnspecifiedErrorExitCode = 1;
1175+
static constexpr int AllTestsSkippedExitCode = 4;
1176+
static constexpr int NoTestsRunExitCode = 2;
1177+
static constexpr int UnmatchedTestSpecExitCode = 3;
1178+
static constexpr int InvalidTestSpecExitCode = 5;
1179+
11741180

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

13361342
int Session::applyCommandLine( int argc, char const * const * argv ) {
1337-
if( m_startupExceptions )
1338-
return 1;
1343+
if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; }
13391344

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

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

13571362
if( m_configData.showHelp )
@@ -1421,8 +1426,7 @@ namespace Catch {
14211426
}
14221427

14231428
int Session::runInternal() {
1424-
if( m_startupExceptions )
1425-
return 1;
1429+
if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; }
14261430

14271431
if (m_configData.showHelp || m_configData.libIdentify) {
14281432
return 0;
@@ -1433,7 +1437,7 @@ namespace Catch {
14331437
<< ") must be greater than the shard index ("
14341438
<< m_configData.shardIndex << ")\n"
14351439
<< std::flush;
1436-
return 1;
1440+
return UnspecifiedErrorExitCode;
14371441
}
14381442

14391443
CATCH_TRY {
@@ -1456,7 +1460,7 @@ namespace Catch {
14561460
for ( auto const& spec : invalidSpecs ) {
14571461
reporter->reportInvalidTestSpec( spec );
14581462
}
1459-
return 1;
1463+
return InvalidTestSpecExitCode;
14601464
}
14611465

14621466

@@ -1470,29 +1474,29 @@ namespace Catch {
14701474

14711475
if ( tests.hadUnmatchedTestSpecs()
14721476
&& m_config->warnAboutUnmatchedTestSpecs() ) {
1473-
return 3;
1477+
// UnmatchedTestSpecExitCode
1478+
return UnmatchedTestSpecExitCode;
14741479
}
14751480

14761481
if ( totals.testCases.total() == 0
14771482
&& !m_config->zeroTestsCountAsSuccess() ) {
1478-
return 2;
1483+
return NoTestsRunExitCode;
14791484
}
14801485

14811486
if ( totals.testCases.total() > 0 &&
14821487
totals.testCases.total() == totals.testCases.skipped
14831488
&& !m_config->zeroTestsCountAsSuccess() ) {
1484-
return 4;
1489+
return AllTestsSkippedExitCode;
14851490
}
14861491

1487-
// Note that on unices only the lower 8 bits are usually used, clamping
1488-
// the return value to 255 prevents false negative when some multiple
1489-
// of 256 tests has failed
1490-
return (std::min) (MaxExitCode, static_cast<int>(totals.assertions.failed));
1492+
if ( totals.assertions.failed ) { return TestFailureExitCode; }
1493+
return 0;
1494+
14911495
}
14921496
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
14931497
catch( std::exception& ex ) {
14941498
Catch::cerr() << ex.what() << '\n' << std::flush;
1495-
return MaxExitCode;
1499+
return UnspecifiedErrorExitCode;
14961500
}
14971501
#endif
14981502
}
@@ -1528,26 +1532,26 @@ namespace Catch {
15281532
static_assert(sizeof(TestCaseProperties) == sizeof(TCP_underlying_type),
15291533
"The size of the TestCaseProperties is different from the assumed size");
15301534

1531-
TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) {
1535+
constexpr TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) {
15321536
return static_cast<TestCaseProperties>(
15331537
static_cast<TCP_underlying_type>(lhs) | static_cast<TCP_underlying_type>(rhs)
15341538
);
15351539
}
15361540

1537-
TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) {
1541+
constexpr TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) {
15381542
lhs = static_cast<TestCaseProperties>(
15391543
static_cast<TCP_underlying_type>(lhs) | static_cast<TCP_underlying_type>(rhs)
15401544
);
15411545
return lhs;
15421546
}
15431547

1544-
TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) {
1548+
constexpr TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) {
15451549
return static_cast<TestCaseProperties>(
15461550
static_cast<TCP_underlying_type>(lhs) & static_cast<TCP_underlying_type>(rhs)
15471551
);
15481552
}
15491553

1550-
bool applies(TestCaseProperties tcp) {
1554+
constexpr bool applies(TestCaseProperties tcp) {
15511555
static_assert(static_cast<TCP_underlying_type>(TestCaseProperties::None) == 0,
15521556
"TestCaseProperties::None must be equal to 0");
15531557
return tcp != TestCaseProperties::None;
@@ -1586,7 +1590,7 @@ namespace Catch {
15861590
return "Anonymous test case " + std::to_string(++counter);
15871591
}
15881592

1589-
StringRef extractFilenamePart(StringRef filename) {
1593+
constexpr StringRef extractFilenamePart(StringRef filename) {
15901594
size_t lastDot = filename.size();
15911595
while (lastDot > 0 && filename[lastDot - 1] != '.') {
15921596
--lastDot;
@@ -1604,7 +1608,7 @@ namespace Catch {
16041608
}
16051609

16061610
// Returns the upper bound on size of extra tags ([#file]+[.])
1607-
size_t sizeOfExtraTags(StringRef filepath) {
1611+
constexpr size_t sizeOfExtraTags(StringRef filepath) {
16081612
// [.] is 3, [#] is another 3
16091613
const size_t extras = 3 + 3;
16101614
return extractFilenamePart(filepath).size() + extras;
@@ -1765,10 +1769,6 @@ namespace Catch {
17651769
return lhs.tags < rhs.tags;
17661770
}
17671771

1768-
TestCaseInfo const& TestCaseHandle::getTestCaseInfo() const {
1769-
return *m_info;
1770-
}
1771-
17721772
} // end namespace Catch
17731773

17741774

@@ -1909,7 +1909,7 @@ namespace Catch {
19091909

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

@@ -2280,7 +2280,7 @@ namespace Catch {
22802280
}
22812281

22822282
Version const& libraryVersion() {
2283-
static Version version( 3, 7, 0, "", 0 );
2283+
static Version version( 3, 7, 1, "", 0 );
22842284
return version;
22852285
}
22862286

@@ -2536,8 +2536,8 @@ namespace Catch {
25362536
void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
25372537
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
25382538
}
2539-
void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) {
2540-
m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
2539+
void AssertionHandler::handleMessage(ResultWas::OfType resultType, std::string&& message) {
2540+
m_resultCapture.handleMessage( m_assertionInfo, resultType, CATCH_MOVE(message), m_reaction );
25412541
}
25422542

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

3659-
void Context::setResultCapture( IResultCapture* resultCapture ) {
3660-
m_resultCapture = resultCapture;
3661-
}
3662-
3663-
void Context::setConfig( IConfig const* config ) { m_config = config; }
3664-
36653659
SimplePcg32& sharedRng() {
36663660
static SimplePcg32 s_rng;
36673661
return s_rng;
@@ -5547,26 +5541,6 @@ ReporterSpec::ReporterSpec(
55475541

55485542

55495543

5550-
namespace Catch {
5551-
5552-
bool isOk( ResultWas::OfType resultType ) {
5553-
return ( resultType & ResultWas::FailureBit ) == 0;
5554-
}
5555-
bool isJustInfo( int flags ) {
5556-
return flags == ResultWas::Info;
5557-
}
5558-
5559-
ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
5560-
return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
5561-
}
5562-
5563-
bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
5564-
bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
5565-
5566-
} // end namespace Catch
5567-
5568-
5569-
55705544
#include <cstdio>
55715545
#include <sstream>
55725546
#include <vector>
@@ -6232,13 +6206,13 @@ namespace Catch {
62326206
void RunContext::handleMessage(
62336207
AssertionInfo const& info,
62346208
ResultWas::OfType resultType,
6235-
StringRef message,
6209+
std::string&& message,
62366210
AssertionReaction& reaction
62376211
) {
62386212
m_lastAssertionInfo = info;
62396213

62406214
AssertionResultData data( resultType, LazyExpression( false ) );
6241-
data.message = static_cast<std::string>(message);
6215+
data.message = CATCH_MOVE( message );
62426216
AssertionResult assertionResult{ m_lastAssertionInfo,
62436217
CATCH_MOVE( data ) };
62446218

@@ -7153,7 +7127,7 @@ namespace Catch {
71537127
TestType m_testAsFunction;
71547128

71557129
public:
7156-
TestInvokerAsFunction( TestType testAsFunction ) noexcept:
7130+
constexpr TestInvokerAsFunction( TestType testAsFunction ) noexcept:
71577131
m_testAsFunction( testAsFunction ) {}
71587132

71597133
void invoke() const override { m_testAsFunction(); }
@@ -7888,36 +7862,16 @@ namespace {
78887862
os.flags(f);
78897863
}
78907864

7891-
bool shouldNewline(XmlFormatting fmt) {
7865+
constexpr bool shouldNewline(XmlFormatting fmt) {
78927866
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Newline));
78937867
}
78947868

7895-
bool shouldIndent(XmlFormatting fmt) {
7869+
constexpr bool shouldIndent(XmlFormatting fmt) {
78967870
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Indent));
78977871
}
78987872

78997873
} // anonymous namespace
79007874

7901-
XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) {
7902-
return static_cast<XmlFormatting>(
7903-
static_cast<std::underlying_type_t<XmlFormatting>>(lhs) |
7904-
static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
7905-
);
7906-
}
7907-
7908-
XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) {
7909-
return static_cast<XmlFormatting>(
7910-
static_cast<std::underlying_type_t<XmlFormatting>>(lhs) &
7911-
static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
7912-
);
7913-
}
7914-
7915-
7916-
XmlEncode::XmlEncode( StringRef str, ForWhat forWhat )
7917-
: m_str( str ),
7918-
m_forWhat( forWhat )
7919-
{}
7920-
79217875
void XmlEncode::encodeTo( std::ostream& os ) const {
79227876
// Apostrophe escaping not necessary if we always use " to write attributes
79237877
// (see: http://www.w3.org/TR/xml/#syntax)
@@ -11050,9 +11004,9 @@ namespace Catch {
1105011004
if (!rootName.empty())
1105111005
name = rootName + '/' + name;
1105211006

11053-
if ( sectionNode.hasAnyAssertions()
11007+
if ( sectionNode.stats.assertions.total() > 0
1105411008
|| !sectionNode.stdOut.empty()
11055-
|| !sectionNode.stdErr.empty() ) {
11009+
|| !sectionNode.stdErr.empty() ) {
1105611010
XmlWriter::ScopedElement e = xml.scopedElement("testCase");
1105711011
xml.writeAttribute("name"_sr, name);
1105811012
xml.writeAttribute("duration"_sr, static_cast<long>(sectionNode.stats.durationInSeconds * 1000));

0 commit comments

Comments
 (0)