Compare commits

..

17 Commits

Author SHA1 Message Date
Martin Hořeňovský
7f21cc6c55 v2.13.0 2020-07-12 20:28:38 +02:00
Martin Hořeňovský
4c85248179 Fixup whitespace in TAPReporter 2020-07-12 20:27:25 +02:00
Martin Hořeňovský
b4e2237152 Remove pointless CompactReporter::getPreferences override 2020-07-12 20:06:14 +02:00
Martin Hořeňovský
40937b67c7 Merge pull request #1983 from s7726/patch-1
Update catch_reporter_tap.hpp
2020-07-12 20:00:03 +02:00
Martin Hořeňovský
0d5b131394 Improve documentation for --min-duration 2020-07-12 16:27:55 +02:00
Martin Hořeňovský
ad3b90553b Document GENERATE's new usage between SECTIONs 2020-07-12 16:24:32 +02:00
Gavin S
b1c45652e5 Update catch_reporter_tap.hpp
TAP format requires all results to be reported.
Removed extraneous preferences function (handled by parent)
Incorporated fix from 3d9e7db2e0
Simplified total printing
2020-07-12 01:17:37 -07:00
Martin Hořeňovský
b79a83e4aa Modify generator tracking to allow GENERATEs between SECTIONs
This means that code such as

```cpp
TEST_CASE() {
    SECTION("first") { SUCCEED(); }
    auto _ = GENERATE(1, 2);
    SECTION("second") { SUCCEED(); }
}
```

will run and report 3 assertions, 1 from section "first" and 2
from section "second". This also applies for greater and potentially
more confusing nesting, but fundamentally it is up to the user to
avoid overly complex and confusing nestings, just as with `SECTION`s.

The old behaviour of `GENERATE` as first thing in a `TEST_CASE`,
`GENERATE` not followed by a `SECTION`, etc etc should be unchanged.

Closes #1938
2020-07-11 23:16:07 +02:00
Martin Hořeňovský
89fe35d515 Fix how testRandomOrder.py builds tag arguments 2020-07-11 21:32:10 +02:00
Martin Hořeňovský
115d6a1c40 Increase tolerances in --min-duration tests
The underpowered and oversubscribed CI servers are hell.
2020-07-07 11:36:56 +02:00
Martin Hořeňovský
91576352f9 Fixup single_include to be consistent with last tag
Closes #1975
2020-07-07 11:32:05 +02:00
Martin Hořeňovský
6f7c191513 --min-duration is overriden by -d no 2020-07-06 20:33:08 +02:00
Martin Hořeňovský
4eb9d37e05 Refactor tests for duration reporting threshold 2020-07-06 20:02:20 +02:00
John Bytheway
53d8af8e96 Test for --min-duration 2020-07-06 11:35:02 +02:00
John Bytheway
46fde0c597 Add --min-duration option
A test runner already has a --durations option to print durations.
However, this isn't entirely satisfactory.

When there are many tests, this produces output spam which makes it hard
to find the test failure output.  Nevertheless, it is helpful to be
informed of tests which are unusually slow.

Therefore, introduce a new option --min-duration that causes all
durations above a certain threshold to be printed.  This allows slow
tests to be visible without mentioning every test.
2020-07-06 11:35:02 +02:00
Martin Hořeňovský
de103db696 Merge pull request #1973 from echuber2/patch-1
Escaping "*" ("times") to fix Markdown presentation
2020-07-06 11:34:22 +02:00
Eric Huber
fedc3a7b7b Escaping literal "*" ("times") to fix markdown 2020-07-05 17:04:00 -05:00
35 changed files with 1584 additions and 94 deletions

View File

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

View File

@@ -5,11 +5,11 @@
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) [![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) [![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) [![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/wRuqI3INY7fTagL7) [![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/aavJBzemrxUgGV9S)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) [![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.12.4/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.0/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released! ## Catch2 is released!

View File

@@ -222,6 +222,16 @@ available warnings
When set to ```yes``` Catch will report the duration of each test case, in milliseconds. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not. When set to ```yes``` Catch will report the duration of each test case, in milliseconds. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not.
<pre>-D, --min-duration &lt;value></pre>
> `--min-duration` was [introduced](https://github.com/catchorg/Catch2/pull/1910) in Catch 2.13.0
When set, Catch will report the duration of each test case that took more
than &lt;value> seconds, in milliseconds. This option is overriden by both
`-d yes` and `-d no`, so that either all durations are reported, or none
are.
<a id="input-file"></a> <a id="input-file"></a>
## Load test names to run from a file ## Load test names to run from a file
<pre>-f, --input-file &lt;filename></pre> <pre>-f, --input-file &lt;filename></pre>

View File

@@ -11,6 +11,38 @@ are run once per each value in a generator.
This is best explained with an example: This is best explained with an example:
```cpp ```cpp
TEST_CASE("Generators") {
auto i = GENERATE(1, 3, 5);
REQUIRE(is_odd(i));
}
```
The "Generators" `TEST_CASE` will be entered 3 times, and the value of
`i` will be 1, 3, and 5 in turn. `GENERATE`s can also be used multiple
times at the same scope, in which case the result will be a cartesian
product of all elements in the generators. This means that in the snippet
below, the test case will be run 6 (2\*3) times.
```cpp
TEST_CASE("Generators") {
auto i = GENERATE(1, 2);
auto j = GENERATE(3, 4, 5);
}
```
There are 2 parts to generators in Catch2, the `GENERATE` macro together
with the already provided generators, and the `IGenerator<T>` interface
that allows users to implement their own generators.
## Combining `GENERATE` and `SECTION`.
`GENERATE` can be seen as an implicit `SECTION`, that goes from the place
`GENERATE` is used, to the end of the scope. This can be used for various
effects. The simplest usage is shown below, where the `SECTION` "one"
runs 4 (2\*2) times, and `SECTION` "two" is run 6 times (2\*3).
```
TEST_CASE("Generators") { TEST_CASE("Generators") {
auto i = GENERATE(1, 2); auto i = GENERATE(1, 2);
SECTION("one") { SECTION("one") {
@@ -24,29 +56,43 @@ TEST_CASE("Generators") {
} }
``` ```
The `SECTION` "one" will be run 4 (2*2) times, because the outer The specific order of the `SECTION`s will be "one", "one", "two", "two",
generator has 2 elements in it, and the inner generator also has 2 "two", "one"...
elements in it. The `SECTION` "two" will be run 6 (2*3) times. The
sections will be run in order "one", "one", "two", "two", "two", "one",
...
It is also possible to have multiple generators at the same level of
nesting. The result is the same as when generators are inside nested The fact that `GENERATE` introduces a virtual `SECTION` can als obe used
sections, that is, the result will be a cartesian product of all to make a generator replay only some `SECTION`s, without having to
elements. This means that in the snippet below, the test case will be explicitly add a `SECTION`. As an example, the code below reports 3
run 6 (2*3) times. assertions, because the "first" section is run once, but the "second"
section is run twice.
```cpp ```cpp
TEST_CASE("Generators") { TEST_CASE("GENERATE between SECTIONs") {
auto i = GENERATE(1, 2); SECTION("first") { REQUIRE(true); }
auto j = GENERATE(3, 4, 5); auto _ = GENERATE(1, 2);
SECTION("second") { REQUIRE(true); }
} }
``` ```
This can lead to surprisingly complex test flows. As an example, the test
below will report 14 assertions:
There are 2 parts to generators in Catch2, the `GENERATE` macro together ```cpp
with the already provided generators, and the `IGenerator<T>` interface TEST_CASE("Complex mix of sections and generates") {
that allows users to implement their own generators. auto i = GENERATE(1, 2);
SECTION("A") {
SUCCEED("A");
}
auto j = GENERATE(3, 4);
SECTION("B") {
SUCCEED("B");
}
auto k = GENERATE(5, 6);
SUCCEED();
}
```
> The ability to place `GENERATE` between two `SECTION`s was [introduced](https://github.com/catchorg/Catch2/issues/1938) in Catch 2.13.0.
## Provided generators ## Provided generators

View File

@@ -2,6 +2,7 @@
# Release notes # Release notes
**Contents**<br> **Contents**<br>
[2.13.0](#2130)<br>
[2.12.4](#2124)<br> [2.12.4](#2124)<br>
[2.12.3](#2123)<br> [2.12.3](#2123)<br>
[2.12.2](#2122)<br> [2.12.2](#2122)<br>
@@ -39,6 +40,18 @@
[Older versions](#older-versions)<br> [Older versions](#older-versions)<br>
[Even Older versions](#even-older-versions)<br> [Even Older versions](#even-older-versions)<br>
## 2.13.0
### Improvements
* `GENERATE` can now follow a `SECTION` at the same level of nesting (#1938)
* The `SECTION`(s) before the `GENERATE` will not be run multiple times, the following ones will.
* Added `-D`/`--min-duration` command line flag (#1910)
* If a test takes longer to finish than the provided value, its name and duration will be printed.
* This flag is overriden by setting `-d`/`--duration`.
### Fixes
* `TAPReporter` no longer skips successful assertions (#1983)
## 2.12.4 ## 2.12.4

View File

@@ -10,8 +10,8 @@
#define TWOBLUECUBES_CATCH_HPP_INCLUDED #define TWOBLUECUBES_CATCH_HPP_INCLUDED
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 4 #define CATCH_VERSION_PATCH 0
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header

View File

@@ -170,6 +170,9 @@ namespace Catch {
| Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" )
["-d"]["--durations"] ["-d"]["--durations"]
( "show test durations" ) ( "show test durations" )
| Opt( config.minDuration, "seconds" )
["-D"]["--min-duration"]
( "show test durations for tests taking at least the given number of seconds" )
| Opt( loadTestNamesFromFile, "filename" ) | Opt( loadTestNamesFromFile, "filename" )
["-f"]["--input-file"] ["-f"]["--input-file"]
( "load test names to run from a file" ) ( "load test names to run from a file" )

View File

@@ -64,6 +64,7 @@ namespace Catch {
bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); }
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }
double Config::minDuration() const { return m_data.minDuration; }
RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; }
unsigned int Config::rngSeed() const { return m_data.rngSeed; } unsigned int Config::rngSeed() const { return m_data.rngSeed; }
UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } UseColour::YesOrNo Config::useColour() const { return m_data.useColour; }

View File

@@ -52,6 +52,7 @@ namespace Catch {
Verbosity verbosity = Verbosity::Normal; Verbosity verbosity = Verbosity::Normal;
WarnAbout::What warnings = WarnAbout::Nothing; WarnAbout::What warnings = WarnAbout::Nothing;
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
double minDuration = -1;
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
UseColour::YesOrNo useColour = UseColour::Auto; UseColour::YesOrNo useColour = UseColour::Auto;
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
@@ -103,6 +104,7 @@ namespace Catch {
bool warnAboutMissingAssertions() const override; bool warnAboutMissingAssertions() const override;
bool warnAboutNoTests() const override; bool warnAboutNoTests() const override;
ShowDurations::OrNot showDurations() const override; ShowDurations::OrNot showDurations() const override;
double minDuration() const override;
RunTests::InWhatOrder runOrder() const override; RunTests::InWhatOrder runOrder() const override;
unsigned int rngSeed() const override; unsigned int rngSeed() const override;
UseColour::YesOrNo useColour() const override; UseColour::YesOrNo useColour() const override;

View File

@@ -69,6 +69,7 @@ namespace Catch {
virtual int abortAfter() const = 0; virtual int abortAfter() const = 0;
virtual bool showInvisibles() const = 0; virtual bool showInvisibles() const = 0;
virtual ShowDurations::OrNot showDurations() const = 0; virtual ShowDurations::OrNot showDurations() const = 0;
virtual double minDuration() const = 0;
virtual TestSpec const& testSpec() const = 0; virtual TestSpec const& testSpec() const = 0;
virtual bool hasTestFilters() const = 0; virtual bool hasTestFilters() const = 0;
virtual std::vector<std::string> const& getTestsOrTags() const = 0; virtual std::vector<std::string> const& getTestsOrTags() const = 0;

View File

@@ -50,7 +50,7 @@ namespace Catch {
currentTracker.addChild( tracker ); currentTracker.addChild( tracker );
} }
if( !ctx.completedCycle() && !tracker->isComplete() ) { if( !tracker->isComplete() ) {
tracker->open(); tracker->open();
} }
@@ -64,8 +64,28 @@ namespace Catch {
} }
void close() override { void close() override {
TrackerBase::close(); TrackerBase::close();
// Generator interface only finds out if it has another item on atual move // If a generator has a child (it is followed by a section)
if (m_runState == CompletedSuccessfully && m_generator->next()) { // and none of its children have started, then we must wait
// until later to start consuming its values.
// This catches cases where `GENERATE` is placed between two
// `SECTION`s.
// **The check for m_children.empty cannot be removed**.
// doing so would break `GENERATE` _not_ followed by `SECTION`s.
const bool should_wait_for_child =
!m_children.empty() &&
std::find_if( m_children.begin(),
m_children.end(),
[]( TestCaseTracking::ITrackerPtr tracker ) {
return tracker->hasStarted();
} ) == m_children.end();
// This check is a bit tricky, because m_generator->next()
// has a side-effect, where it consumes generator's current
// value, but we do not want to invoke the side-effect if
// this generator is still waiting for any child to start.
if ( should_wait_for_child ||
( m_runState == CompletedSuccessfully &&
m_generator->next() ) ) {
m_children.clear(); m_children.clear();
m_runState = Executing; m_runState = Executing;
} }
@@ -206,7 +226,6 @@ namespace Catch {
using namespace Generators; using namespace Generators;
GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext, GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext,
TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) ); TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) );
assert( tracker.isOpen() );
m_lastAssertionInfo.lineInfo = lineInfo; m_lastAssertionInfo.lineInfo = lineInfo;
return tracker; return tracker;
} }

View File

@@ -187,7 +187,8 @@ namespace TestCaseTracking {
bool SectionTracker::isComplete() const { bool SectionTracker::isComplete() const {
bool complete = true; bool complete = true;
if ((m_filters.empty() || m_filters[0] == "") if (m_filters.empty()
|| m_filters[0] == ""
|| std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) { || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) {
complete = TrackerBase::isComplete(); complete = TrackerBase::isComplete();
} }

View File

@@ -55,6 +55,7 @@ namespace TestCaseTracking {
virtual bool isSuccessfullyCompleted() const = 0; virtual bool isSuccessfullyCompleted() const = 0;
virtual bool isOpen() const = 0; // Started but not complete virtual bool isOpen() const = 0; // Started but not complete
virtual bool hasChildren() const = 0; virtual bool hasChildren() const = 0;
virtual bool hasStarted() const = 0;
virtual ITracker& parent() = 0; virtual ITracker& parent() = 0;
@@ -121,7 +122,9 @@ namespace TestCaseTracking {
bool isSuccessfullyCompleted() const override; bool isSuccessfullyCompleted() const override;
bool isOpen() const override; bool isOpen() const override;
bool hasChildren() const override; bool hasChildren() const override;
bool hasStarted() const override {
return m_runState != NotStarted;
}
void addChild( ITrackerPtr const& child ) override; void addChild( ITrackerPtr const& child ) override;

View File

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

View File

@@ -41,6 +41,17 @@ namespace Catch {
return std::string(buffer); return std::string(buffer);
} }
bool shouldShowDuration( IConfig const& config, double duration ) {
if ( config.showDurations() == ShowDurations::Always ) {
return true;
}
if ( config.showDurations() == ShowDurations::Never ) {
return false;
}
const double min = config.minDuration();
return min >= 0 && duration >= min;
}
std::string serializeFilters( std::vector<std::string> const& container ) { std::string serializeFilters( std::vector<std::string> const& container ) {
ReusableStringStream oss; ReusableStringStream oss;
bool first = true; bool first = true;

View File

@@ -25,6 +25,9 @@ namespace Catch {
// Returns double formatted as %.3f (format expected on output) // Returns double formatted as %.3f (format expected on output)
std::string getFormattedDuration( double duration ); std::string getFormattedDuration( double duration );
//! Should the reporter show
bool shouldShowDuration( IConfig const& config, double duration );
std::string serializeFilters( std::vector<std::string> const& container ); std::string serializeFilters( std::vector<std::string> const& container );
template<typename DerivedT> template<typename DerivedT>
@@ -52,7 +55,7 @@ namespace Catch {
void noMatchingTestCases(std::string const&) override {} void noMatchingTestCases(std::string const&) override {}
void reportInvalidArguments(std::string const&) override {} void reportInvalidArguments(std::string const&) override {}
void testRunStarting(TestRunInfo const& _testRunInfo) override { void testRunStarting(TestRunInfo const& _testRunInfo) override {
currentTestRunInfo = _testRunInfo; currentTestRunInfo = _testRunInfo;
} }

View File

@@ -245,10 +245,6 @@ private:
return "Reports test results on a single line, suitable for IDEs"; return "Reports test results on a single line, suitable for IDEs";
} }
ReporterPreferences CompactReporter::getPreferences() const {
return m_reporterPrefs;
}
void CompactReporter::noMatchingTestCases( std::string const& spec ) { void CompactReporter::noMatchingTestCases( std::string const& spec ) {
stream << "No test cases matched '" << spec << '\'' << std::endl; stream << "No test cases matched '" << spec << '\'' << std::endl;
} }
@@ -275,8 +271,9 @@ private:
} }
void CompactReporter::sectionEnded(SectionStats const& _sectionStats) { void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {
if (m_config->showDurations() == ShowDurations::Always) { double dur = _sectionStats.durationInSeconds;
stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; if ( shouldShowDuration( *m_config, dur ) ) {
stream << getFormattedDuration( dur ) << " s: " << _sectionStats.sectionInfo.name << std::endl;
} }
} }

View File

@@ -22,8 +22,6 @@ namespace Catch {
static std::string getDescription(); static std::string getDescription();
ReporterPreferences getPreferences() const override;
void noMatchingTestCases(std::string const& spec) override; void noMatchingTestCases(std::string const& spec) override;
void assertionStarting(AssertionInfo const&) override; void assertionStarting(AssertionInfo const&) override;

View File

@@ -418,8 +418,9 @@ void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {
stream << "\nNo assertions in test case"; stream << "\nNo assertions in test case";
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
} }
if (m_config->showDurations() == ShowDurations::Always) { double dur = _sectionStats.durationInSeconds;
stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; if (shouldShowDuration(*m_config, dur)) {
stream << getFormattedDuration(dur) << " s: " << _sectionStats.sectionInfo.name << std::endl;
} }
if (m_headerPrinted) { if (m_headerPrinted) {
m_headerPrinted = false; m_headerPrinted = false;

View File

@@ -23,16 +23,17 @@ namespace Catch {
using StreamingReporterBase::StreamingReporterBase; using StreamingReporterBase::StreamingReporterBase;
TAPReporter( ReporterConfig const& config ):
StreamingReporterBase( config ) {
m_reporterPrefs.shouldReportAllAssertions = true;
}
~TAPReporter() override; ~TAPReporter() override;
static std::string getDescription() { static std::string getDescription() {
return "Reports test results in TAP format, suitable for test harnesses"; return "Reports test results in TAP format, suitable for test harnesses";
} }
ReporterPreferences getPreferences() const override {
return m_reporterPrefs;
}
void noMatchingTestCases( std::string const& spec ) override { void noMatchingTestCases( std::string const& spec ) override {
stream << "# No test cases matched '" << spec << "'" << std::endl; stream << "# No test cases matched '" << spec << "'" << std::endl;
} }
@@ -203,16 +204,15 @@ namespace Catch {
return; return;
} }
// using messages.end() directly (or auto) yields compilation error: const auto itEnd = messages.cend();
std::vector<MessageInfo>::const_iterator itEnd = messages.end(); const auto N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
{ {
Colour colourGuard( colour ); Colour colourGuard( colour );
stream << " with " << pluralise( N, "message" ) << ":"; stream << " with " << pluralise( N, "message" ) << ":";
} }
for(; itMessage != itEnd; ) { while( itMessage != itEnd ) {
// If this assertion is a warning ignore any INFO messages // If this assertion is a warning ignore any INFO messages
if( printInfoMessages || itMessage->type != ResultWas::Info ) { if( printInfoMessages || itMessage->type != ResultWas::Info ) {
stream << " '" << itMessage->message << "'"; stream << " '" << itMessage->message << "'";
@@ -220,7 +220,9 @@ namespace Catch {
Colour colourGuard( dimColour() ); Colour colourGuard( dimColour() );
stream << " and"; stream << " and";
} }
continue;
} }
++itMessage;
} }
} }
@@ -234,10 +236,9 @@ namespace Catch {
}; };
void printTotals( const Totals& totals ) const { void printTotals( const Totals& totals ) const {
stream << "1.." << totals.assertions.total();
if( totals.testCases.total() == 0 ) { if( totals.testCases.total() == 0 ) {
stream << "1..0 # Skipped: No tests ran."; stream << " # Skipped: No tests ran.";
} else {
stream << "1.." << counter;
} }
} }
}; };

View File

@@ -27,6 +27,7 @@ set(TEST_SOURCES
${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/ToString.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/ToString.tests.cpp
${SELF_TEST_DIR}/TimingTests/Sleep.tests.cpp
${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp ${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp
${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp ${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp
${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp ${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp

View File

@@ -10,6 +10,40 @@ project( Catch2ExtraTests LANGUAGES CXX )
message( STATUS "Extra tests included" ) message( STATUS "Extra tests included" )
# The MinDuration reporting tests do not need separate compilation, but
# they have non-trivial execution time, so they are categorized as
# extra tests, so that they are run less.
add_test(NAME MinDuration::SimpleThreshold COMMAND $<TARGET_FILE:SelfTest> --min-duration 0.22 [min_duration_test])
set_tests_properties(
MinDuration::SimpleThreshold
PROPERTIES
PASS_REGULAR_EXPRESSION "s: sleep_for_250ms"
FAIL_REGULAR_EXPRESSION "sleep_for_100ms"
RUN_SERIAL ON # The test is timing sensitive, so we want to run it
# serially to avoid false positives on oversubscribed machines
)
# -d yes overrides the threshold, so we should see the faster test even
# with a ridiculous high min duration threshold
add_test(NAME MinDuration::DurationOverrideYes COMMAND $<TARGET_FILE:SelfTest> --min-duration 1.0 -d yes [min_duration_test])
set_tests_properties(
MinDuration::DurationOverrideYes
PROPERTIES
PASS_REGULAR_EXPRESSION "s: sleep_for_100ms"
)
# -d no overrides the threshold, so we should never see any tests even
# with ridiculously low min duration threshold
add_test(NAME MinDuration::DurationOverrideNo COMMAND $<TARGET_FILE:SelfTest> --min-duration 0.0001 -d no [min_duration_test])
set_tests_properties(
MinDuration::DurationOverrideNo
PROPERTIES
FAIL_REGULAR_EXPRESSION "sleep_for_250ms"
)
# ------------ end of duration reporting tests
# define folders used: # define folders used:
set( TESTS_DIR ${CATCH_DIR}/projects/ExtraTests ) set( TESTS_DIR ${CATCH_DIR}/projects/ExtraTests )

View File

@@ -36,6 +36,48 @@ Generators.tests.cpp:<line number>: passed: i != j for: 1 != 3
Generators.tests.cpp:<line number>: passed: i != j for: 1 != 4 Generators.tests.cpp:<line number>: passed: i != j for: 1 != 4
Generators.tests.cpp:<line number>: passed: i != j for: 2 != 3 Generators.tests.cpp:<line number>: passed: i != j for: 2 != 3
Generators.tests.cpp:<line number>: passed: i != j for: 2 != 4 Generators.tests.cpp:<line number>: passed: i != j for: 2 != 4
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'A'
PartTracker.tests.cpp:<line number>: passed: m for: 1
PartTracker.tests.cpp:<line number>: passed: m for: 2
PartTracker.tests.cpp:<line number>: passed: m for: 3
PartTracker.tests.cpp:<line number>: passed: 1
PartTracker.tests.cpp:<line number>: passed: m for: 2
PartTracker.tests.cpp:<line number>: passed: m for: 3
PartTracker.tests.cpp:<line number>: passed: m for: 1
PartTracker.tests.cpp:<line number>: passed: m for: 2
PartTracker.tests.cpp:<line number>: passed: m for: 3
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'A'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 1' and 'j := 3' and 'k := 5'
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'B'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 1' and 'j := 3' and 'k := 6'
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'B'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 1' and 'j := 4' and 'k := 5'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 1' and 'j := 4' and 'k := 6'
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'A'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 2' and 'j := 3' and 'k := 5'
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'B'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 2' and 'j := 3' and 'k := 6'
PartTracker.tests.cpp:<line number>: passed: with 1 message: 'B'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 2' and 'j := 4' and 'k := 5'
PartTracker.tests.cpp:<line number>: passed: with 3 messages: 'i := 2' and 'j := 4' and 'k := 6'
PartTracker.tests.cpp:<line number>: passed: m for: 1
PartTracker.tests.cpp:<line number>: passed: n for: 1
PartTracker.tests.cpp:<line number>: passed: m for: 1
PartTracker.tests.cpp:<line number>: passed: n for: 2
PartTracker.tests.cpp:<line number>: passed: m for: 1
PartTracker.tests.cpp:<line number>: passed: n for: 3
PartTracker.tests.cpp:<line number>: passed: m for: 2
PartTracker.tests.cpp:<line number>: passed: n for: 1
PartTracker.tests.cpp:<line number>: passed: m for: 2
PartTracker.tests.cpp:<line number>: passed: n for: 2
PartTracker.tests.cpp:<line number>: passed: m for: 2
PartTracker.tests.cpp:<line number>: passed: n for: 3
PartTracker.tests.cpp:<line number>: passed: m for: 3
PartTracker.tests.cpp:<line number>: passed: n for: 1
PartTracker.tests.cpp:<line number>: passed: m for: 3
PartTracker.tests.cpp:<line number>: passed: n for: 2
PartTracker.tests.cpp:<line number>: passed: m for: 3
PartTracker.tests.cpp:<line number>: passed: n for: 3
Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed:

View File

@@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string? Why would you throw a std::string?
=============================================================================== ===============================================================================
test cases: 316 | 242 passed | 70 failed | 4 failed as expected test cases: 321 | 247 passed | 70 failed | 4 failed as expected
assertions: 1716 | 1564 passed | 131 failed | 21 failed as expected assertions: 1758 | 1606 passed | 131 failed | 21 failed as expected

View File

@@ -309,6 +309,424 @@ Generators.tests.cpp:<line number>: PASSED:
with expansion: with expansion:
2 != 4 2 != 4
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
A
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - Section followed by flat generate
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( 1 )
-------------------------------------------------------------------------------
#1938 - Section followed by flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - Section followed by flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
A
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 3
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 3
k := 6
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 4
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 4
k := 6
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
A
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 3
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 3
k := 6
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 4
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 4
k := 6
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
3
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0 #1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@@ -13709,6 +14127,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED: Misc.tests.cpp:<line number>: PASSED:
=============================================================================== ===============================================================================
test cases: 316 | 226 passed | 86 failed | 4 failed as expected test cases: 321 | 231 passed | 86 failed | 4 failed as expected
assertions: 1733 | 1564 passed | 148 failed | 21 failed as expected assertions: 1775 | 1606 passed | 148 failed | 21 failed as expected

View File

@@ -309,6 +309,424 @@ Generators.tests.cpp:<line number>: PASSED:
with expansion: with expansion:
2 != 4 2 != 4
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
A
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - GENERATE after a section
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - Section followed by flat generate
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( 1 )
-------------------------------------------------------------------------------
#1938 - Section followed by flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - Section followed by flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - flat generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
A
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 3
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 3
k := 6
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 4
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 1
j := 4
k := 6
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
A
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
A
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 3
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 3
k := 6
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
B
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with message:
B
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 4
k := 5
-------------------------------------------------------------------------------
#1938 - mixed sections and generates
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
with messages:
i := 2
j := 4
k := 6
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
1
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
2
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
3
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
1
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
2
-------------------------------------------------------------------------------
#1938 - nested generate
-------------------------------------------------------------------------------
PartTracker.tests.cpp:<line number>
...............................................................................
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( m )
with expansion:
3
PartTracker.tests.cpp:<line number>: PASSED:
REQUIRE( n )
with expansion:
3
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0 #1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@@ -513,6 +931,6 @@ Condition.tests.cpp:<line number>: FAILED:
CHECK( true != true ) CHECK( true != true )
=============================================================================== ===============================================================================
test cases: 26 | 21 passed | 3 failed | 2 failed as expected test cases: 31 | 26 passed | 3 failed | 2 failed as expected
assertions: 58 | 51 passed | 4 failed | 3 failed as expected assertions: 100 | 93 passed | 4 failed | 3 failed as expected

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact <testsuitesloose text artifact
> >
<testsuite name="<exe-name>" errors="17" failures="132" tests="1734" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="17" failures="132" tests="1776" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties> <properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/> <property name="random-seed" value="1"/>
@@ -35,6 +35,15 @@ Nor would this
<testcase classname="<exe-name>.global" name="#1912 -- test spec parser handles escaping/backslash in test name" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1912 -- test spec parser handles escaping/backslash in test name" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1913 - GENERATE inside a for loop should not keep recreating the generator" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1913 - GENERATE inside a for loop should not keep recreating the generator" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1913 - GENERATEs can share a line" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1913 - GENERATEs can share a line" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - GENERATE after a section/A" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - GENERATE after a section/B" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - Section followed by flat generate" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - Section followed by flat generate/A" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - flat generate" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - mixed sections and generates" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - mixed sections and generates/A" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - mixed sections and generates/B" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1938 - nested generate" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 1, 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, 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, 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="#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0" time="{duration}" status="run"/>

View File

@@ -99,6 +99,15 @@
<testCase name="Generators internals/Range/Negative manual step/Integer/Slightly under end" duration="{duration}"/> <testCase name="Generators internals/Range/Negative manual step/Integer/Slightly under end" duration="{duration}"/>
</file> </file>
<file path="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp"> <file path="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp">
<testCase name="#1938 - GENERATE after a section/A" duration="{duration}"/>
<testCase name="#1938 - GENERATE after a section/B" duration="{duration}"/>
<testCase name="#1938 - Section followed by flat generate" duration="{duration}"/>
<testCase name="#1938 - Section followed by flat generate/A" duration="{duration}"/>
<testCase name="#1938 - flat generate" duration="{duration}"/>
<testCase name="#1938 - mixed sections and generates" duration="{duration}"/>
<testCase name="#1938 - mixed sections and generates/A" duration="{duration}"/>
<testCase name="#1938 - mixed sections and generates/B" duration="{duration}"/>
<testCase name="#1938 - nested generate" duration="{duration}"/>
<testCase name="Tracker" duration="{duration}"/> <testCase name="Tracker" duration="{duration}"/>
<testCase name="Tracker/successfully close one section" duration="{duration}"/> <testCase name="Tracker/successfully close one section" duration="{duration}"/>
<testCase name="Tracker/fail one section" duration="{duration}"/> <testCase name="Tracker/fail one section" duration="{duration}"/>

View File

@@ -318,6 +318,342 @@ Nor would this
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="#1938 - GENERATE after a section" tags="[!hide][.][generators][regression]" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Section name="A" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
1
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
2
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
3
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1938 - Section followed by flat generate" tags="[!hide][.][generators][regression]" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Section name="A" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
1
</Original>
<Expanded>
1
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
3
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1938 - flat generate" tags="[!hide][.][generators][regression]" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
3
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1938 - mixed sections and generates" tags="[!hide][.][generators][regression]" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Section name="A" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Info>
i := 1
</Info>
<Info>
j := 3
</Info>
<Info>
k := 5
</Info>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Info>
i := 1
</Info>
<Info>
j := 3
</Info>
<Info>
k := 6
</Info>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Info>
i := 1
</Info>
<Info>
j := 4
</Info>
<Info>
k := 5
</Info>
<Info>
i := 1
</Info>
<Info>
j := 4
</Info>
<Info>
k := 6
</Info>
<Section name="A" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Info>
i := 2
</Info>
<Info>
j := 3
</Info>
<Info>
k := 5
</Info>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Info>
i := 2
</Info>
<Info>
j := 3
</Info>
<Info>
k := 6
</Info>
<Section name="B" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<Info>
i := 2
</Info>
<Info>
j := 4
</Info>
<Info>
k := 5
</Info>
<Info>
i := 2
</Info>
<Info>
j := 4
</Info>
<Info>
k := 6
</Info>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1938 - nested generate" tags="[!hide][.][generators][regression]" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
1
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
m
</Original>
<Expanded>
3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/PartTracker.tests.cpp" >
<Original>
n
</Original>
<Expanded>
3
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0" tags="[!hide][.][compilation][regression]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > <TestCase name="#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0" tags="[!hide][.][compilation][regression]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
@@ -16375,9 +16711,9 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="1564" failures="149" expectedFailures="21"/> <OverallResults successes="1606" failures="149" expectedFailures="21"/>
<OverallResultsCases successes="226" failures="86" expectedFailures="4"/> <OverallResultsCases successes="231" failures="86" expectedFailures="4"/>
</Group> </Group>
<OverallResults successes="1564" failures="148" expectedFailures="21"/> <OverallResults successes="1606" failures="148" expectedFailures="21"/>
<OverallResultsCases successes="226" failures="86" expectedFailures="4"/> <OverallResultsCases successes="231" failures="86" expectedFailures="4"/>
</Catch> </Catch>

View File

@@ -204,3 +204,50 @@ TEST_CASE("#1670 regression check", "[.approvals][tracker]") {
SECTION("2") SUCCEED(); SECTION("2") SUCCEED();
} }
} }
// #1938 required a rework on how generator tracking works, so that `GENERATE`
// supports being sandwiched between two `SECTION`s. The following tests check
// various other scenarios through checking output in approval tests.
TEST_CASE("#1938 - GENERATE after a section", "[.][regression][generators]") {
SECTION("A") {
SUCCEED("A");
}
auto m = GENERATE(1, 2, 3);
SECTION("B") {
REQUIRE(m);
}
}
TEST_CASE("#1938 - flat generate", "[.][regression][generators]") {
auto m = GENERATE(1, 2, 3);
REQUIRE(m);
}
TEST_CASE("#1938 - nested generate", "[.][regression][generators]") {
auto m = GENERATE(1, 2, 3);
auto n = GENERATE(1, 2, 3);
REQUIRE(m);
REQUIRE(n);
}
TEST_CASE("#1938 - mixed sections and generates", "[.][regression][generators]") {
auto i = GENERATE(1, 2);
SECTION("A") {
SUCCEED("A");
}
auto j = GENERATE(3, 4);
SECTION("B") {
SUCCEED("B");
}
auto k = GENERATE(5, 6);
CAPTURE(i, j, k);
SUCCEED();
}
TEST_CASE("#1938 - Section followed by flat generate", "[.][regression][generators]") {
SECTION("A") {
REQUIRE(1);
}
auto m = GENERATE(2, 3);
REQUIRE(m);
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include "catch.hpp"
#include <chrono>
#include <thread>
TEST_CASE( "sleep_for_100ms", "[.min_duration_test][approvals]" )
{
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
CHECK( true );
}
TEST_CASE( "sleep_for_250ms", "[.min_duration_test][approvals]" )
{
std::this_thread::sleep_for( std::chrono::milliseconds( 250 ) );
CHECK( true );
}

View File

@@ -267,6 +267,7 @@ TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") {
REQUIRE(i != j); REQUIRE(i != j);
} }
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@@ -15,9 +15,9 @@ import random
def list_tests(self_test_exe, tags, rng_seed): def list_tests(self_test_exe, tags, rng_seed):
cmd = [self_test_exe, '--list-test-names-only', '--order', 'rand', cmd = [self_test_exe, '--list-test-names-only', '--order', 'rand',
'--rng-seed', str(rng_seed)] '--rng-seed', str(rng_seed)]
tags_arg = ','.join('[{}]'.format(t) for t in tags) tags_arg = ','.join('[{}]~[.]'.format(t) for t in tags)
if tags_arg: if tags_arg:
cmd.append(tags_arg + '~[.]') cmd.append(tags_arg)
process = subprocess.Popen( process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate() stdout, stderr = process.communicate()

View File

@@ -1,6 +1,6 @@
/* /*
* Catch v2.12.4 * Catch v2.13.0
* Generated: 2020-07-05 11:47:18.451282 * Generated: 2020-07-12 20:07:49.015950
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved.
@@ -14,8 +14,8 @@
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 4 #define CATCH_VERSION_PATCH 0
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header
@@ -4522,6 +4522,7 @@ namespace Catch {
virtual int abortAfter() const = 0; virtual int abortAfter() const = 0;
virtual bool showInvisibles() const = 0; virtual bool showInvisibles() const = 0;
virtual ShowDurations::OrNot showDurations() const = 0; virtual ShowDurations::OrNot showDurations() const = 0;
virtual double minDuration() const = 0;
virtual TestSpec const& testSpec() const = 0; virtual TestSpec const& testSpec() const = 0;
virtual bool hasTestFilters() const = 0; virtual bool hasTestFilters() const = 0;
virtual std::vector<std::string> const& getTestsOrTags() const = 0; virtual std::vector<std::string> const& getTestsOrTags() const = 0;
@@ -5294,6 +5295,7 @@ namespace Catch {
Verbosity verbosity = Verbosity::Normal; Verbosity verbosity = Verbosity::Normal;
WarnAbout::What warnings = WarnAbout::Nothing; WarnAbout::What warnings = WarnAbout::Nothing;
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
double minDuration = -1;
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
UseColour::YesOrNo useColour = UseColour::Auto; UseColour::YesOrNo useColour = UseColour::Auto;
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
@@ -5344,6 +5346,7 @@ namespace Catch {
bool warnAboutMissingAssertions() const override; bool warnAboutMissingAssertions() const override;
bool warnAboutNoTests() const override; bool warnAboutNoTests() const override;
ShowDurations::OrNot showDurations() const override; ShowDurations::OrNot showDurations() const override;
double minDuration() const override;
RunTests::InWhatOrder runOrder() const override; RunTests::InWhatOrder runOrder() const override;
unsigned int rngSeed() const override; unsigned int rngSeed() const override;
UseColour::YesOrNo useColour() const override; UseColour::YesOrNo useColour() const override;
@@ -5721,6 +5724,9 @@ namespace Catch {
// Returns double formatted as %.3f (format expected on output) // Returns double formatted as %.3f (format expected on output)
std::string getFormattedDuration( double duration ); std::string getFormattedDuration( double duration );
//! Should the reporter show
bool shouldShowDuration( IConfig const& config, double duration );
std::string serializeFilters( std::vector<std::string> const& container ); std::string serializeFilters( std::vector<std::string> const& container );
template<typename DerivedT> template<typename DerivedT>
@@ -6114,8 +6120,6 @@ namespace Catch {
static std::string getDescription(); static std::string getDescription();
ReporterPreferences getPreferences() const override;
void noMatchingTestCases(std::string const& spec) override; void noMatchingTestCases(std::string const& spec) override;
void assertionStarting(AssertionInfo const&) override; void assertionStarting(AssertionInfo const&) override;
@@ -7499,6 +7503,7 @@ namespace TestCaseTracking {
virtual bool isSuccessfullyCompleted() const = 0; virtual bool isSuccessfullyCompleted() const = 0;
virtual bool isOpen() const = 0; // Started but not complete virtual bool isOpen() const = 0; // Started but not complete
virtual bool hasChildren() const = 0; virtual bool hasChildren() const = 0;
virtual bool hasStarted() const = 0;
virtual ITracker& parent() = 0; virtual ITracker& parent() = 0;
@@ -7565,6 +7570,9 @@ namespace TestCaseTracking {
bool isSuccessfullyCompleted() const override; bool isSuccessfullyCompleted() const override;
bool isOpen() const override; bool isOpen() const override;
bool hasChildren() const override; bool hasChildren() const override;
bool hasStarted() const override {
return m_runState != NotStarted;
}
void addChild( ITrackerPtr const& child ) override; void addChild( ITrackerPtr const& child ) override;
@@ -9861,6 +9869,9 @@ namespace Catch {
| Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" )
["-d"]["--durations"] ["-d"]["--durations"]
( "show test durations" ) ( "show test durations" )
| Opt( config.minDuration, "seconds" )
["-D"]["--min-duration"]
( "show test durations for tests taking at least the given number of seconds" )
| Opt( loadTestNamesFromFile, "filename" ) | Opt( loadTestNamesFromFile, "filename" )
["-f"]["--input-file"] ["-f"]["--input-file"]
( "load test names to run from a file" ) ( "load test names to run from a file" )
@@ -10008,6 +10019,7 @@ namespace Catch {
bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); }
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }
double Config::minDuration() const { return m_data.minDuration; }
RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; }
unsigned int Config::rngSeed() const { return m_data.rngSeed; } unsigned int Config::rngSeed() const { return m_data.rngSeed; }
UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } UseColour::YesOrNo Config::useColour() const { return m_data.useColour; }
@@ -12547,7 +12559,7 @@ namespace Catch {
currentTracker.addChild( tracker ); currentTracker.addChild( tracker );
} }
if( !ctx.completedCycle() && !tracker->isComplete() ) { if( !tracker->isComplete() ) {
tracker->open(); tracker->open();
} }
@@ -12561,8 +12573,28 @@ namespace Catch {
} }
void close() override { void close() override {
TrackerBase::close(); TrackerBase::close();
// Generator interface only finds out if it has another item on atual move // If a generator has a child (it is followed by a section)
if (m_runState == CompletedSuccessfully && m_generator->next()) { // and none of its children have started, then we must wait
// until later to start consuming its values.
// This catches cases where `GENERATE` is placed between two
// `SECTION`s.
// **The check for m_children.empty cannot be removed**.
// doing so would break `GENERATE` _not_ followed by `SECTION`s.
const bool should_wait_for_child =
!m_children.empty() &&
std::find_if( m_children.begin(),
m_children.end(),
[]( TestCaseTracking::ITrackerPtr tracker ) {
return tracker->hasStarted();
} ) == m_children.end();
// This check is a bit tricky, because m_generator->next()
// has a side-effect, where it consumes generator's current
// value, but we do not want to invoke the side-effect if
// this generator is still waiting for any child to start.
if ( should_wait_for_child ||
( m_runState == CompletedSuccessfully &&
m_generator->next() ) ) {
m_children.clear(); m_children.clear();
m_runState = Executing; m_runState = Executing;
} }
@@ -12702,7 +12734,6 @@ namespace Catch {
using namespace Generators; using namespace Generators;
GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext, GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext,
TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) ); TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) );
assert( tracker.isOpen() );
m_lastAssertionInfo.lineInfo = lineInfo; m_lastAssertionInfo.lineInfo = lineInfo;
return tracker; return tracker;
} }
@@ -14381,7 +14412,8 @@ namespace TestCaseTracking {
bool SectionTracker::isComplete() const { bool SectionTracker::isComplete() const {
bool complete = true; bool complete = true;
if ((m_filters.empty() || m_filters[0] == "") if (m_filters.empty()
|| m_filters[0] == ""
|| std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) { || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) {
complete = TrackerBase::isComplete(); complete = TrackerBase::isComplete();
} }
@@ -15206,7 +15238,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 12, 4, "", 0 ); static Version version( 2, 13, 0, "", 0 );
return version; return version;
} }
@@ -15608,6 +15640,17 @@ namespace Catch {
return std::string(buffer); return std::string(buffer);
} }
bool shouldShowDuration( IConfig const& config, double duration ) {
if ( config.showDurations() == ShowDurations::Always ) {
return true;
}
if ( config.showDurations() == ShowDurations::Never ) {
return false;
}
const double min = config.minDuration();
return min >= 0 && duration >= min;
}
std::string serializeFilters( std::vector<std::string> const& container ) { std::string serializeFilters( std::vector<std::string> const& container ) {
ReusableStringStream oss; ReusableStringStream oss;
bool first = true; bool first = true;
@@ -15874,10 +15917,6 @@ private:
return "Reports test results on a single line, suitable for IDEs"; return "Reports test results on a single line, suitable for IDEs";
} }
ReporterPreferences CompactReporter::getPreferences() const {
return m_reporterPrefs;
}
void CompactReporter::noMatchingTestCases( std::string const& spec ) { void CompactReporter::noMatchingTestCases( std::string const& spec ) {
stream << "No test cases matched '" << spec << '\'' << std::endl; stream << "No test cases matched '" << spec << '\'' << std::endl;
} }
@@ -15904,8 +15943,9 @@ private:
} }
void CompactReporter::sectionEnded(SectionStats const& _sectionStats) { void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {
if (m_config->showDurations() == ShowDurations::Always) { double dur = _sectionStats.durationInSeconds;
stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; if ( shouldShowDuration( *m_config, dur ) ) {
stream << getFormattedDuration( dur ) << " s: " << _sectionStats.sectionInfo.name << std::endl;
} }
} }
@@ -16325,8 +16365,9 @@ void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {
stream << "\nNo assertions in test case"; stream << "\nNo assertions in test case";
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
} }
if (m_config->showDurations() == ShowDurations::Always) { double dur = _sectionStats.durationInSeconds;
stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; if (shouldShowDuration(*m_config, dur)) {
stream << getFormattedDuration(dur) << " s: " << _sectionStats.sectionInfo.name << std::endl;
} }
if (m_headerPrinted) { if (m_headerPrinted) {
m_headerPrinted = false; m_headerPrinted = false;

View File

@@ -23,16 +23,17 @@ namespace Catch {
using StreamingReporterBase::StreamingReporterBase; using StreamingReporterBase::StreamingReporterBase;
TAPReporter( ReporterConfig const& config ):
StreamingReporterBase( config ) {
m_reporterPrefs.shouldReportAllAssertions = true;
}
~TAPReporter() override; ~TAPReporter() override;
static std::string getDescription() { static std::string getDescription() {
return "Reports test results in TAP format, suitable for test harnesses"; return "Reports test results in TAP format, suitable for test harnesses";
} }
ReporterPreferences getPreferences() const override {
return m_reporterPrefs;
}
void noMatchingTestCases( std::string const& spec ) override { void noMatchingTestCases( std::string const& spec ) override {
stream << "# No test cases matched '" << spec << "'" << std::endl; stream << "# No test cases matched '" << spec << "'" << std::endl;
} }
@@ -203,16 +204,15 @@ namespace Catch {
return; return;
} }
// using messages.end() directly (or auto) yields compilation error: const auto itEnd = messages.cend();
std::vector<MessageInfo>::const_iterator itEnd = messages.end(); const auto N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
{ {
Colour colourGuard( colour ); Colour colourGuard( colour );
stream << " with " << pluralise( N, "message" ) << ":"; stream << " with " << pluralise( N, "message" ) << ":";
} }
for(; itMessage != itEnd; ) { while( itMessage != itEnd ) {
// If this assertion is a warning ignore any INFO messages // If this assertion is a warning ignore any INFO messages
if( printInfoMessages || itMessage->type != ResultWas::Info ) { if( printInfoMessages || itMessage->type != ResultWas::Info ) {
stream << " '" << itMessage->message << "'"; stream << " '" << itMessage->message << "'";
@@ -220,7 +220,9 @@ namespace Catch {
Colour colourGuard( dimColour() ); Colour colourGuard( dimColour() );
stream << " and"; stream << " and";
} }
continue;
} }
++itMessage;
} }
} }
@@ -234,10 +236,9 @@ namespace Catch {
}; };
void printTotals( const Totals& totals ) const { void printTotals( const Totals& totals ) const {
stream << "1.." << totals.assertions.total();
if( totals.testCases.total() == 0 ) { if( totals.testCases.total() == 0 ) {
stream << "1..0 # Skipped: No tests ran."; stream << " # Skipped: No tests ran.";
} else {
stream << "1.." << counter;
} }
} }
}; };