From 2025e88354911f1f112c384ffd9b345de100cedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 22 Apr 2020 13:44:22 +0200 Subject: [PATCH] Update Catch to v2.12.1 --- package.json | 2 +- worker/deps/catch/CMakeLists.txt | 2 +- worker/deps/catch/README.md | 4 +- .../catch/contrib/ParseAndAddCatchTests.cmake | 2 +- worker/deps/catch/docs/cmake-integration.md | 14 ++ worker/deps/catch/docs/command-line.md | 18 +- worker/deps/catch/docs/opensource-users.md | 31 +-- worker/deps/catch/docs/release-notes.md | 33 +++ worker/deps/catch/include/catch.hpp | 4 +- .../internal/catch_assertionhandler.cpp | 1 + .../internal/catch_compiler_capabilities.h | 17 +- .../catch/include/internal/catch_debugger.cpp | 3 +- .../catch/include/internal/catch_decomposer.h | 12 + .../internal/catch_interfaces_exception.h | 4 + .../include/internal/catch_matchers_vector.h | 78 +++--- .../catch_test_case_registry_impl.cpp | 71 +++++- .../internal/catch_test_spec_parser.cpp | 2 + .../catch/include/internal/catch_version.cpp | 2 +- .../reporters/catch_reporter_console.cpp | 2 +- worker/deps/catch/projects/CMakeLists.txt | 2 + .../catch/projects/ExtraTests/CMakeLists.txt | 2 +- .../Baselines/compact.sw.approved.txt | 24 ++ .../Baselines/console.std.approved.txt | 4 +- .../Baselines/console.sw.approved.txt | 150 +++++++++++- .../Baselines/console.swa4.approved.txt | 59 ++++- .../SelfTest/Baselines/junit.sw.approved.txt | 6 +- .../Baselines/sonarqube.sw.approved.txt | 4 + .../SelfTest/Baselines/xml.sw.approved.txt | 223 +++++++++++++++++- .../IntrospectiveTests/CmdLine.tests.cpp | 29 +++ .../SelfTest/UsageTests/Compilation.tests.cpp | 33 +++ .../SelfTest/UsageTests/Matchers.tests.cpp | 69 +++++- .../projects/TestScripts/testRandomOrder.py | 59 +++++ .../catch/single_include/catch2/catch.hpp | 198 +++++++++++----- worker/scripts/get-dep.sh | 2 +- 34 files changed, 1008 insertions(+), 158 deletions(-) create mode 100755 worker/deps/catch/projects/TestScripts/testRandomOrder.py diff --git a/package.json b/package.json index 02df826fc3..c44f99be43 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "uuid": "^7.0.3" }, "devDependencies": { - "@types/node": "^13.13.1", + "@types/node": "^13.13.2", "@types/random-number": "0.0.0", "@types/uuid": "^7.0.2", "@typescript-eslint/eslint-plugin": "^2.29.0", diff --git a/worker/deps/catch/CMakeLists.txt b/worker/deps/catch/CMakeLists.txt index 55bf413d7a..8e8ee02dc4 100644 --- a/worker/deps/catch/CMakeLists.txt +++ b/worker/deps/catch/CMakeLists.txt @@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() -project(Catch2 LANGUAGES CXX VERSION 2.11.3) +project(Catch2 LANGUAGES CXX VERSION 2.12.1) # Provide path for scripts list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") diff --git a/worker/deps/catch/README.md b/worker/deps/catch/README.md index e7469c7459..455b572e75 100644 --- a/worker/deps/catch/README.md +++ b/worker/deps/catch/README.md @@ -5,11 +5,11 @@ [![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) [![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2) [![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2) -[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/p9Pcgple8QWwgNR0) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/DQL97fLLJLZXwB8d) [![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) -The latest version of the single header can be downloaded directly using this link +The latest version of the single header can be downloaded directly using this link ## Catch2 is released! diff --git a/worker/deps/catch/contrib/ParseAndAddCatchTests.cmake b/worker/deps/catch/contrib/ParseAndAddCatchTests.cmake index 925d932819..3c551f07d7 100644 --- a/worker/deps/catch/contrib/ParseAndAddCatchTests.cmake +++ b/worker/deps/catch/contrib/ParseAndAddCatchTests.cmake @@ -144,7 +144,7 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget) if("${TestType}" STREQUAL "SCENARIO") set(Name "Scenario: ${Name}") endif() - if(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME AND TestFixture) + if(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME AND "${TestType}" MATCHES "(CATCH_)?TEST_CASE_METHOD" AND TestFixture ) set(CTestName "${TestFixture}:${Name}") else() set(CTestName "${Name}") diff --git a/worker/deps/catch/docs/cmake-integration.md b/worker/deps/catch/docs/cmake-integration.md index 57073c40c1..fda922ae49 100644 --- a/worker/deps/catch/docs/cmake-integration.md +++ b/worker/deps/catch/docs/cmake-integration.md @@ -6,6 +6,7 @@ [Automatic test registration](#automatic-test-registration)
[CMake project options](#cmake-project-options)
[Installing Catch2 from git repository](#installing-catch2-from-git-repository)
+[Installing Catch2 from vcpkg](#installing-catch2-from-vcpkg)
Because we use CMake to build Catch2, we also provide a couple of integration points for our users. @@ -220,6 +221,19 @@ when configuring the build, and then modify your calls to [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) accordingly. +## Installing Catch2 from vcpkg + +Alternatively, you can build and install Catch2 using [vcpkg](https://github.com/microsoft/vcpkg/) dependency manager: +``` +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +./bootstrap-vcpkg.sh +./vcpkg integrate install +./vcpkg install catch2 +``` + +The catch2 port in vcpkg is kept up to date by microsoft team members and community contributors. +If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. --- diff --git a/worker/deps/catch/docs/command-line.md b/worker/deps/catch/docs/command-line.md index 51eeb2f6d7..1741eb8f84 100644 --- a/worker/deps/catch/docs/command-line.md +++ b/worker/deps/catch/docs/command-line.md @@ -243,15 +243,25 @@ This option lists all available tests in a non-indented form, one on each line. Test cases are ordered one of three ways: - ### decl -Declaration order (this is the default order if no --order argument is provided). The order the tests were originally declared in. Note that ordering between files is not guaranteed and is implementation dependent. +Declaration order (this is the default order if no --order argument is provided). +Tests in the same TU are sorted using their declaration orders, different +TUs are in an implementation (linking) dependent order. + ### lex -Lexicographically sorted. Tests are sorted, alpha-numerically, by name. +Lexicographic order. Tests are sorted by their name, their tags are ignored. + ### rand -Randomly sorted. Test names are sorted using ```std::random_shuffle()```. By default the random number generator is seeded with 0 - and so the order is repeatable. To control the random seed see rng-seed. + +Randomly sorted. The order is dependent on Catch2's random seed (see +[`--rng-seed`](#rng-seed)), and is subset invariant. What this means +is that as long as the random seed is fixed, running only some tests +(e.g. via tag) does not change their relative order. + +> The subset stability was introduced in Catch2 v2.12.0 + ## Specify a seed for the Random Number Generator diff --git a/worker/deps/catch/docs/opensource-users.md b/worker/deps/catch/docs/opensource-users.md index 36c0db64f6..cbea85d791 100644 --- a/worker/deps/catch/docs/opensource-users.md +++ b/worker/deps/catch/docs/opensource-users.md @@ -20,18 +20,21 @@ Listing a project here does not imply endorsement and the plan is to keep these ### [ApprovalTests.cpp](https://github.com/approvals/ApprovalTests.cpp) C++11 implementation of Approval Tests, for quick, convenient testing of legacy code. +### [args](https://github.com/Taywee/args) +A simple header-only C++ argument parser library. + ### [Azmq](https://github.com/zeromq/azmq) Boost Asio style bindings for ZeroMQ. ### [Cataclysm: Dark Days Ahead](https://github.com/CleverRaven/Cataclysm-DDA) Post-apocalyptic survival RPG. -### [ChakraCore](https://github.com/Microsoft/ChakraCore) -The core part of the Chakra JavaScript engine that powers Microsoft Edge. - ### [ChaiScript](https://github.com/ChaiScript/ChaiScript) A, header-only, embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques. +### [ChakraCore](https://github.com/Microsoft/ChakraCore) +The core part of the Chakra JavaScript engine that powers Microsoft Edge. + ### [Clara](https://github.com/philsquared/Clara) A, single-header-only, type-safe, command line parser - which also prints formatted usage strings. @@ -65,9 +68,6 @@ A small C++ library wrapper for the native C ODBC API. ### [Nonius](https://github.com/libnonius/nonius) A header-only framework for benchmarking small snippets of C++ code. -### [SOCI](https://github.com/SOCI/soci) -The C++ Database Access Library. - ### [polymorphic_value](https://github.com/jbcoe/polymorphic_value) A polymorphic value-type for C++. @@ -77,18 +77,21 @@ A C++ client library for Consul. Consul is a distributed tool for discovering an ### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp) A library of algorithms for values-distributed-in-time. -### [thor](https://github.com/xorz57/thor) -Wrapper Library for CUDA. +### [SOCI](https://github.com/SOCI/soci) +The C++ Database Access Library. ### [TextFlowCpp](https://github.com/philsquared/textflowcpp) A small, single-header-only, library for wrapping and composing columns of text. +### [thor](https://github.com/xorz57/thor) +Wrapper Library for CUDA. + +### [toml++](https://github.com/marzer/tomlplusplus) +A header-only TOML parser and serializer for modern C++. + ### [Trompeloeil](https://github.com/rollbear/trompeloeil) A thread-safe header-only mocking framework for C++14. -### [args](https://github.com/Taywee/args) -A simple header-only C++ argument parser library. - ## Applications & Tools ### [ArangoDB](https://github.com/arangodb/arangodb) @@ -103,6 +106,9 @@ MAME originally stood for Multiple Arcade Machine Emulator. ### [Newsbeuter](https://github.com/akrennmair/newsbeuter) Newsbeuter is an open-source RSS/Atom feed reader for text terminals. +### [PopHead](https://github.com/SPC-Some-Polish-Coders/PopHead) +A 2D, Zombie, RPG game which is being made on our own engine. + ### [raspigcd](https://github.com/pantadeusz/raspigcd) Low level CLI app and library for execution of GCODE on Raspberry Pi without any additional microcontrolers (just RPi + Stepsticks). @@ -112,9 +118,6 @@ SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gr ### [Standardese](https://github.com/foonathan/standardese) Standardese aims to be a nextgen Doxygen. -### [PopHead](https://github.com/SPC-Some-Polish-Coders/PopHead) -A 2D, Zombie, RPG game which is being made on our own engine. - --- [Home](Readme.md#top) diff --git a/worker/deps/catch/docs/release-notes.md b/worker/deps/catch/docs/release-notes.md index b6975b64ca..1567314d9d 100644 --- a/worker/deps/catch/docs/release-notes.md +++ b/worker/deps/catch/docs/release-notes.md @@ -2,6 +2,8 @@ # Release notes **Contents**
+[2.12.1](#2121)
+[2.12.0](#2120)
[2.11.3](#2113)
[2.11.2](#2112)
[2.11.1](#2111)
@@ -34,6 +36,37 @@ [Older versions](#older-versions)
[Even Older versions](#even-older-versions)
+## 2.12.1 + +### Fixes +* Vector matchers now support initializer list literals better + +### Improvements +* Added support for `^` (bitwise xor) to `CHECK` and `REQUIRE` + + +## 2.12.0 + +### Improvements +* Running tests in random order (`--order rand`) has been reworked significantly (#1908) + * Given same seed, all platforms now produce the same order + * Given same seed, the relative order of tests does not change if you select only a subset of them +* Vector matchers support custom allocators (#1909) +* `|` and `&` (bitwise or and bitwise and) are now supported in `CHECK` and `REQUIRE` + * The resulting type must be convertible to `bool` + +### Fixes +* Fixed computation of benchmarking column widths in ConsoleReporter (#1885, #1886) +* Suppressed clang-tidy's `cppcoreguidelines-pro-type-vararg` in assertions (#1901) + * It was a false positive trigered by the new warning support workaround +* Fixed bug in test specification parser handling of OR'd patterns using escaping (#1905) + +### Miscellaneous +* Worked around IBM XL's codegen bug (#1907) + * It would emit code for _destructors_ of temporaries in an unevaluated context +* Improved detection of stdlib's support for `std::uncaught_exceptions` (#1911) + + ## 2.11.3 ### Fixes diff --git a/worker/deps/catch/include/catch.hpp b/worker/deps/catch/include/catch.hpp index d0404a86ff..b8b79b94b1 100644 --- a/worker/deps/catch/include/catch.hpp +++ b/worker/deps/catch/include/catch.hpp @@ -10,8 +10,8 @@ #define TWOBLUECUBES_CATCH_HPP_INCLUDED #define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 11 -#define CATCH_VERSION_PATCH 3 +#define CATCH_VERSION_MINOR 12 +#define CATCH_VERSION_PATCH 1 #ifdef __clang__ # pragma clang system_header diff --git a/worker/deps/catch/include/internal/catch_assertionhandler.cpp b/worker/deps/catch/include/internal/catch_assertionhandler.cpp index 77c3f1d474..fd14c85a2f 100644 --- a/worker/deps/catch/include/internal/catch_assertionhandler.cpp +++ b/worker/deps/catch/include/internal/catch_assertionhandler.cpp @@ -15,6 +15,7 @@ #include "catch_interfaces_registry_hub.h" #include "catch_capture_matchers.h" #include "catch_run_context.h" +#include "catch_enforce.h" namespace Catch { diff --git a/worker/deps/catch/include/internal/catch_compiler_capabilities.h b/worker/deps/catch/include/internal/catch_compiler_capabilities.h index 568e1ca0d7..26351c7acb 100644 --- a/worker/deps/catch/include/internal/catch_compiler_capabilities.h +++ b/worker/deps/catch/include/internal/catch_compiler_capabilities.h @@ -39,7 +39,7 @@ #endif -#if defined(CATCH_CPP17_OR_GREATER) +#if defined(__cpp_lib_uncaught_exceptions) # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS #endif @@ -58,7 +58,20 @@ # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug +// which results in calls to destructors being emitted for each temporary, +// without a matching initialization. In practice, this can result in something +// like `std::string::~string` being called on an uninitialized value. +// +// For example, this code will likely segfault under IBM XL: +// ``` +// REQUIRE(std::string("12") + "34" == "1234") +// ``` +// +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. +# if !defined(__ibmxl__) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */ +# endif # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ diff --git a/worker/deps/catch/include/internal/catch_debugger.cpp b/worker/deps/catch/include/internal/catch_debugger.cpp index fc78c36e9b..d4f7478010 100644 --- a/worker/deps/catch/include/internal/catch_debugger.cpp +++ b/worker/deps/catch/include/internal/catch_debugger.cpp @@ -14,8 +14,7 @@ #if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) -# include -# include +# include # include # include # include diff --git a/worker/deps/catch/include/internal/catch_decomposer.h b/worker/deps/catch/include/internal/catch_decomposer.h index 08075f0e9e..9320c4ddf8 100644 --- a/worker/deps/catch/include/internal/catch_decomposer.h +++ b/worker/deps/catch/include/internal/catch_decomposer.h @@ -200,6 +200,18 @@ namespace Catch { auto operator <= ( RhsT const& rhs ) -> BinaryExpr const { return { static_cast(m_lhs <= rhs), m_lhs, "<=", rhs }; } + template + auto operator | (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs | rhs), m_lhs, "|", rhs }; + } + template + auto operator & (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs & rhs), m_lhs, "&", rhs }; + } + template + auto operator ^ (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs ^ rhs), m_lhs, "^", rhs }; + } template auto operator && ( RhsT const& ) -> BinaryExpr const { diff --git a/worker/deps/catch/include/internal/catch_interfaces_exception.h b/worker/deps/catch/include/internal/catch_interfaces_exception.h index d3254d5f24..43840ea090 100644 --- a/worker/deps/catch/include/internal/catch_interfaces_exception.h +++ b/worker/deps/catch/include/internal/catch_interfaces_exception.h @@ -46,6 +46,9 @@ namespace Catch { {} std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return ""; +#else try { if( it == itEnd ) std::rethrow_exception(std::current_exception()); @@ -55,6 +58,7 @@ namespace Catch { catch( T& ex ) { return m_translateFunction( ex ); } +#endif } protected: diff --git a/worker/deps/catch/include/internal/catch_matchers_vector.h b/worker/deps/catch/include/internal/catch_matchers_vector.h index 2dc8a7150c..15a6ac9995 100644 --- a/worker/deps/catch/include/internal/catch_matchers_vector.h +++ b/worker/deps/catch/include/internal/catch_matchers_vector.h @@ -17,12 +17,12 @@ namespace Catch { namespace Matchers { namespace Vector { - template - struct ContainsElementMatcher : MatcherBase> { + template + struct ContainsElementMatcher : MatcherBase> { ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { for (auto const& el : v) { if (el == m_comparator) { return true; @@ -38,12 +38,12 @@ namespace Matchers { T const& m_comparator; }; - template - struct ContainsMatcher : MatcherBase> { + template + struct ContainsMatcher : MatcherBase> { - ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { // !TBD: see note in EqualsMatcher if (m_comparator.size() > v.size()) return false; @@ -65,18 +65,18 @@ namespace Matchers { return "Contains: " + ::Catch::Detail::stringify( m_comparator ); } - std::vector const& m_comparator; + std::vector const& m_comparator; }; - template - struct EqualsMatcher : MatcherBase> { + template + struct EqualsMatcher : MatcherBase> { - EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { // !TBD: This currently works if all elements can be compared using != // - a more general approach would be via a compare template that defaults - // to using !=. but could be specialised for, e.g. std::vector etc + // to using !=. but could be specialised for, e.g. std::vector etc // - then just call that directly if (m_comparator.size() != v.size()) return false; @@ -88,15 +88,15 @@ namespace Matchers { std::string describe() const override { return "Equals: " + ::Catch::Detail::stringify( m_comparator ); } - std::vector const& m_comparator; + std::vector const& m_comparator; }; - template - struct ApproxMatcher : MatcherBase> { + template + struct ApproxMatcher : MatcherBase> { - ApproxMatcher(std::vector const& comparator) : m_comparator( comparator ) {} + ApproxMatcher(std::vector const& comparator) : m_comparator( comparator ) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { if (m_comparator.size() != v.size()) return false; for (std::size_t i = 0; i < v.size(); ++i) @@ -123,14 +123,14 @@ namespace Matchers { return *this; } - std::vector const& m_comparator; + std::vector const& m_comparator; mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); }; - template - struct UnorderedEqualsMatcher : MatcherBase> { - UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} - bool match(std::vector const& vec) const override { + template + struct UnorderedEqualsMatcher : MatcherBase> { + UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} + bool match(std::vector const& vec) const override { // Note: This is a reimplementation of std::is_permutation, // because I don't want to include inside the common path if (m_target.size() != vec.size()) { @@ -143,7 +143,7 @@ namespace Matchers { return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); } private: - std::vector const& m_target; + std::vector const& m_target; }; } // namespace Vector @@ -151,29 +151,29 @@ namespace Matchers { // The following functions create the actual matcher objects. // This allows the types to be inferred - template - Vector::ContainsMatcher Contains( std::vector const& comparator ) { - return Vector::ContainsMatcher( comparator ); + template, typename AllocMatch = AllocComp> + Vector::ContainsMatcher Contains( std::vector const& comparator ) { + return Vector::ContainsMatcher( comparator ); } - template - Vector::ContainsElementMatcher VectorContains( T const& comparator ) { - return Vector::ContainsElementMatcher( comparator ); + template> + Vector::ContainsElementMatcher VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher( comparator ); } - template - Vector::EqualsMatcher Equals( std::vector const& comparator ) { - return Vector::EqualsMatcher( comparator ); + template, typename AllocMatch = AllocComp> + Vector::EqualsMatcher Equals( std::vector const& comparator ) { + return Vector::EqualsMatcher( comparator ); } - template - Vector::ApproxMatcher Approx( std::vector const& comparator ) { - return Vector::ApproxMatcher( comparator ); + template, typename AllocMatch = AllocComp> + Vector::ApproxMatcher Approx( std::vector const& comparator ) { + return Vector::ApproxMatcher( comparator ); } - template - Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { - return Vector::UnorderedEqualsMatcher(target); + template, typename AllocMatch = AllocComp> + Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { + return Vector::UnorderedEqualsMatcher( target ); } } // namespace Matchers diff --git a/worker/deps/catch/include/internal/catch_test_case_registry_impl.cpp b/worker/deps/catch/include/internal/catch_test_case_registry_impl.cpp index b254ca08e6..065f70bda6 100644 --- a/worker/deps/catch/include/internal/catch_test_case_registry_impl.cpp +++ b/worker/deps/catch/include/internal/catch_test_case_registry_impl.cpp @@ -15,27 +15,78 @@ #include "catch_string_manip.h" #include "catch_test_case_info.h" +#include #include namespace Catch { - std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { + namespace { + struct TestHasher { + explicit TestHasher(Catch::SimplePcg32& rng) { + basis = rng(); + basis <<= 32; + basis |= rng(); + } + + uint64_t basis; + + uint64_t operator()(TestCase const& t) const { + // Modified FNV-1a hash + static constexpr uint64_t prime = 1099511628211; + uint64_t hash = basis; + for (const char c : t.name) { + hash ^= c; + hash *= prime; + } + return hash; + } + }; + } // end unnamed namespace - std::vector sorted = unsortedTestCases; + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { switch( config.runOrder() ) { - case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end() ); - break; - case RunTests::InRandomOrder: - seedRng( config ); - std::shuffle( sorted.begin(), sorted.end(), rng() ); - break; case RunTests::InDeclarationOrder: // already in declaration order break; + + case RunTests::InLexicographicalOrder: { + std::vector sorted = unsortedTestCases; + std::sort( sorted.begin(), sorted.end() ); + return sorted; + } + + case RunTests::InRandomOrder: { + seedRng( config ); + TestHasher h( rng() ); + + using hashedTest = std::pair; + std::vector indexed_tests; + indexed_tests.reserve( unsortedTestCases.size() ); + + for (auto const& testCase : unsortedTestCases) { + indexed_tests.emplace_back(h(testCase), &testCase); + } + + std::sort(indexed_tests.begin(), indexed_tests.end(), + [](hashedTest const& lhs, hashedTest const& rhs) { + if (lhs.first == rhs.first) { + return lhs.second->name < rhs.second->name; + } + return lhs.first < rhs.first; + }); + + std::vector sorted; + sorted.reserve( indexed_tests.size() ); + + for (auto const& hashed : indexed_tests) { + sorted.emplace_back(*hashed.second); + } + + return sorted; + } } - return sorted; + return unsortedTestCases; } bool isThrowSafe( TestCase const& testCase, IConfig const& config ) { diff --git a/worker/deps/catch/include/internal/catch_test_spec_parser.cpp b/worker/deps/catch/include/internal/catch_test_spec_parser.cpp index dad15c01c9..40fcdcc395 100644 --- a/worker/deps/catch/include/internal/catch_test_spec_parser.cpp +++ b/worker/deps/catch/include/internal/catch_test_spec_parser.cpp @@ -168,6 +168,7 @@ namespace Catch { m_pos = m_arg.size(); m_substring.clear(); m_patternName.clear(); + m_realPatternPos = 0; return false; } endMode(); @@ -186,6 +187,7 @@ namespace Catch { } m_patternName.clear(); + m_realPatternPos = 0; return token; } diff --git a/worker/deps/catch/include/internal/catch_version.cpp b/worker/deps/catch/include/internal/catch_version.cpp index db6425e803..8f2daea7a1 100644 --- a/worker/deps/catch/include/internal/catch_version.cpp +++ b/worker/deps/catch/include/internal/catch_version.cpp @@ -37,7 +37,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 11, 3, "", 0 ); + static Version version( 2, 12, 1, "", 0 ); return version; } diff --git a/worker/deps/catch/include/reporters/catch_reporter_console.cpp b/worker/deps/catch/include/reporters/catch_reporter_console.cpp index 706f93f870..0fa399d586 100644 --- a/worker/deps/catch/include/reporters/catch_reporter_console.cpp +++ b/worker/deps/catch/include/reporters/catch_reporter_console.cpp @@ -362,7 +362,7 @@ ConsoleReporter::ConsoleReporter(ReporterConfig const& config) else { return{ - { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left }, + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left }, { "samples mean std dev", 14, ColumnInfo::Right }, { "iterations low mean low std dev", 14, ColumnInfo::Right }, { "estimated high mean high std dev", 14, ColumnInfo::Right } diff --git a/worker/deps/catch/projects/CMakeLists.txt b/worker/deps/catch/projects/CMakeLists.txt index 0aafc1780d..08badb809a 100644 --- a/worker/deps/catch/projects/CMakeLists.txt +++ b/worker/deps/catch/projects/CMakeLists.txt @@ -451,6 +451,8 @@ set_tests_properties(TestsInFile::InvalidTestNames-1 PROPERTIES PASS_REGULAR_EXP add_test(NAME TestsInFile::InvalidTestNames-2 COMMAND $ "-f ${CATCH_DIR}/projects/SelfTest/Misc/invalid-test-names.input") set_tests_properties(TestsInFile::InvalidTestNames-2 PROPERTIES PASS_REGULAR_EXPRESSION "No tests ran") +add_test(NAME RandomTestOrdering COMMAND ${PYTHON_EXECUTABLE} + ${CATCH_DIR}/projects/TestScripts/testRandomOrder.py $) if (CATCH_USE_VALGRIND) add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $) diff --git a/worker/deps/catch/projects/ExtraTests/CMakeLists.txt b/worker/deps/catch/projects/ExtraTests/CMakeLists.txt index 0e514d96fc..c8c975c00d 100644 --- a/worker/deps/catch/projects/ExtraTests/CMakeLists.txt +++ b/worker/deps/catch/projects/ExtraTests/CMakeLists.txt @@ -123,7 +123,7 @@ add_test(NAME BenchmarkingMacros COMMAND BenchmarkingMacros -r console -s) set_tests_properties( BenchmarkingMacros PROPERTIES - PASS_REGULAR_EXPRESSION "benchmark name samples iterations estimated" + PASS_REGULAR_EXPRESSION "benchmark name[\\r\\n\\t ]+samples[\\r\\n\\t ]+iterations[\\r\\n\\t ]+estimated" ) # This test touches windows.h, so it should only be compiled under msvc diff --git a/worker/deps/catch/projects/SelfTest/Baselines/compact.sw.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/compact.sw.approved.txt index eef23b5a97..3ac244ee9d 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -23,6 +23,13 @@ This would not be caught previously Nor would this Tricky.tests.cpp:: failed: explicitly with 1 message: '1514' Compilation.tests.cpp:: passed: std::is_same, TypeList>::value for: true +CmdLine.tests.cpp:: passed: spec.matches(fakeTestCase("spec . char")) for: true +CmdLine.tests.cpp:: passed: spec.matches(fakeTestCase("spec , char")) for: true +CmdLine.tests.cpp:: passed: !(spec.matches(fakeTestCase(R"(spec \, char)"))) for: !false +CmdLine.tests.cpp:: passed: spec.matches(fakeTestCase(R"(spec {a} char)")) for: true +CmdLine.tests.cpp:: passed: spec.matches(fakeTestCase(R"(spec [a] char)")) for: true +CmdLine.tests.cpp:: passed: !(spec.matches(fakeTestCase("differs but has similar tag", "[a]"))) for: !false +CmdLine.tests.cpp:: passed: spec.matches(fakeTestCase(R"(spec \ char)")) for: true Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42' with 1 message: 'expected exception' Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' Exception.tests.cpp:: passed: thisThrows() with 1 message: 'answer := 42' @@ -237,6 +244,11 @@ Matchers.tests.cpp:: passed: 1, Predicate(alwaysTrue, "always Matchers.tests.cpp:: passed: 1, !Predicate(alwaysFalse, "always false") for: 1 not matches predicate: "always false" Matchers.tests.cpp:: passed: "Hello olleH", Predicate( [] (std::string const& str) -> bool { return str.front() == str.back(); }, "First and last character should be equal") for: "Hello olleH" matches predicate: "First and last character should be equal" Matchers.tests.cpp:: passed: "This wouldn't pass", !Predicate( [] (std::string const& str) -> bool { return str.front() == str.back(); } ) for: "This wouldn't pass" not matches undescribed predicate +Compilation.tests.cpp:: passed: lhs | rhs for: Val: 1 | Val: 2 +Compilation.tests.cpp:: passed: !(lhs & rhs) for: !(Val: 1 & Val: 2) +Compilation.tests.cpp:: passed: HasBitOperators{ 1 } & HasBitOperators{ 1 } for: Val: 1 & Val: 1 +Compilation.tests.cpp:: passed: lhs ^ rhs for: Val: 1 ^ Val: 2 +Compilation.tests.cpp:: passed: !(lhs ^ lhs) for: !(Val: 1 ^ Val: 1) Tricky.tests.cpp:: passed: true Tricky.tests.cpp:: passed: true Tricky.tests.cpp:: passed: true @@ -1519,6 +1531,7 @@ Approx.tests.cpp:: passed: approx( d ) != 1.25 for: Approx( 1.23 ) VariadicMacros.tests.cpp:: passed: with 1 message: 'no assertions' Matchers.tests.cpp:: passed: empty, Approx(empty) for: { } is approx: { } Matchers.tests.cpp:: passed: v1, Approx(v1) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } +Matchers.tests.cpp:: passed: v1, Approx({ 1., 2., 3. }) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } Matchers.tests.cpp:: passed: v1, !Approx(temp) for: { 1.0, 2.0, 3.0 } not is approx: { 1.0, 2.0, 3.0, 4.0 } Matchers.tests.cpp:: passed: v1, !Approx(v2) for: { 1.0, 2.0, 3.0 } not is approx: { 1.5, 2.5, 3.5 } Matchers.tests.cpp:: passed: v1, Approx(v2).margin(0.5) for: { 1.0, 2.0, 3.0 } is approx: { 1.5, 2.5, 3.5 } @@ -1528,18 +1541,29 @@ Matchers.tests.cpp:: failed: empty, Approx(t1) for: { } is approx: Matchers.tests.cpp:: failed: v1, Approx(v2) for: { 2.0, 4.0, 6.0 } is approx: { 1.0, 3.0, 5.0 } Matchers.tests.cpp:: passed: v, VectorContains(1) for: { 1, 2, 3 } Contains: 1 Matchers.tests.cpp:: passed: v, VectorContains(2) for: { 1, 2, 3 } Contains: 2 +Matchers.tests.cpp:: passed: v5, (VectorContains>(2)) for: { 1, 2, 3 } Contains: 2 Matchers.tests.cpp:: passed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2 } +Matchers.tests.cpp:: passed: v, Contains({ 1, 2 }) for: { 1, 2, 3 } Contains: { 1, 2 } +Matchers.tests.cpp:: passed: v5, (Contains, CustomAllocator>(v2)) for: { 1, 2, 3 } Contains: { 1, 2 } Matchers.tests.cpp:: passed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2, 3 } Matchers.tests.cpp:: passed: v, Contains(empty) for: { 1, 2, 3 } Contains: { } Matchers.tests.cpp:: passed: empty, Contains(empty) for: { } Contains: { } +Matchers.tests.cpp:: passed: v5, (Contains, CustomAllocator>(v2)) for: { 1, 2, 3 } Contains: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v5, Contains(v6) for: { 1, 2, 3 } Contains: { 1, 2 } Matchers.tests.cpp:: passed: v, VectorContains(1) && VectorContains(2) for: { 1, 2, 3 } ( Contains: 1 and Contains: 2 ) Matchers.tests.cpp:: passed: v, Equals(v) for: { 1, 2, 3 } Equals: { 1, 2, 3 } Matchers.tests.cpp:: passed: empty, Equals(empty) for: { } Equals: { } +Matchers.tests.cpp:: passed: v, Equals({ 1, 2, 3 }) for: { 1, 2, 3 } Equals: { 1, 2, 3 } Matchers.tests.cpp:: passed: v, Equals(v2) for: { 1, 2, 3 } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v5, (Equals, CustomAllocator>(v2)) for: { 1, 2, 3 } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v5, Equals(v6) for: { 1, 2, 3 } Equals: { 1, 2, 3 } Matchers.tests.cpp:: passed: v, UnorderedEquals(v) for: { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v, UnorderedEquals({ 3, 2, 1 }) for: { 1, 2, 3 } UnorderedEquals: { 3, 2, 1 } Matchers.tests.cpp:: passed: empty, UnorderedEquals(empty) for: { } UnorderedEquals: { } Matchers.tests.cpp:: passed: permuted, UnorderedEquals(v) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } Matchers.tests.cpp:: passed: permuted, UnorderedEquals(v) for: { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v5, (UnorderedEquals, CustomAllocator>(permuted)) for: { 1, 2, 3 } UnorderedEquals: { 2, 3, 1 } +Matchers.tests.cpp:: passed: v5_permuted, UnorderedEquals(v5) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } Matchers.tests.cpp:: failed: v, VectorContains(-1) for: { 1, 2, 3 } Contains: -1 Matchers.tests.cpp:: failed: empty, VectorContains(1) for: { } Contains: 1 Matchers.tests.cpp:: failed: empty, Contains(v) for: { } Contains: { 1, 2, 3 } diff --git a/worker/deps/catch/projects/SelfTest/Baselines/console.std.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/console.std.approved.txt index c0357adb4d..1cb3970e50 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/console.std.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/console.std.approved.txt @@ -1380,6 +1380,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 307 | 233 passed | 70 failed | 4 failed as expected -assertions: 1677 | 1525 passed | 131 failed | 21 failed as expected +test cases: 310 | 236 passed | 70 failed | 4 failed as expected +assertions: 1701 | 1549 passed | 131 failed | 21 failed as expected diff --git a/worker/deps/catch/projects/SelfTest/Baselines/console.sw.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/console.sw.approved.txt index 1b0a8ce212..9ac146f938 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/console.sw.approved.txt @@ -188,6 +188,61 @@ Compilation.tests.cpp:: PASSED: with expansion: true +------------------------------------------------------------------------------- +#1905 -- test spec parser properly clears internal state between compound tests +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase("spec . char")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase("spec , char")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE_FALSE( spec.matches(fakeTestCase(R"(spec \, char)")) ) +with expansion: + !false + +------------------------------------------------------------------------------- +#1912 -- test spec parser handles escaping + Various parentheses +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase(R"(spec {a} char)")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase(R"(spec [a] char)")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE_FALSE( spec.matches(fakeTestCase("differs but has similar tag", "[a]")) ) +with expansion: + !false + +------------------------------------------------------------------------------- +#1912 -- test spec parser handles escaping + backslash in test name +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase(R"(spec \ char)")) ) +with expansion: + true + ------------------------------------------------------------------------------- #748 - captures with unexpected exceptions outside assertions @@ -1879,6 +1934,37 @@ Matchers.tests.cpp:: PASSED: with expansion: "This wouldn't pass" not matches undescribed predicate +------------------------------------------------------------------------------- +Assertion macros support bit operators and bool conversions +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: PASSED: + REQUIRE( lhs | rhs ) +with expansion: + Val: 1 | Val: 2 + +Compilation.tests.cpp:: PASSED: + REQUIRE_FALSE( lhs & rhs ) +with expansion: + !(Val: 1 & Val: 2) + +Compilation.tests.cpp:: PASSED: + REQUIRE( HasBitOperators{ 1 } & HasBitOperators{ 1 } ) +with expansion: + Val: 1 & Val: 1 + +Compilation.tests.cpp:: PASSED: + REQUIRE( lhs ^ rhs ) +with expansion: + Val: 1 ^ Val: 2 + +Compilation.tests.cpp:: PASSED: + REQUIRE_FALSE( lhs ^ lhs ) +with expansion: + !(Val: 1 ^ Val: 1) + ------------------------------------------------------------------------------- Assertions then sections ------------------------------------------------------------------------------- @@ -11101,6 +11187,11 @@ Matchers.tests.cpp:: PASSED: with expansion: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } +Matchers.tests.cpp:: PASSED: + REQUIRE_THAT( v1, Approx({ 1., 2., 3. }) ) +with expansion: + { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } + ------------------------------------------------------------------------------- Vector Approx matcher Vectors with elements @@ -11183,6 +11274,11 @@ Matchers.tests.cpp:: PASSED: with expansion: { 1, 2, 3 } Contains: 2 +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, (VectorContains>(2)) ) +with expansion: + { 1, 2, 3 } Contains: 2 + ------------------------------------------------------------------------------- Vector matchers Contains (vector) @@ -11195,6 +11291,16 @@ Matchers.tests.cpp:: PASSED: with expansion: { 1, 2, 3 } Contains: { 1, 2 } +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v, Contains({ 1, 2 }) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2 } + +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, (Contains, CustomAllocator>(v2)) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2 } + Matchers.tests.cpp:: PASSED: CHECK_THAT( v, Contains(v2) ) with expansion: @@ -11210,6 +11316,16 @@ Matchers.tests.cpp:: PASSED: with expansion: { } Contains: { } +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, (Contains, CustomAllocator>(v2)) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2, 3 } + +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, Contains(v6) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2 } + ------------------------------------------------------------------------------- Vector matchers Contains (element), composed @@ -11239,11 +11355,26 @@ Matchers.tests.cpp:: PASSED: with expansion: { } Equals: { } +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v, Equals({ 1, 2, 3 }) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2, 3 } + Matchers.tests.cpp:: PASSED: CHECK_THAT( v, Equals(v2) ) with expansion: { 1, 2, 3 } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, (Equals, CustomAllocator>(v2)) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2, 3 } + +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, Equals(v6) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2, 3 } + ------------------------------------------------------------------------------- Vector matchers UnorderedEquals @@ -11256,6 +11387,11 @@ Matchers.tests.cpp:: PASSED: with expansion: { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v, UnorderedEquals({ 3, 2, 1 }) ) +with expansion: + { 1, 2, 3 } UnorderedEquals: { 3, 2, 1 } + Matchers.tests.cpp:: PASSED: CHECK_THAT( empty, UnorderedEquals(empty) ) with expansion: @@ -11271,6 +11407,16 @@ Matchers.tests.cpp:: PASSED: with expansion: { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5, (UnorderedEquals, CustomAllocator>(permuted)) ) +with expansion: + { 1, 2, 3 } UnorderedEquals: { 2, 3, 1 } + +Matchers.tests.cpp:: PASSED: + CHECK_THAT( v5_permuted, UnorderedEquals(v5) ) +with expansion: + { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } + ------------------------------------------------------------------------------- Vector matchers that fail Contains (element) @@ -13427,6 +13573,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 307 | 217 passed | 86 failed | 4 failed as expected -assertions: 1694 | 1525 passed | 148 failed | 21 failed as expected +test cases: 310 | 220 passed | 86 failed | 4 failed as expected +assertions: 1718 | 1549 passed | 148 failed | 21 failed as expected diff --git a/worker/deps/catch/projects/SelfTest/Baselines/console.swa4.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/console.swa4.approved.txt index 322b815864..4a5b486482 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -188,6 +188,61 @@ Compilation.tests.cpp:: PASSED: with expansion: true +------------------------------------------------------------------------------- +#1905 -- test spec parser properly clears internal state between compound tests +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase("spec . char")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase("spec , char")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE_FALSE( spec.matches(fakeTestCase(R"(spec \, char)")) ) +with expansion: + !false + +------------------------------------------------------------------------------- +#1912 -- test spec parser handles escaping + Various parentheses +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase(R"(spec {a} char)")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase(R"(spec [a] char)")) ) +with expansion: + true + +CmdLine.tests.cpp:: PASSED: + REQUIRE_FALSE( spec.matches(fakeTestCase("differs but has similar tag", "[a]")) ) +with expansion: + !false + +------------------------------------------------------------------------------- +#1912 -- test spec parser handles escaping + backslash in test name +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: PASSED: + REQUIRE( spec.matches(fakeTestCase(R"(spec \ char)")) ) +with expansion: + true + ------------------------------------------------------------------------------- #748 - captures with unexpected exceptions outside assertions @@ -368,6 +423,6 @@ Condition.tests.cpp:: FAILED: CHECK( true != true ) =============================================================================== -test cases: 19 | 14 passed | 3 failed | 2 failed as expected -assertions: 42 | 35 passed | 4 failed | 3 failed as expected +test cases: 21 | 16 passed | 3 failed | 2 failed as expected +assertions: 49 | 42 passed | 4 failed | 3 failed as expected diff --git a/worker/deps/catch/projects/SelfTest/Baselines/junit.sw.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/junit.sw.approved.txt index e8f7c09ff4..603e4d0b52 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -30,6 +30,9 @@ Nor would this + + + FAILED: @@ -337,6 +340,7 @@ Exception.tests.cpp: + diff --git a/worker/deps/catch/projects/SelfTest/Baselines/sonarqube.sw.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/sonarqube.sw.approved.txt index 2f11cf5bba..663f6fb945 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -2,6 +2,9 @@ + + + @@ -369,6 +372,7 @@ Class.tests.cpp: + diff --git a/worker/deps/catch/projects/SelfTest/Baselines/xml.sw.approved.txt b/worker/deps/catch/projects/SelfTest/Baselines/xml.sw.approved.txt index cc90e0cb29..ddbdb595b7 100644 --- a/worker/deps/catch/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/worker/deps/catch/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -196,6 +196,74 @@ Nor would this + + + + spec.matches(fakeTestCase("spec . char")) + + + true + + + + + spec.matches(fakeTestCase("spec , char")) + + + true + + + + + !(spec.matches(fakeTestCase(R"(spec \, char)"))) + + + !false + + + + + +
+ + + spec.matches(fakeTestCase(R"(spec {a} char)")) + + + true + + + + + spec.matches(fakeTestCase(R"(spec [a] char)")) + + + true + + + + + !(spec.matches(fakeTestCase("differs but has similar tag", "[a]"))) + + + !false + + + +
+
+ + + spec.matches(fakeTestCase(R"(spec \ char)")) + + + true + + + +
+ +
@@ -2109,6 +2177,49 @@ Nor would this
+ + + + lhs | rhs + + + Val: 1 | Val: 2 + + + + + !(lhs & rhs) + + + !(Val: 1 & Val: 2) + + + + + HasBitOperators{ 1 } & HasBitOperators{ 1 } + + + Val: 1 & Val: 1 + + + + + lhs ^ rhs + + + Val: 1 ^ Val: 2 + + + + + !(lhs ^ lhs) + + + !(Val: 1 ^ Val: 1) + + + + @@ -13529,9 +13640,17 @@ There is no extra whitespace here { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } - + + + v1, Approx<double>({ 1., 2., 3. }) + + + { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } + + + - +
@@ -13630,7 +13749,15 @@ There is no extra whitespace here { 1, 2, 3 } Contains: 2 - + + + v5, (VectorContains<int, CustomAllocator<int>>(2)) + + + { 1, 2, 3 } Contains: 2 + + +
@@ -13641,6 +13768,22 @@ There is no extra whitespace here { 1, 2, 3 } Contains: { 1, 2 } + + + v, Contains<int>({ 1, 2 }) + + + { 1, 2, 3 } Contains: { 1, 2 } + + + + + v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) + + + { 1, 2, 3 } Contains: { 1, 2 } + + v, Contains(v2) @@ -13665,7 +13808,23 @@ There is no extra whitespace here { } Contains: { } - + + + v5, (Contains<int, std::allocator<int>, CustomAllocator<int>>(v2)) + + + { 1, 2, 3 } Contains: { 1, 2, 3 } + + + + + v5, Contains(v6) + + + { 1, 2, 3 } Contains: { 1, 2 } + + +
@@ -13695,6 +13854,14 @@ There is no extra whitespace here { } Equals: { } + + + v, Equals<int>({ 1, 2, 3 }) + + + { 1, 2, 3 } Equals: { 1, 2, 3 } + + v, Equals(v2) @@ -13703,7 +13870,23 @@ There is no extra whitespace here { 1, 2, 3 } Equals: { 1, 2, 3 } - + + + v5, (Equals<int, std::allocator<int>, CustomAllocator<int>>(v2)) + + + { 1, 2, 3 } Equals: { 1, 2, 3 } + + + + + v5, Equals(v6) + + + { 1, 2, 3 } Equals: { 1, 2, 3 } + + +
@@ -13714,6 +13897,14 @@ There is no extra whitespace here { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 } + + + v, UnorderedEquals<int>({ 3, 2, 1 }) + + + { 1, 2, 3 } UnorderedEquals: { 3, 2, 1 } + + empty, UnorderedEquals(empty) @@ -13738,7 +13929,23 @@ There is no extra whitespace here { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 } - + + + v5, (UnorderedEquals<int, std::allocator<int>, CustomAllocator<int>>(permuted)) + + + { 1, 2, 3 } UnorderedEquals: { 2, 3, 1 } + + + + + v5_permuted, UnorderedEquals(v5) + + + { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } + + +
@@ -16048,7 +16255,7 @@ loose text artifact
- + - + diff --git a/worker/deps/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/worker/deps/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index 6e590326fe..488957178e 100644 --- a/worker/deps/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/worker/deps/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -292,6 +292,35 @@ TEST_CASE( "Parse test names and tags", "[command-line][test-spec]" ) { } } +TEST_CASE("#1905 -- test spec parser properly clears internal state between compound tests", "[command-line][test-spec]") { + using Catch::parseTestSpec; + using Catch::TestSpec; + // We ask for one of 2 different tests and the latter one of them has a , in name that needs escaping + TestSpec spec = parseTestSpec(R"("spec . char","spec \, char")"); + + REQUIRE(spec.matches(fakeTestCase("spec . char"))); + REQUIRE(spec.matches(fakeTestCase("spec , char"))); + REQUIRE_FALSE(spec.matches(fakeTestCase(R"(spec \, char)"))); +} + +TEST_CASE("#1912 -- test spec parser handles escaping", "[command-line][test-spec]") { + using Catch::parseTestSpec; + using Catch::TestSpec; + + SECTION("Various parentheses") { + TestSpec spec = parseTestSpec(R"(spec {a} char,spec \[a] char)"); + + REQUIRE(spec.matches(fakeTestCase(R"(spec {a} char)"))); + REQUIRE(spec.matches(fakeTestCase(R"(spec [a] char)"))); + REQUIRE_FALSE(spec.matches(fakeTestCase("differs but has similar tag", "[a]"))); + } + SECTION("backslash in test name") { + TestSpec spec = parseTestSpec(R"(spec \\ char)"); + + REQUIRE(spec.matches(fakeTestCase(R"(spec \ char)"))); + } +} + TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) { #ifndef CATCH_CONFIG_DISABLE_MATCHERS diff --git a/worker/deps/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp b/worker/deps/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp index 0baf2842ba..850d5f9b1a 100644 --- a/worker/deps/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp +++ b/worker/deps/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp @@ -234,3 +234,36 @@ namespace { namespace CompilationTests { }} // namespace CompilationTests +namespace { + struct HasBitOperators { + int value; + + friend HasBitOperators operator| (HasBitOperators lhs, HasBitOperators rhs) { + return { lhs.value | rhs.value }; + } + friend HasBitOperators operator& (HasBitOperators lhs, HasBitOperators rhs) { + return { lhs.value & rhs.value }; + } + friend HasBitOperators operator^ (HasBitOperators lhs, HasBitOperators rhs) { + return { lhs.value ^ rhs.value }; + } + explicit operator bool() const { + return !!value; + } + + friend std::ostream& operator<<(std::ostream& out, HasBitOperators val) { + out << "Val: " << val.value; + return out; + } + }; +} + +TEST_CASE("Assertion macros support bit operators and bool conversions", "[compilation][bitops]") { + HasBitOperators lhs{ 1 }, rhs{ 2 }; + REQUIRE(lhs | rhs); + REQUIRE_FALSE(lhs & rhs); + REQUIRE(HasBitOperators{ 1 } & HasBitOperators{ 1 }); + REQUIRE(lhs ^ rhs); + REQUIRE_FALSE(lhs ^ lhs); +} + diff --git a/worker/deps/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp b/worker/deps/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp index 52f2912d74..c4a8ebf9d0 100644 --- a/worker/deps/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp +++ b/worker/deps/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp @@ -214,6 +214,42 @@ namespace { namespace MatchersTests { CHECK_THAT(testStringForMatching(), !Contains("substring")); } + template + struct CustomAllocator : private std::allocator + { + using size_type = size_t; + using difference_type = ptrdiff_t; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; + using value_type = T; + + template + struct rebind + { using other = CustomAllocator; }; + + using propagate_on_container_move_assignment = std::true_type; + using is_always_equal = std::true_type; + + CustomAllocator() = default; + + CustomAllocator(const CustomAllocator& other) + : std::allocator(other) { } + + template + CustomAllocator(const CustomAllocator&) { } + + ~CustomAllocator() = default; + + using std::allocator::address; + using std::allocator::allocate; + using std::allocator::construct; + using std::allocator::deallocate; + using std::allocator::max_size; + using std::allocator::destroy; + }; + TEST_CASE("Vector matchers", "[matchers][vector]") { std::vector v; v.push_back(1); @@ -234,19 +270,35 @@ namespace { namespace MatchersTests { v4.push_back(2 + 1e-8); v4.push_back(3 + 1e-8); + std::vector> v5; + v5.push_back(1); + v5.push_back(2); + v5.push_back(3); + + std::vector> v6; + v6.push_back(1); + v6.push_back(2); + std::vector empty; SECTION("Contains (element)") { CHECK_THAT(v, VectorContains(1)); CHECK_THAT(v, VectorContains(2)); + CHECK_THAT(v5, (VectorContains>(2))); } SECTION("Contains (vector)") { CHECK_THAT(v, Contains(v2)); + CHECK_THAT(v, Contains({ 1, 2 })); + CHECK_THAT(v5, (Contains, CustomAllocator>(v2))); + v2.push_back(3); // now exactly matches CHECK_THAT(v, Contains(v2)); CHECK_THAT(v, Contains(empty)); CHECK_THAT(empty, Contains(empty)); + + CHECK_THAT(v5, (Contains, CustomAllocator>(v2))); + CHECK_THAT(v5, Contains(v6)); } SECTION("Contains (element), composed") { CHECK_THAT(v, VectorContains(1) && VectorContains(2)); @@ -256,15 +308,21 @@ namespace { namespace MatchersTests { // Same vector CHECK_THAT(v, Equals(v)); - CHECK_THAT(empty, Equals(empty)); // Different vector with same elements + CHECK_THAT(v, Equals({ 1, 2, 3 })); v2.push_back(3); CHECK_THAT(v, Equals(v2)); + + CHECK_THAT(v5, (Equals, CustomAllocator>(v2))); + + v6.push_back(3); + CHECK_THAT(v5, Equals(v6)); } SECTION("UnorderedEquals") { CHECK_THAT(v, UnorderedEquals(v)); + CHECK_THAT(v, UnorderedEquals({ 3, 2, 1 })); CHECK_THAT(empty, UnorderedEquals(empty)); auto permuted = v; @@ -273,6 +331,12 @@ namespace { namespace MatchersTests { std::reverse(begin(permuted), end(permuted)); REQUIRE_THAT(permuted, UnorderedEquals(v)); + + CHECK_THAT(v5, (UnorderedEquals, CustomAllocator>(permuted))); + + auto v5_permuted = v5; + std::next_permutation(begin(v5_permuted), end(v5_permuted)); + CHECK_THAT(v5_permuted, UnorderedEquals(v5)); } } @@ -518,6 +582,7 @@ namespace { namespace MatchersTests { std::vector v1({1., 2., 3.}); SECTION("A vector is approx equal to itself") { REQUIRE_THAT(v1, Approx(v1)); + REQUIRE_THAT(v1, Approx({ 1., 2., 3. })); } std::vector v2({1.5, 2.5, 3.5}); SECTION("Different length") { @@ -552,7 +617,7 @@ namespace { namespace MatchersTests { REQUIRE_THROWS_MATCHES(throwsSpecialException(2), SpecialException, !Message("DerivedException::what")); REQUIRE_THROWS_MATCHES(throwsSpecialException(2), SpecialException, Message("SpecialException::what")); } - + TEST_CASE("Composed matchers are distinct", "[matchers][composed]") { auto m1 = Contains("string"); auto m2 = Contains("random"); diff --git a/worker/deps/catch/projects/TestScripts/testRandomOrder.py b/worker/deps/catch/projects/TestScripts/testRandomOrder.py new file mode 100755 index 0000000000..a6ffb996d7 --- /dev/null +++ b/worker/deps/catch/projects/TestScripts/testRandomOrder.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 + +""" +This test script verifies that the random ordering of tests inside +Catch2 is invariant in regards to subsetting. This is done by running +the binary 3 times, once with all tests selected, and twice with smaller +subsets of tests selected, and verifying that the selected tests are in +the same relative order. +""" + +import subprocess +import sys +import random + +def list_tests(self_test_exe, tags, rng_seed): + cmd = [self_test_exe, '--list-test-names-only', '--order', 'rand', + '--rng-seed', str(rng_seed)] + tags_arg = ','.join('[{}]'.format(t) for t in tags) + if tags_arg: + cmd.append(tags_arg + '~[.]') + process = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = process.communicate() + if stderr: + raise RuntimeError("Unexpected error output:\n" + process.stderr) + result = stdout.split(b'\n') + result = [s for s in result if s] + if len(result) < 2: + raise RuntimeError("Unexpectedly few tests listed (got {})".format( + len(result))) + return result + +def check_is_sublist_of(shorter, longer): + assert len(shorter) < len(longer) + assert len(set(longer)) == len(longer) + + indexes_in_longer = {s: i for i, s in enumerate(longer)} + for s1, s2 in zip(shorter, shorter[1:]): + assert indexes_in_longer[s1] < indexes_in_longer[s2], ( + '{} comes before {} in longer list.\n' + 'Longer: {}\nShorter: {}'.format(s2, s1, longer, shorter)) + +def main(): + self_test_exe, = sys.argv[1:] + + # We want a random seed for the test, but want to avoid 0, + # because it has special meaning + seed = random.randint(1, 2 ** 32 - 1) + + list_one_tag = list_tests(self_test_exe, ['generators'], seed) + list_two_tags = list_tests(self_test_exe, ['generators', 'matchers'], seed) + list_all = list_tests(self_test_exe, [], seed) + + # First, verify that restricting to a subset yields the same order + check_is_sublist_of(list_two_tags, list_all) + check_is_sublist_of(list_one_tag, list_two_tags) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/worker/deps/catch/single_include/catch2/catch.hpp b/worker/deps/catch/single_include/catch2/catch.hpp index 51618b38e9..6beb0eadb3 100644 --- a/worker/deps/catch/single_include/catch2/catch.hpp +++ b/worker/deps/catch/single_include/catch2/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v2.11.3 - * Generated: 2020-03-19 13:44:21.042491 + * Catch v2.12.1 + * Generated: 2020-04-21 19:29:20.964532 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. @@ -14,8 +14,8 @@ #define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 11 -#define CATCH_VERSION_PATCH 3 +#define CATCH_VERSION_MINOR 12 +#define CATCH_VERSION_PATCH 1 #ifdef __clang__ # pragma clang system_header @@ -132,7 +132,7 @@ namespace Catch { #endif -#if defined(CATCH_CPP17_OR_GREATER) +#if defined(__cpp_lib_uncaught_exceptions) # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS #endif @@ -151,7 +151,20 @@ namespace Catch { # define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) # define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug +// which results in calls to destructors being emitted for each temporary, +// without a matching initialization. In practice, this can result in something +// like `std::string::~string` being called on an uninitialized value. +// +// For example, this code will likely segfault under IBM XL: +// ``` +// REQUIRE(std::string("12") + "34" == "1234") +// ``` +// +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. +# if !defined(__ibmxl__) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */ +# endif # define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ @@ -2356,6 +2369,18 @@ namespace Catch { auto operator <= ( RhsT const& rhs ) -> BinaryExpr const { return { static_cast(m_lhs <= rhs), m_lhs, "<=", rhs }; } + template + auto operator | (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs | rhs), m_lhs, "|", rhs }; + } + template + auto operator & (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs & rhs), m_lhs, "&", rhs }; + } + template + auto operator ^ (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs ^ rhs), m_lhs, "^", rhs }; + } template auto operator && ( RhsT const& ) -> BinaryExpr const { @@ -3000,6 +3025,9 @@ namespace Catch { {} std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return ""; +#else try { if( it == itEnd ) std::rethrow_exception(std::current_exception()); @@ -3009,6 +3037,7 @@ namespace Catch { catch( T& ex ) { return m_translateFunction( ex ); } +#endif } protected: @@ -3571,12 +3600,12 @@ namespace Catch { namespace Matchers { namespace Vector { - template - struct ContainsElementMatcher : MatcherBase> { + template + struct ContainsElementMatcher : MatcherBase> { ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { for (auto const& el : v) { if (el == m_comparator) { return true; @@ -3592,12 +3621,12 @@ namespace Matchers { T const& m_comparator; }; - template - struct ContainsMatcher : MatcherBase> { + template + struct ContainsMatcher : MatcherBase> { - ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { // !TBD: see note in EqualsMatcher if (m_comparator.size() > v.size()) return false; @@ -3619,18 +3648,18 @@ namespace Matchers { return "Contains: " + ::Catch::Detail::stringify( m_comparator ); } - std::vector const& m_comparator; + std::vector const& m_comparator; }; - template - struct EqualsMatcher : MatcherBase> { + template + struct EqualsMatcher : MatcherBase> { - EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { // !TBD: This currently works if all elements can be compared using != // - a more general approach would be via a compare template that defaults - // to using !=. but could be specialised for, e.g. std::vector etc + // to using !=. but could be specialised for, e.g. std::vector etc // - then just call that directly if (m_comparator.size() != v.size()) return false; @@ -3642,15 +3671,15 @@ namespace Matchers { std::string describe() const override { return "Equals: " + ::Catch::Detail::stringify( m_comparator ); } - std::vector const& m_comparator; + std::vector const& m_comparator; }; - template - struct ApproxMatcher : MatcherBase> { + template + struct ApproxMatcher : MatcherBase> { - ApproxMatcher(std::vector const& comparator) : m_comparator( comparator ) {} + ApproxMatcher(std::vector const& comparator) : m_comparator( comparator ) {} - bool match(std::vector const &v) const override { + bool match(std::vector const &v) const override { if (m_comparator.size() != v.size()) return false; for (std::size_t i = 0; i < v.size(); ++i) @@ -3677,14 +3706,14 @@ namespace Matchers { return *this; } - std::vector const& m_comparator; + std::vector const& m_comparator; mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); }; - template - struct UnorderedEqualsMatcher : MatcherBase> { - UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} - bool match(std::vector const& vec) const override { + template + struct UnorderedEqualsMatcher : MatcherBase> { + UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} + bool match(std::vector const& vec) const override { // Note: This is a reimplementation of std::is_permutation, // because I don't want to include inside the common path if (m_target.size() != vec.size()) { @@ -3697,7 +3726,7 @@ namespace Matchers { return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); } private: - std::vector const& m_target; + std::vector const& m_target; }; } // namespace Vector @@ -3705,29 +3734,29 @@ namespace Matchers { // The following functions create the actual matcher objects. // This allows the types to be inferred - template - Vector::ContainsMatcher Contains( std::vector const& comparator ) { - return Vector::ContainsMatcher( comparator ); + template, typename AllocMatch = AllocComp> + Vector::ContainsMatcher Contains( std::vector const& comparator ) { + return Vector::ContainsMatcher( comparator ); } - template - Vector::ContainsElementMatcher VectorContains( T const& comparator ) { - return Vector::ContainsElementMatcher( comparator ); + template> + Vector::ContainsElementMatcher VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher( comparator ); } - template - Vector::EqualsMatcher Equals( std::vector const& comparator ) { - return Vector::EqualsMatcher( comparator ); + template, typename AllocMatch = AllocComp> + Vector::EqualsMatcher Equals( std::vector const& comparator ) { + return Vector::EqualsMatcher( comparator ); } - template - Vector::ApproxMatcher Approx( std::vector const& comparator ) { - return Vector::ApproxMatcher( comparator ); + template, typename AllocMatch = AllocComp> + Vector::ApproxMatcher Approx( std::vector const& comparator ) { + return Vector::ApproxMatcher( comparator ); } - template - Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { - return Vector::UnorderedEqualsMatcher(target); + template, typename AllocMatch = AllocComp> + Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { + return Vector::UnorderedEqualsMatcher( target ); } } // namespace Matchers @@ -10319,8 +10348,7 @@ namespace Catch { #if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) -# include -# include +# include # include # include # include @@ -13977,27 +14005,77 @@ namespace Catch { // end catch_test_case_info.cpp // start catch_test_case_registry_impl.cpp +#include #include namespace Catch { - std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { + namespace { + struct TestHasher { + explicit TestHasher(Catch::SimplePcg32& rng) { + basis = rng(); + basis <<= 32; + basis |= rng(); + } + + uint64_t basis; - std::vector sorted = unsortedTestCases; + uint64_t operator()(TestCase const& t) const { + // Modified FNV-1a hash + static constexpr uint64_t prime = 1099511628211; + uint64_t hash = basis; + for (const char c : t.name) { + hash ^= c; + hash *= prime; + } + return hash; + } + }; + } // end unnamed namespace + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { switch( config.runOrder() ) { - case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end() ); - break; - case RunTests::InRandomOrder: - seedRng( config ); - std::shuffle( sorted.begin(), sorted.end(), rng() ); - break; case RunTests::InDeclarationOrder: // already in declaration order break; + + case RunTests::InLexicographicalOrder: { + std::vector sorted = unsortedTestCases; + std::sort( sorted.begin(), sorted.end() ); + return sorted; + } + + case RunTests::InRandomOrder: { + seedRng( config ); + TestHasher h( rng() ); + + using hashedTest = std::pair; + std::vector indexed_tests; + indexed_tests.reserve( unsortedTestCases.size() ); + + for (auto const& testCase : unsortedTestCases) { + indexed_tests.emplace_back(h(testCase), &testCase); + } + + std::sort(indexed_tests.begin(), indexed_tests.end(), + [](hashedTest const& lhs, hashedTest const& rhs) { + if (lhs.first == rhs.first) { + return lhs.second->name < rhs.second->name; + } + return lhs.first < rhs.first; + }); + + std::vector sorted; + sorted.reserve( indexed_tests.size() ); + + for (auto const& hashed : indexed_tests) { + sorted.emplace_back(*hashed.second); + } + + return sorted; + } } - return sorted; + return unsortedTestCases; } bool isThrowSafe( TestCase const& testCase, IConfig const& config ) { @@ -14591,6 +14669,7 @@ namespace Catch { m_pos = m_arg.size(); m_substring.clear(); m_patternName.clear(); + m_realPatternPos = 0; return false; } endMode(); @@ -14609,6 +14688,7 @@ namespace Catch { } m_patternName.clear(); + m_realPatternPos = 0; return token; } @@ -15079,7 +15159,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 11, 3, "", 0 ); + static Version version( 2, 12, 1, "", 0 ); return version; } @@ -16142,7 +16222,7 @@ ConsoleReporter::ConsoleReporter(ReporterConfig const& config) else { return{ - { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left }, + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left }, { "samples mean std dev", 14, ColumnInfo::Right }, { "iterations low mean low std dev", 14, ColumnInfo::Right }, { "estimated high mean high std dev", 14, ColumnInfo::Right } diff --git a/worker/scripts/get-dep.sh b/worker/scripts/get-dep.sh index 566e5a46ed..ddde846932 100755 --- a/worker/scripts/get-dep.sh +++ b/worker/scripts/get-dep.sh @@ -126,7 +126,7 @@ function get_abseil_cpp() function get_catch() { GIT_REPO="https://github.com/catchorg/Catch2.git" - GIT_TAG="v2.11.3" + GIT_TAG="v2.12.1" DEST="deps/catch" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"