From 28db5ed4c98db6a47d7a04afbd6b7ad9ba73e401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 2 Mar 2019 21:22:41 +0100 Subject: [PATCH] Add tests for #1514 If the regression comes back, it will only be caught by approvals, but that's better than nothing. --- .../Baselines/compact.sw.approved.txt | 5 ++++- .../Baselines/console.std.approved.txt | 16 ++++++++++++++-- .../Baselines/console.sw.approved.txt | 16 ++++++++++++++-- .../Baselines/console.swa4.approved.txt | 19 +++++++++++++------ .../SelfTest/Baselines/junit.sw.approved.txt | 16 +++++++++++++++- .../SelfTest/Baselines/xml.sw.approved.txt | 17 +++++++++++++++-- projects/SelfTest/UsageTests/Tricky.tests.cpp | 8 ++++++++ 7 files changed, 83 insertions(+), 14 deletions(-) diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 31c7ee0d..494fba13 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -14,6 +14,9 @@ Compilation.tests.cpp:: passed: std::memcmp(uarr, "123", sizeof(uar Compilation.tests.cpp:: passed: std::memcmp(sarr, "456", sizeof(sarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"' Compilation.tests.cpp:: passed: Compilation.tests.cpp:: passed: h1 == h2 for: [1403 helper] == [1403 helper] +Nor would this +This would not be caught previously +Tricky.tests.cpp:: failed: explicitly with 1 message: '1514' Compilation.tests.cpp:: passed: std::is_same, TypeList>::value for: true Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42' with 1 message: 'expected exception' Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' @@ -1459,5 +1462,5 @@ Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -Failed 69 test cases, failed 129 assertions. +Failed 70 test cases, failed 130 assertions. diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 9be03dcd..2353c07e 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1,3 +1,5 @@ +Nor would this +This would not be caught previously ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is a host application. @@ -5,6 +7,16 @@ Run with -? for options Randomness seeded to: 1 +------------------------------------------------------------------------------- +#1514: stderr/stdout is not captured in tests aborted by an exception +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: +explicitly with message: + 1514 + ------------------------------------------------------------------------------- #748 - captures with unexpected exceptions outside assertions @@ -1174,6 +1186,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 246 | 186 passed | 56 failed | 4 failed as expected -assertions: 1380 | 1244 passed | 115 failed | 21 failed as expected +test cases: 247 | 186 passed | 57 failed | 4 failed as expected +assertions: 1381 | 1244 passed | 116 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 23f91912..03b049f2 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -133,6 +133,18 @@ Compilation.tests.cpp:: PASSED: with expansion: [1403 helper] == [1403 helper] +Nor would this +This would not be caught previously +------------------------------------------------------------------------------- +#1514: stderr/stdout is not captured in tests aborted by an exception +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: +explicitly with message: + 1514 + ------------------------------------------------------------------------------- #1548 ------------------------------------------------------------------------------- @@ -10709,6 +10721,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 246 | 173 passed | 69 failed | 4 failed as expected -assertions: 1394 | 1244 passed | 129 failed | 21 failed as expected +test cases: 247 | 173 passed | 70 failed | 4 failed as expected +assertions: 1395 | 1244 passed | 130 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index 63d7e28f..770b3273 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -133,6 +133,18 @@ Compilation.tests.cpp:: PASSED: with expansion: [1403 helper] == [1403 helper] +Nor would this +This would not be caught previously +------------------------------------------------------------------------------- +#1514: stderr/stdout is not captured in tests aborted by an exception +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: +explicitly with message: + 1514 + ------------------------------------------------------------------------------- #1548 ------------------------------------------------------------------------------- @@ -328,12 +340,7 @@ Condition.tests.cpp:: FAILED: with expansion: false -Condition.tests.cpp:: FAILED: - CHECK_FALSE( true ) -with expansion: - !true - =============================================================================== -test cases: 16 | 13 passed | 1 failed | 2 failed as expected +test cases: 17 | 13 passed | 2 failed | 2 failed as expected assertions: 40 | 33 passed | 4 failed | 3 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 2c8a6495..b99e0151 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -4,7 +4,7 @@ loose text artifact - + @@ -13,6 +13,18 @@ loose text artifact + + +1514 +Tricky.tests.cpp: + + +This would not be caught previously + + +Nor would this + + @@ -998,11 +1010,13 @@ Exception.tests.cpp: +This would not be caught previously A string sent directly to stdout Message from section one Message from section two +Nor would this A string sent directly to stderr A string sent to stderr via clog diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 60257c25..a1785047 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -142,6 +142,19 @@ + + + 1514 + + + +This would not be caught previously + + +Nor would this + + + @@ -12959,7 +12972,7 @@ loose text artifact - + - + diff --git a/projects/SelfTest/UsageTests/Tricky.tests.cpp b/projects/SelfTest/UsageTests/Tricky.tests.cpp index b0363d42..44863c49 100644 --- a/projects/SelfTest/UsageTests/Tricky.tests.cpp +++ b/projects/SelfTest/UsageTests/Tricky.tests.cpp @@ -19,6 +19,7 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// TEST_CASE @@ -426,3 +427,10 @@ TEST_CASE( "Bitfields can be captured (#1027)" ) { REQUIRE( y.v == 0 ); REQUIRE( 0 == y.v ); } + +TEST_CASE("#1514: stderr/stdout is not captured in tests aborted by an exception", "[output-capture][regression][.]") { + std::cout << "This would not be caught previously\n"; + std::clog << "Nor would this\n"; + // FAIL aborts the test by throwing a Catch exception + FAIL("1514"); +}