Skip to content

Commit

Permalink
update to latest
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Turner <[email protected]>
  • Loading branch information
spacey-sooty committed Dec 19, 2024
1 parent 73b45d0 commit 00347a3
Show file tree
Hide file tree
Showing 51 changed files with 658 additions and 458 deletions.
12 changes: 9 additions & 3 deletions thirdparty/catch2/cmake/modules/extras/Catch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
[OUTPUT_PREFIX prefix]
[OUTPUT_SUFFIX suffix]
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
[SKIP_IS_FAILURE]
)
``catch_discover_tests`` sets up a post-build command on the test executable
Expand Down Expand Up @@ -131,7 +132,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
of test cases from the test executable and when the tests are executed themselves.
This requires cmake/ctest >= 3.22.
`DISCOVERY_MODE mode``
``DISCOVERY_MODE mode``
Provides control over when ``catch_discover_tests`` performs test discovery.
By default, ``POST_BUILD`` sets up a post-build command to perform test discovery
at build time. In certain scenarios, like cross-compiling, this ``POST_BUILD``
Expand All @@ -144,14 +145,17 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
calling ``catch_discover_tests``. This provides a mechanism for globally selecting
a preferred test discovery behavior without having to modify each call site.
``SKIP_IS_FAILURE``
Disables skipped test detection.
#]=======================================================================]

#------------------------------------------------------------------------------
function(catch_discover_tests TARGET)

cmake_parse_arguments(
""
""
"SKIP_IS_FAILURE"
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX;DISCOVERY_MODE"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS;DL_FRAMEWORK_PATHS"
${ARGN}
Expand Down Expand Up @@ -192,6 +196,9 @@ function(catch_discover_tests TARGET)
TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR
)
if (NOT _SKIP_IS_FAILURE)
set(_PROPERTIES ${_PROPERTIES} SKIP_RETURN_CODE 4)
endif()

if(_DISCOVERY_MODE STREQUAL "POST_BUILD")
add_custom_command(
Expand Down Expand Up @@ -260,7 +267,6 @@ function(catch_discover_tests TARGET)
" CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n"
" TEST_DL_PATHS" " [==[" "${_DL_PATHS}" "]==]" "\n"
" TEST_DL_FRAMEWORK_PATHS" " [==[" "${_DL_FRAMEWORK_PATHS}" "]==]" "\n"
" CTEST_FILE" " [==[" "${CTEST_FILE}" "]==]" "\n"
" )" "\n"
" endif()" "\n"
" include(\"${ctest_tests_file}\")" "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace Catch {
double diff = b - m;
return a + diff * diff;
} ) /
( last - first );
static_cast<double>( last - first );
return std::sqrt( variance );
}

Expand Down Expand Up @@ -213,7 +213,7 @@ namespace Catch {
double* first,
double* last ) {
auto count = last - first;
double idx = (count - 1) * k / static_cast<double>(q);
double idx = static_cast<double>((count - 1) * k) / static_cast<double>(q);
int j = static_cast<int>(idx);
double g = idx - j;
std::nth_element(first, first + j, last);
Expand Down Expand Up @@ -316,10 +316,10 @@ namespace Catch {

double accel = sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) );
long n = static_cast<long>( resample.size() );
double prob_n =
double prob_n = static_cast<double>(
std::count_if( resample.begin(),
resample.end(),
[point]( double x ) { return x < point; } ) /
[point]( double x ) { return x < point; } )) /
static_cast<double>( n );
// degenerate case with uniform samples
if ( Catch::Detail::directCompare( prob_n, 0. ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Catch {

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

Expand Down
36 changes: 20 additions & 16 deletions thirdparty/catch2/src/main/native/cpp/catch2/catch_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
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 @@ -198,8 +204,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 @@ -215,7 +220,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 @@ -285,8 +290,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 @@ -297,7 +301,7 @@ namespace Catch {
<< ") must be greater than the shard index ("
<< m_configData.shardIndex << ")\n"
<< std::flush;
return 1;
return UnspecifiedErrorExitCode;
}

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


Expand All @@ -334,29 +338,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
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,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 @@ -80,7 +80,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 @@ -98,7 +98,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 @@ -259,8 +259,4 @@ namespace Catch {
return lhs.tags < rhs.tags;
}

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

} // end namespace Catch
4 changes: 2 additions & 2 deletions thirdparty/catch2/src/main/native/cpp/catch2/catch_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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 All @@ -30,7 +30,7 @@ namespace Catch {
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
}
auto Timer::getElapsedSeconds() const -> double {
return getElapsedMicroseconds()/1000000.0;
return static_cast<double>(getElapsedMicroseconds())/1000000.0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace Detail {
const int hexThreshold = 255;

struct Endianness {
enum Arch { Big, Little };
enum Arch : uint8_t {
Big,
Little
};

static Arch which() {
int one = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Catch {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace {
#endif // Windows/ ANSI/ None


#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC )
#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC ) || defined( __GLIBC__ )
# define CATCH_INTERNAL_HAS_ISATTY
# include <unistd.h>
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,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
Loading

0 comments on commit 00347a3

Please sign in to comment.