Compare commits

..

8 Commits

Author SHA1 Message Date
Martin Hořeňovský
c4e3767e26 v2.13.7 2021-07-28 20:30:51 +02:00
Martin Hořeňovský
eea3e9a5b5 Mark !mayfail tests as skipped in the JUnit reporter
Should fix #2116
2021-07-27 23:16:01 +02:00
Martin Hořeňovský
7727c15290 Remove Conan builds from travis-CI 2021-06-07 20:02:30 +02:00
Dimitrij Mijoski
531a149ae7 Fix compiling v2.x with C++17 + Clang 5 + libstdc++ v5
This basically tests the combination where the compiler supports most
of C++17 but the library does not.
2021-05-25 23:50:45 +02:00
Martin Hořeňovský
9683570be7 Tiny optimization in JUnit reporter 2021-05-23 11:31:33 +02:00
Martin Hořeňovský
581c46249a JUnit reporter uses only 3 decimal places when reporting durations
We used to use whatever precision we ended up having from C++'s
stdlib. However, some relatively popular tools, like Jenkins,
use Maven SureFire XML schema to validate JUnit test reports, and
Maven SureFire schema requires the duration to have at most 3
decimal places.

For compatibility, the JUnit reporter will now respect this
limitation.

Closes #2221
2021-05-22 23:45:43 +02:00
Evgeny Proydakov
b15b862d86 Fixed noexcept benchmark build for gcc. 2021-05-21 20:49:16 +02:00
Martin Hořeňovský
6971476563 Ensure that <iterator> is included before back_inserter is used
Closes #2231
2021-05-21 20:20:00 +02:00
22 changed files with 316 additions and 72 deletions

View File

@@ -258,6 +258,15 @@ matrix:
addons: *gcc7
env: COMPILER='g++-7' EXAMPLES=1 COVERAGE=1 EXTRAS=1 CPP17=1
- os: linux
dist: xenial
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-5.0']
env: COMPILER='clang++-5.0' CPP17=1
- os: linux
dist: xenial
compiler: clang
@@ -276,19 +285,6 @@ matrix:
packages: ['clang-6.0', 'libstdc++-8-dev']
env: COMPILER='clang++-6.0' CPP17=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
# 8/ Conan
- language: python
python:
- "3.7"
dist: xenial
install:
- pip install conan-package-tools
env:
- CONAN_GCC_VERSIONS=8
- CONAN_DOCKER_IMAGE=conanio/gcc8
script:
- python .conan/build.py
install:
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}

View File

@@ -16,7 +16,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
project(Catch2 LANGUAGES CXX VERSION 2.13.6)
project(Catch2 LANGUAGES CXX VERSION 2.13.7)
# Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")

View File

@@ -9,7 +9,7 @@
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.13.6/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
<a href="https://github.com/catchorg/Catch2/releases/download/v2.13.7/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released!

View File

@@ -2,6 +2,7 @@
# Release notes
**Contents**<br>
[2.13.7](#2137)<br>
[2.13.6](#2136)<br>
[2.13.5](#2135)<br>
[2.13.4](#2134)<br>
@@ -47,6 +48,16 @@
[Even Older versions](#even-older-versions)<br>
## 2.13.7
### Fixes
* Added missing `<iterator>` include in benchmarking. (#2231)
* Fixed noexcept build with benchmarking enabled (#2235)
* Fixed build for compilers with C++17 support but without C++17 library support (#2195)
* JUnit only uses 3 decimal places when reporting durations (#2221)
* `!mayfail` tagged tests are now marked as `skipped` in JUnit reporter output (#2116)
## 2.13.6
### Fixes

View File

@@ -11,7 +11,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 6
#define CATCH_VERSION_PATCH 7
#ifdef __clang__
# pragma clang system_header

View File

@@ -19,6 +19,7 @@
#include "detail/catch_run_for_at_least.hpp"
#include <algorithm>
#include <iterator>
namespace Catch {
namespace Benchmark {

View File

@@ -56,7 +56,7 @@ namespace Catch {
}
iters *= 2;
}
throw optimized_away_error{};
Catch::throw_exception(optimized_away_error{});
}
} // namespace Detail
} // namespace Benchmark

View File

@@ -234,7 +234,7 @@
// Check if byte is available and usable
# if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
# include <cstddef>
# if __cpp_lib_byte > 0
# if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0)
# define CATCH_INTERNAL_CONFIG_CPP17_BYTE
# endif
# endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)

View File

@@ -21,6 +21,8 @@
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
#include "benchmark/catch_estimate.hpp"
#include "benchmark/catch_outlier_classification.hpp"
#include <iterator>
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING

View File

@@ -37,7 +37,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 6, "", 0 );
static Version version( 2, 13, 7, "", 0 );
return version;
}

View File

@@ -18,6 +18,7 @@
#include <sstream>
#include <ctime>
#include <algorithm>
#include <iomanip>
namespace Catch {
@@ -45,7 +46,7 @@ namespace Catch {
#else
std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
#endif
return std::string(timeStamp);
return std::string(timeStamp, timeStampSize-1);
}
std::string fileNameTag(const std::vector<std::string> &tags) {
@@ -56,6 +57,17 @@ namespace Catch {
return it->substr(1);
return std::string();
}
// Formats the duration in seconds to 3 decimal places.
// This is done because some genius defined Maven Surefire schema
// in a way that only accepts 3 decimal places, and tools like
// Jenkins use that schema for validation JUnit reporter output.
std::string formatDuration( double seconds ) {
ReusableStringStream rss;
rss << std::fixed << std::setprecision( 3 ) << seconds;
return rss.str();
}
} // anonymous namespace
JunitReporter::JunitReporter( ReporterConfig const& _config )
@@ -125,7 +137,7 @@ namespace Catch {
if( m_config->showDurations() == ShowDurations::Never )
xml.writeAttribute( "time", "" );
else
xml.writeAttribute( "time", suiteTime );
xml.writeAttribute( "time", formatDuration( suiteTime ) );
xml.writeAttribute( "timestamp", getCurrentTimestamp() );
// Write properties if there are any
@@ -170,12 +182,13 @@ namespace Catch {
if ( !m_config->name().empty() )
className = m_config->name() + "." + className;
writeSection( className, "", rootSection );
writeSection( className, "", rootSection, stats.testInfo.okToFail() );
}
void JunitReporter::writeSection( std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode ) {
void JunitReporter::writeSection( std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode,
bool testOkToFail) {
std::string name = trim( sectionNode.stats.sectionInfo.name );
if( !rootName.empty() )
name = rootName + '/' + name;
@@ -192,15 +205,21 @@ namespace Catch {
xml.writeAttribute( "classname", className );
xml.writeAttribute( "name", name );
}
xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) );
xml.writeAttribute( "time", formatDuration( sectionNode.stats.durationInSeconds ) );
// This is not ideal, but it should be enough to mimic gtest's
// junit output.
// Ideally the JUnit reporter would also handle `skipTest`
// events and write those out appropriately.
xml.writeAttribute( "status", "run" );
if (sectionNode.stats.assertions.failedButOk) {
xml.scopedElement("skipped")
.writeAttribute("message", "TEST_CASE tagged with !mayfail");
}
writeAssertions( sectionNode );
if( !sectionNode.stdOut.empty() )
xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), XmlFormatting::Newline );
if( !sectionNode.stdErr.empty() )
@@ -208,9 +227,9 @@ namespace Catch {
}
for( auto const& childNode : sectionNode.childSections )
if( className.empty() )
writeSection( name, "", *childNode );
writeSection( name, "", *childNode, testOkToFail );
else
writeSection( className, name, *childNode );
writeSection( className, name, *childNode, testOkToFail );
}
void JunitReporter::writeAssertions( SectionNode const& sectionNode ) {

View File

@@ -41,9 +41,10 @@ namespace Catch {
void writeTestCase(TestCaseNode const& testCaseNode);
void writeSection(std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode);
void writeSection( std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode,
bool testOkToFail );
void writeAssertions(SectionNode const& sectionNode);
void writeAssertion(AssertionStats const& stats);

View File

@@ -846,6 +846,10 @@ Matchers.tests.cpp:<line number>: passed: testStringForMatching(), (Contains("st
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random") for: "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" )
Matchers.tests.cpp:<line number>: passed: testStringForMatching(), !Contains("different") for: "this string contains 'abc' as a substring" not contains: "different"
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), !Contains("substring") for: "this string contains 'abc' as a substring" not contains: "substring"
Condition.tests.cpp:<line number>: failed: explicitly
Condition.tests.cpp:<line number>: failed: explicitly
Condition.tests.cpp:<line number>: failed: explicitly
Condition.tests.cpp:<line number>: failed: explicitly
Exception.tests.cpp:<line number>: passed: thisThrows(), "expected exception" for: "expected exception" equals: "expected exception"
Exception.tests.cpp:<line number>: failed: thisThrows(), "should fail" for: "expected exception" equals: "should fail"
Generators.tests.cpp:<line number>: passed: values > -6 for: 3 > -6

View File

@@ -694,6 +694,46 @@ Matchers.tests.cpp:<line number>: FAILED:
with expansion:
"this string contains 'abc' as a substring" not contains: "substring"
-------------------------------------------------------------------------------
Mayfail test case with nested sections
A
1
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mayfail test case with nested sections
A
2
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mayfail test case with nested sections
B
1
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mayfail test case with nested sections
B
2
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mismatching exception messages failing the test
-------------------------------------------------------------------------------
@@ -1380,6 +1420,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
test cases: 322 | 248 passed | 70 failed | 4 failed as expected
assertions: 1759 | 1607 passed | 131 failed | 21 failed as expected
test cases: 323 | 248 passed | 70 failed | 5 failed as expected
assertions: 1763 | 1607 passed | 131 failed | 25 failed as expected

View File

@@ -6492,6 +6492,46 @@ Matchers.tests.cpp:<line number>: FAILED:
with expansion:
"this string contains 'abc' as a substring" not contains: "substring"
-------------------------------------------------------------------------------
Mayfail test case with nested sections
A
1
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mayfail test case with nested sections
A
2
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mayfail test case with nested sections
B
1
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mayfail test case with nested sections
B
2
-------------------------------------------------------------------------------
Condition.tests.cpp:<line number>
...............................................................................
Condition.tests.cpp:<line number>: FAILED:
-------------------------------------------------------------------------------
Mismatching exception messages failing the test
-------------------------------------------------------------------------------
@@ -14138,6 +14178,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 322 | 232 passed | 86 failed | 4 failed as expected
assertions: 1776 | 1607 passed | 148 failed | 21 failed as expected
test cases: 323 | 232 passed | 86 failed | 5 failed as expected
assertions: 1780 | 1607 passed | 148 failed | 25 failed as expected

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="132" tests="1777" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="132" tests="1781" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/>
@@ -48,6 +48,7 @@ Nor would this
<testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<error type="TEST_CASE">
FAILED:
expected exception
@@ -56,6 +57,7 @@ Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/inside REQUIRE_NOTHROW" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<error message="thisThrows()" type="REQUIRE_NOTHROW">
FAILED:
REQUIRE_NOTHROW( thisThrows() )
@@ -68,6 +70,7 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="#809" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#833" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#835 -- errno should not be touched by Catch" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure message="f() == 0" type="CHECK">
FAILED:
CHECK( f() == 0 )
@@ -443,6 +446,7 @@ Matchers.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Enums in namespaces can quickly have stringification enabled using REGISTER_ENUM" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Epsilon only applies to Approx's value" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Equality checks that should fail" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure message="data.int_seven == 6" type="CHECK">
FAILED:
CHECK( data.int_seven == 6 )
@@ -736,6 +740,7 @@ Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Inequality checks that should fail" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure message="data.int_seven != 7" type="CHECK">
FAILED:
CHECK( data.int_seven != 7 )
@@ -799,6 +804,34 @@ with expansion:
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mayfail test case with nested sections/1/A" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure type="FAIL">
FAILED:
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mayfail test case with nested sections/2/A" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure type="FAIL">
FAILED:
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mayfail test case with nested sections/1/B" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure type="FAIL">
FAILED:
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mayfail test case with nested sections/2/B" time="{duration}" status="run">
<skipped message="TEST_CASE tagged with !mayfail"/>
<failure type="FAIL">
FAILED:
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mismatching exception messages failing the test" time="{duration}" status="run">
<failure message="thisThrows(), &quot;should fail&quot;" type="REQUIRE_THROWS_WITH">
FAILED:

View File

@@ -575,6 +575,30 @@ Condition.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="Inequality checks that should succeed" duration="{duration}"/>
<testCase name="Mayfail test case with nested sections/1/A" duration="{duration}">
<skipped message="FAIL()">
FAILED:
Condition.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="Mayfail test case with nested sections/2/A" duration="{duration}">
<skipped message="FAIL()">
FAILED:
Condition.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="Mayfail test case with nested sections/1/B" duration="{duration}">
<skipped message="FAIL()">
FAILED:
Condition.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="Mayfail test case with nested sections/2/B" duration="{duration}">
<skipped message="FAIL()">
FAILED:
Condition.tests.cpp:<line number>
</skipped>
</testCase>
<testCase name="Ordering comparison checks that should fail" duration="{duration}">
<failure message="CHECK(data.int_seven > 7)">
FAILED:

View File

@@ -7956,6 +7956,43 @@ Nor would this
</Expression>
<OverallResult success="false"/>
</TestCase>
<TestCase name="Mayfail test case with nested sections" tags="[!mayfail]" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Section name="A" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Section name="1" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Failure filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" />
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<Section name="A" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Section name="2" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Failure filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" />
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<Section name="A" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<OverallResults successes="0" failures="0" expectedFailures="0"/>
</Section>
<Section name="B" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Section name="1" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Failure filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" />
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<Section name="B" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Section name="2" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<Failure filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" />
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<Section name="B" filename="projects/<exe-name>/UsageTests/Condition.tests.cpp" >
<OverallResults successes="0" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Mismatching exception messages failing the test" tags="[!hide][!throws][.][failing]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<Original>
@@ -16722,9 +16759,9 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="1607" failures="149" expectedFailures="21"/>
<OverallResultsCases successes="232" failures="86" expectedFailures="4"/>
<OverallResults successes="1607" failures="149" expectedFailures="25"/>
<OverallResultsCases successes="232" failures="86" expectedFailures="5"/>
</Group>
<OverallResults successes="1607" failures="148" expectedFailures="21"/>
<OverallResultsCases successes="232" failures="86" expectedFailures="4"/>
<OverallResults successes="1607" failures="148" expectedFailures="25"/>
<OverallResultsCases successes="232" failures="86" expectedFailures="5"/>
</Catch>

View File

@@ -11,7 +11,7 @@
// Wdouble-promotion is not supported until 3.8
# if (__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ > 7)
# pragma clang diagnostic ignored "-Wdouble-promotion"
# endif
# endif
#endif
#include "catch.hpp"
@@ -89,6 +89,19 @@ TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" )
CHECK( x == Approx( 1.301 ) );
}
// Needed to test junit reporter's handling of mayfail test cases and sections
TEST_CASE("Mayfail test case with nested sections", "[!mayfail]") {
SECTION("A") {
SECTION("1") { FAIL(); }
SECTION("2") { FAIL(); }
}
SECTION("B") {
SECTION("1") { FAIL(); }
SECTION("2") { FAIL(); }
}
}
TEST_CASE( "Inequality checks that should succeed" )
{
TestData data;

View File

@@ -58,12 +58,12 @@ TEST_CASE("tables", "[generators]") {
// Structured bindings make the table utility much nicer to use
TEST_CASE( "strlen2", "[approvals][generators]" ) {
auto [test_input, expected] = GENERATE( table<std::string, size_t>({
{"one", 3},
{"two", 3},
{"three", 5},
{"four", 4}
}));
using tuple_type = std::tuple<std::string, int>; // see above workaround
auto [test_input, expected] =
GENERATE( table<std::string, size_t>( { tuple_type{ "one", 3 },
tuple_type{ "two", 3 },
tuple_type{ "three", 5 },
tuple_type{ "four", 4 } } ) );
REQUIRE( test_input.size() == expected );
}
@@ -99,11 +99,9 @@ TEST_CASE( "strlen3", "[generators]" ) {
static auto eatCucumbers( int start, int eat ) -> int { return start-eat; }
SCENARIO("Eating cucumbers", "[generators][approvals]") {
auto [start, eat, left] = GENERATE( table<int,int,int> ({
{ 12, 5, 7 },
{ 20, 5, 15 }
}));
using tuple_type = std::tuple<int, int, int>;
auto [start, eat, left] = GENERATE( table<int, int, int>(
{ tuple_type{ 12, 5, 7 }, tuple_type{ 20, 5, 15 } } ) );
GIVEN( "there are " << start << " cucumbers" )
WHEN( "I eat " << eat << " cucumbers" )

View File

@@ -28,7 +28,10 @@ filelocParser = re.compile(r'''
''', re.VERBOSE)
lineNumberParser = re.compile(r' line="[0-9]*"')
hexParser = re.compile(r'\b(0[xX][0-9a-fA-F]+)\b')
durationsParser = re.compile(r' time="[0-9]*\.[0-9]*"')
# Note: junit must serialize time with 3 (or or less) decimal places
# before generalizing this parser, make sure that this is checked
# in other places too.
junitDurationsParser = re.compile(r' time="[0-9]*\.[0-9]{3}"')
sonarqubeDurationParser = re.compile(r' duration="[0-9]+"')
timestampsParser = re.compile(r'\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z')
versionParser = re.compile(r'Catch v[0-9]+\.[0-9]+\.[0-9]+(-develop\.[0-9]+)?')
@@ -138,7 +141,7 @@ def filterLine(line, isCompact):
line = hexParser.sub("0x<hex digits>", line)
# strip durations and timestamps
line = durationsParser.sub(' time="{duration}"', line)
line = junitDurationsParser.sub(' time="{duration}"', line)
line = sonarqubeDurationParser.sub(' duration="{duration}"', line)
line = timestampsParser.sub('{iso8601-timestamp}', line)
line = specialCaseParser.sub('file:\g<1>', line)

View File

@@ -1,6 +1,6 @@
/*
* Catch v2.13.6
* Generated: 2021-04-16 18:23:38.044268
* Catch v2.13.7
* Generated: 2021-07-28 20:29:27.753164
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2021 Two Blue Cubes Ltd. All rights reserved.
@@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 6
#define CATCH_VERSION_PATCH 7
#ifdef __clang__
# pragma clang system_header
@@ -326,7 +326,7 @@ namespace Catch {
// Check if byte is available and usable
# if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
# include <cstddef>
# if __cpp_lib_byte > 0
# if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0)
# define CATCH_INTERNAL_CONFIG_CPP17_BYTE
# endif
# endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
@@ -5458,6 +5458,8 @@ namespace Catch {
} // namespace Catch
// end catch_outlier_classification.hpp
#include <iterator>
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING
#include <string>
@@ -6342,9 +6344,10 @@ namespace Catch {
void writeTestCase(TestCaseNode const& testCaseNode);
void writeSection(std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode);
void writeSection( std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode,
bool testOkToFail );
void writeAssertions(SectionNode const& sectionNode);
void writeAssertion(AssertionStats const& stats);
@@ -6879,7 +6882,7 @@ namespace Catch {
}
iters *= 2;
}
throw optimized_away_error{};
Catch::throw_exception(optimized_away_error{});
}
} // namespace Detail
} // namespace Benchmark
@@ -6887,6 +6890,7 @@ namespace Catch {
// end catch_run_for_at_least.hpp
#include <algorithm>
#include <iterator>
namespace Catch {
namespace Benchmark {
@@ -15376,7 +15380,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 6, "", 0 );
static Version version( 2, 13, 7, "", 0 );
return version;
}
@@ -16789,6 +16793,7 @@ CATCH_REGISTER_REPORTER("console", ConsoleReporter)
#include <sstream>
#include <ctime>
#include <algorithm>
#include <iomanip>
namespace Catch {
@@ -16816,7 +16821,7 @@ namespace Catch {
#else
std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
#endif
return std::string(timeStamp);
return std::string(timeStamp, timeStampSize-1);
}
std::string fileNameTag(const std::vector<std::string> &tags) {
@@ -16827,6 +16832,17 @@ namespace Catch {
return it->substr(1);
return std::string();
}
// Formats the duration in seconds to 3 decimal places.
// This is done because some genius defined Maven Surefire schema
// in a way that only accepts 3 decimal places, and tools like
// Jenkins use that schema for validation JUnit reporter output.
std::string formatDuration( double seconds ) {
ReusableStringStream rss;
rss << std::fixed << std::setprecision( 3 ) << seconds;
return rss.str();
}
} // anonymous namespace
JunitReporter::JunitReporter( ReporterConfig const& _config )
@@ -16896,7 +16912,7 @@ namespace Catch {
if( m_config->showDurations() == ShowDurations::Never )
xml.writeAttribute( "time", "" );
else
xml.writeAttribute( "time", suiteTime );
xml.writeAttribute( "time", formatDuration( suiteTime ) );
xml.writeAttribute( "timestamp", getCurrentTimestamp() );
// Write properties if there are any
@@ -16941,12 +16957,13 @@ namespace Catch {
if ( !m_config->name().empty() )
className = m_config->name() + "." + className;
writeSection( className, "", rootSection );
writeSection( className, "", rootSection, stats.testInfo.okToFail() );
}
void JunitReporter::writeSection( std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode ) {
void JunitReporter::writeSection( std::string const& className,
std::string const& rootName,
SectionNode const& sectionNode,
bool testOkToFail) {
std::string name = trim( sectionNode.stats.sectionInfo.name );
if( !rootName.empty() )
name = rootName + '/' + name;
@@ -16963,13 +16980,18 @@ namespace Catch {
xml.writeAttribute( "classname", className );
xml.writeAttribute( "name", name );
}
xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) );
xml.writeAttribute( "time", formatDuration( sectionNode.stats.durationInSeconds ) );
// This is not ideal, but it should be enough to mimic gtest's
// junit output.
// Ideally the JUnit reporter would also handle `skipTest`
// events and write those out appropriately.
xml.writeAttribute( "status", "run" );
if (sectionNode.stats.assertions.failedButOk) {
xml.scopedElement("skipped")
.writeAttribute("message", "TEST_CASE tagged with !mayfail");
}
writeAssertions( sectionNode );
if( !sectionNode.stdOut.empty() )
@@ -16979,9 +17001,9 @@ namespace Catch {
}
for( auto const& childNode : sectionNode.childSections )
if( className.empty() )
writeSection( name, "", *childNode );
writeSection( name, "", *childNode, testOkToFail );
else
writeSection( className, name, *childNode );
writeSection( className, name, *childNode, testOkToFail );
}
void JunitReporter::writeAssertions( SectionNode const& sectionNode ) {