Skip to content

Commit 447f53e

Browse files
committed
Fixed !shouldfail
1 parent 13a887a commit 447f53e

File tree

9 files changed

+161
-12
lines changed

9 files changed

+161
-12
lines changed

include/internal/catch_run_context.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ namespace Catch {
109109
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
110110

111111
Totals deltaTotals = m_totals.delta( prevTotals );
112+
if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) {
113+
deltaTotals.assertions.failed++;
114+
deltaTotals.testCases.passed--;
115+
deltaTotals.testCases.failed++;
116+
}
112117
m_totals.testCases += deltaTotals.testCases;
113118
m_reporter->testCaseEnded( TestCaseStats( testInfo,
114119
deltaTotals,

include/reporters/catch_reporter_console.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ namespace Catch {
349349
if( totals.testCases.total() == 0 ) {
350350
stream << Colour( Colour::Warning ) << "No tests ran\n";
351351
}
352-
else if( totals.assertions.total() > 0 && totals.assertions.allPassed() ) {
352+
else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) {
353353
stream << Colour( Colour::ResultSuccess ) << "All tests passed";
354354
stream << " ("
355355
<< pluralise( totals.assertions.passed, "assertion" ) << " in "

projects/SelfTest/Baselines/console.std.approved.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,6 @@ with expansion:
830830
"first" == "second"
831831

832832
===============================================================================
833-
test cases: 167 | 124 passed | 42 failed | 1 failed as expected
834-
assertions: 919 | 823 passed | 83 failed | 13 failed as expected
833+
test cases: 168 | 124 passed | 42 failed | 2 failed as expected
834+
assertions: 920 | 824 passed | 78 failed | 18 failed as expected
835835

projects/SelfTest/Baselines/console.sw.approved.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3951,6 +3951,17 @@ with expansion:
39513951
==
39523952
9223372036854775807 (0x<hex digits>)
39533953

3954+
-------------------------------------------------------------------------------
3955+
This test 'should' fail but doesn't
3956+
-------------------------------------------------------------------------------
3957+
MiscTests.cpp:<line number>
3958+
...............................................................................
3959+
3960+
MiscTests.cpp:<line number>:
3961+
PASSED:
3962+
with message:
3963+
oops!
3964+
39543965
-------------------------------------------------------------------------------
39553966
Process can be configured on command line
39563967
default - no arguments
@@ -9093,6 +9104,6 @@ with expansion:
90939104
1 > 0
90949105

90959106
===============================================================================
9096-
test cases: 167 | 123 passed | 43 failed | 1 failed as expected
9097-
assertions: 921 | 823 passed | 85 failed | 13 failed as expected
9107+
test cases: 168 | 123 passed | 43 failed | 2 failed as expected
9108+
assertions: 922 | 824 passed | 80 failed | 18 failed as expected
90989109

projects/SelfTest/Baselines/console.swa4.approved.txt

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,131 @@ ConditionTests.cpp:<line number>: FAILED:
485485
with expansion:
486486
9.1f != Approx( 9.1000003815 )
487487

488+
-------------------------------------------------------------------------------
489+
Ordering comparison checks that should succeed
490+
-------------------------------------------------------------------------------
491+
ConditionTests.cpp:<line number>
492+
...............................................................................
493+
494+
ConditionTests.cpp:<line number>:
495+
PASSED:
496+
REQUIRE( data.int_seven < 8 )
497+
with expansion:
498+
7 < 8
499+
500+
ConditionTests.cpp:<line number>:
501+
PASSED:
502+
REQUIRE( data.int_seven > 6 )
503+
with expansion:
504+
7 > 6
505+
506+
ConditionTests.cpp:<line number>:
507+
PASSED:
508+
REQUIRE( data.int_seven > 0 )
509+
with expansion:
510+
7 > 0
511+
512+
ConditionTests.cpp:<line number>:
513+
PASSED:
514+
REQUIRE( data.int_seven > -1 )
515+
with expansion:
516+
7 > -1
517+
518+
ConditionTests.cpp:<line number>:
519+
PASSED:
520+
REQUIRE( data.int_seven >= 7 )
521+
with expansion:
522+
7 >= 7
523+
524+
ConditionTests.cpp:<line number>:
525+
PASSED:
526+
REQUIRE( data.int_seven >= 6 )
527+
with expansion:
528+
7 >= 6
529+
530+
ConditionTests.cpp:<line number>:
531+
PASSED:
532+
REQUIRE( data.int_seven <= 7 )
533+
with expansion:
534+
7 <= 7
535+
536+
ConditionTests.cpp:<line number>:
537+
PASSED:
538+
REQUIRE( data.int_seven <= 8 )
539+
with expansion:
540+
7 <= 8
541+
542+
ConditionTests.cpp:<line number>:
543+
PASSED:
544+
REQUIRE( data.float_nine_point_one > 9 )
545+
with expansion:
546+
9.1f > 9
547+
548+
ConditionTests.cpp:<line number>:
549+
PASSED:
550+
REQUIRE( data.float_nine_point_one < 10 )
551+
with expansion:
552+
9.1f < 10
553+
554+
ConditionTests.cpp:<line number>:
555+
PASSED:
556+
REQUIRE( data.float_nine_point_one < 9.2 )
557+
with expansion:
558+
9.1f < 9.2
559+
560+
ConditionTests.cpp:<line number>:
561+
PASSED:
562+
REQUIRE( data.str_hello <= "hello" )
563+
with expansion:
564+
"hello" <= "hello"
565+
566+
ConditionTests.cpp:<line number>:
567+
PASSED:
568+
REQUIRE( data.str_hello >= "hello" )
569+
with expansion:
570+
"hello" >= "hello"
571+
572+
ConditionTests.cpp:<line number>:
573+
PASSED:
574+
REQUIRE( data.str_hello < "hellp" )
575+
with expansion:
576+
"hello" < "hellp"
577+
578+
ConditionTests.cpp:<line number>:
579+
PASSED:
580+
REQUIRE( data.str_hello < "zebra" )
581+
with expansion:
582+
"hello" < "zebra"
583+
584+
ConditionTests.cpp:<line number>:
585+
PASSED:
586+
REQUIRE( data.str_hello > "hellm" )
587+
with expansion:
588+
"hello" > "hellm"
589+
590+
ConditionTests.cpp:<line number>:
591+
PASSED:
592+
REQUIRE( data.str_hello > "a" )
593+
with expansion:
594+
"hello" > "a"
595+
596+
-------------------------------------------------------------------------------
597+
Ordering comparison checks that should fail
598+
-------------------------------------------------------------------------------
599+
ConditionTests.cpp:<line number>
600+
...............................................................................
601+
602+
ConditionTests.cpp:<line number>: FAILED:
603+
CHECK( data.int_seven > 7 )
604+
with expansion:
605+
7 > 7
606+
607+
ConditionTests.cpp:<line number>: FAILED:
608+
CHECK( data.int_seven < 7 )
609+
with expansion:
610+
7 < 7
611+
488612
===============================================================================
489-
test cases: 19 | 15 passed | 3 failed | 1 failed as expected
490-
assertions: 62 | 56 passed | 4 failed | 2 failed as expected
613+
test cases: 21 | 16 passed | 3 failed | 2 failed as expected
614+
assertions: 81 | 73 passed | 4 failed | 4 failed as expected
491615

projects/SelfTest/Baselines/junit.sw.approved.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<testsuites>
2-
<testsuite name="CatchSelfTest" errors="13" failures="72" tests="921" hostname="tbd" time="{duration}" timestamp="tbd">
2+
<testsuite name="CatchSelfTest" errors="13" failures="68" tests="923" hostname="tbd" time="{duration}" timestamp="tbd">
33
<testcase classname="global" name="toString(enum)" time="{duration}"/>
44
<testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
55
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
@@ -499,6 +499,7 @@ MiscTests.cpp:<line number>
499499
<testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/>
500500
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
501501
<testcase classname="global" name="long long" time="{duration}"/>
502+
<testcase classname="global" name="This test 'should' fail but doesn't" time="{duration}"/>
502503
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
503504
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
504505
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>

projects/SelfTest/Baselines/xml.sw.approved.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@
665665
5 != 5
666666
</Expanded>
667667
</Expression>
668-
<OverallResult success="false"/>
668+
<OverallResult success="true"/>
669669
</TestCase>
670670
<TestCase name="Ordering comparison checks that should succeed">
671671
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
@@ -4085,6 +4085,9 @@
40854085
</Expression>
40864086
<OverallResult success="true"/>
40874087
</TestCase>
4088+
<TestCase name="This test 'should' fail but doesn't">
4089+
<OverallResult success="false"/>
4090+
</TestCase>
40884091
<TestCase name="Process can be configured on command line">
40894092
<Section name="default - no arguments">
40904093
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
@@ -9563,7 +9566,7 @@ there"
95639566
</Section>
95649567
<OverallResult success="true"/>
95659568
</TestCase>
9566-
<OverallResults successes="823" failures="85" expectedFailures="13"/>
9569+
<OverallResults successes="824" failures="81" expectedFailures="18"/>
95679570
</Group>
9568-
<OverallResults successes="823" failures="85" expectedFailures="13"/>
9571+
<OverallResults successes="824" failures="80" expectedFailures="18"/>
95699572
</Catch>

projects/SelfTest/ConditionTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ TEST_CASE( "Inequality checks that should succeed", "" )
101101
REQUIRE( data.str_hello.size() != 6 );
102102
}
103103

104-
TEST_CASE( "Inequality checks that should fail", "[.][failing]" )
104+
TEST_CASE( "Inequality checks that should fail", "[.][failing][!shouldfail]" )
105105
{
106106
TestData data;
107107

projects/SelfTest/MiscTests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,8 @@ TEST_CASE( "long long" ) {
478478
// int x = 10/i; // This should cause the signal to fire
479479
// CHECK( x == 0 );
480480
//}
481+
482+
TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" )
483+
{
484+
SUCCEED( "oops!" );
485+
}

0 commit comments

Comments
 (0)