Removed displaced RunningTest class

This commit is contained in:
Phil Nash 2013-07-25 07:49:00 +01:00
parent 9aff9aa328
commit ee647f5099
3 changed files with 9 additions and 138 deletions

View File

@ -16,7 +16,6 @@
#include "catch_test_case_info.h"
#include "catch_capture.hpp"
#include "catch_totals.hpp"
#include "catch_running_test.hpp"
#include "catch_test_spec.h"
#include "catch_test_case_tracker.hpp"
@ -60,7 +59,7 @@ namespace Catch {
explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
: m_runInfo( config->name() ),
m_context( getCurrentMutableContext() ),
m_runningTest( NULL ),
m_activeTestCase( NULL ),
m_config( config ),
m_reporter( reporter ),
m_prevRunner( &m_context.getRunner() ),
@ -115,14 +114,13 @@ namespace Catch {
m_reporter->testCaseStarting( testInfo );
m_runningTest = new RunningTest( testCase ); // deprecated
m_activeTestCase = &testCase;
m_testCaseTracker = TestCaseTracker( testInfo.name );
do {
do {
runCurrentTest( redirectedCout, redirectedCerr );
}
// while( m_runningTest->hasUntestedSections() && !aborting() );
while( !m_testCaseTracker->isCompleted() && !aborting() );
}
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
@ -145,8 +143,7 @@ namespace Catch {
aborting() ) );
delete m_runningTest;
m_runningTest = NULL;
m_activeTestCase = NULL;
m_testCaseTracker.reset();
return deltaTotals;
@ -189,9 +186,6 @@ namespace Catch {
if( !m_testCaseTracker->enterSection( oss.str() ) )
return false;
// if( !m_runningTest->addSection( oss.str() ) ) // deprecated
// return false;
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
m_reporter->sectionStarting( sectionInfo );
@ -212,13 +206,11 @@ namespace Catch {
if( assertions.total() == 0 &&
m_config->warnAboutMissingAssertions() &&
!m_testCaseTracker->currentSectionHasChildren() ) {
// m_runningTest->isBranchSection() ) { // deprecated
m_totals.assertions.failed++;
assertions.failed++;
missingAssertions = true;
}
// m_runningTest->endSection( info.name, false ); // deprecated
m_testCaseTracker->leaveSection();
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
@ -238,8 +230,8 @@ namespace Catch {
}
virtual std::string getCurrentTestName() const {
return m_runningTest
? m_runningTest->getTestCase().getTestCaseInfo().name
return m_activeTestCase
? m_activeTestCase->getTestCaseInfo().name
: "";
}
@ -272,23 +264,21 @@ namespace Catch {
}
void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
TestCaseInfo const& testCaseInfo = m_runningTest->getTestCase().getTestCaseInfo();
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo );
m_reporter->sectionStarting( testCaseSection );
try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
//m_runningTest->reset(); // deprecated
m_testCaseTracker->enter();
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
StreamRedirect coutRedir( std::cout, redirectedCout );
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
m_runningTest->getTestCase().invoke();
m_activeTestCase->invoke();
}
else {
m_runningTest->getTestCase().invoke();
m_activeTestCase->invoke();
}
//m_runningTest->ranToCompletion(); // deprecated
m_testCaseTracker->leave();
}
catch( TestFailureException& ) {
@ -326,7 +316,7 @@ namespace Catch {
TestRunInfo m_runInfo;
IMutableContext& m_context;
RunningTest* m_runningTest; // deprecated
TestCase const* m_activeTestCase;
Option<TestCaseTracker> m_testCaseTracker;
AssertionResult m_lastResult;

View File

@ -1,117 +0,0 @@
/*
* Created by Phil Nash on 4/5/2012
* Copyright 2012 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)
*/
#ifndef TWOBLUECUBES_CATCH_RUNNING_TEST_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_RUNNING_TEST_HPP_INCLUDED
#include "catch_test_case_info.h"
#include "catch_section_info.hpp"
namespace Catch {
class RunningTest {
enum RunStatus {
NothingRun,
EncounteredASection,
RanAtLeastOneSection,
RanToCompletionWithSections,
RanToCompletionWithNoSections
};
public:
explicit RunningTest( TestCase const& info )
: m_info( info ),
m_runStatus( RanAtLeastOneSection ),
m_rootSection( info.getTestCaseInfo().name ),
m_currentSection( &m_rootSection ),
m_changed( false )
{}
bool wasSectionSeen() const {
return m_runStatus == RanAtLeastOneSection ||
m_runStatus == RanToCompletionWithSections;
}
bool isBranchSection() const {
return m_currentSection &&
m_currentSection->isBranch();
}
bool hasSections() const {
return m_runStatus == RanAtLeastOneSection ||
m_runStatus == RanToCompletionWithSections ||
m_runStatus == EncounteredASection;
}
void reset() {
m_runStatus = NothingRun;
m_changed = false;
m_lastSectionToRun = NULL;
}
void ranToCompletion() {
if( m_runStatus != RanAtLeastOneSection && m_runStatus != EncounteredASection )
m_runStatus = RanToCompletionWithNoSections;
m_runStatus = RanToCompletionWithSections;
if( m_lastSectionToRun ) {
m_lastSectionToRun->ranToCompletion();
m_changed = true;
}
}
bool addSection( std::string const& name ) {
if( m_runStatus == NothingRun )
m_runStatus = EncounteredASection;
RunningSection* thisSection = m_currentSection->findOrAddSubSection( name, m_changed );
if( !wasSectionSeen() && thisSection->shouldRun() ) {
m_currentSection = thisSection;
m_lastSectionToRun = NULL;
return true;
}
return false;
}
void endSection( std::string const&, bool stealth ) {
if( m_currentSection->ran() ) {
if( !stealth )
m_runStatus = RanAtLeastOneSection;
m_changed = true;
}
else if( m_runStatus == EncounteredASection ) {
if( !stealth )
m_runStatus = RanAtLeastOneSection;
m_lastSectionToRun = m_currentSection;
}
m_currentSection = m_currentSection->getParent();
}
TestCase const& getTestCase() const {
return m_info;
}
bool hasUntestedSections() const {
return m_runStatus == RanAtLeastOneSection ||
( m_rootSection.hasUntestedSections() && m_changed );
}
private:
RunningTest( RunningTest const& );
void operator=( RunningTest const& );
TestCase const& m_info;
RunStatus m_runStatus;
RunningSection m_rootSection;
RunningSection* m_currentSection;
RunningSection* m_lastSectionToRun;
bool m_changed;
};
}
#endif // TWOBLUECUBES_CATCH_RUNNING_TEST_HPP_INCLUDED

View File

@ -156,7 +156,6 @@
4AB42F84166F3E1A0099F2C8 /* catch_reporter_console.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_console.hpp; sourceTree = "<group>"; };
4AB77CB51551AEA200857BF0 /* catch_ptr.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_ptr.hpp; sourceTree = "<group>"; };
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_section_info.hpp; sourceTree = "<group>"; };
4AB77CB81553BB3800857BF0 /* catch_running_test.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_running_test.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
4ABEA80415C90D2B009F0424 /* catch_objc_arc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_objc_arc.hpp; sourceTree = "<group>"; };
4AC91CCE155CF02800DC5117 /* catch_expression_lhs.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_expression_lhs.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
4AC91CD0155D8DA600DC5117 /* catch_expression_decomposer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_expression_decomposer.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
@ -376,7 +375,6 @@
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */,
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */,
4AB77CB81553BB3800857BF0 /* catch_running_test.hpp */,
4A084F1D15DAD15F0027E631 /* catch_test_spec.h */,
4A8E4DCC160A344100194CBD /* catch_tags.hpp */,
26948287179EF7F900ED166E /* catch_test_case_tracker.hpp */,