mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Removed redundant MetaTestRunner
This commit is contained in:
parent
200197f0b2
commit
ca7292e3a7
@ -11,8 +11,6 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "catch_self_test.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
inline int thisThrows()
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "catch.hpp"
|
||||
#include "catch_self_test.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -5,22 +5,21 @@
|
||||
* 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)
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
#include "catch_self_test.hpp"
|
||||
#include "internal/catch_text.h"
|
||||
#include "internal/catch_console_colour.hpp"
|
||||
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#endif
|
||||
|
||||
#include "../../include/internal/catch_commandline.hpp"
|
||||
#include "../../include/internal/catch_test_spec.h"
|
||||
#include "../../include/reporters/catch_reporter_xml.hpp"
|
||||
#include "internal/catch_text.h"
|
||||
#include "internal/catch_console_colour.hpp"
|
||||
#include "internal/catch_commandline.hpp"
|
||||
#include "internal/catch_test_spec.h"
|
||||
|
||||
#include "reporters/catch_reporter_xml.hpp"
|
||||
|
||||
template<size_t size>
|
||||
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Created by Phil on 14/02/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)
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch_self_test.hpp"
|
||||
|
||||
namespace Catch{
|
||||
|
||||
NullStreamingReporter::~NullStreamingReporter() {}
|
||||
|
||||
Totals EmbeddedRunner::runMatching( const std::string& rawTestSpec, std::size_t groupIndex, std::size_t groupsCount, const std::string& ) {
|
||||
std::ostringstream oss;
|
||||
Ptr<Config> config = new Config();
|
||||
config->setStreamBuf( oss.rdbuf() );
|
||||
|
||||
Totals totals;
|
||||
|
||||
// Scoped because RunContext doesn't report EndTesting until its destructor
|
||||
{
|
||||
RunContext runner( config.get(), m_reporter.get() );
|
||||
totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount );
|
||||
}
|
||||
return totals;
|
||||
}
|
||||
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Created by Phil on 14/01/2011.
|
||||
* 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)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
// Use this external guard here as if we're using the single header version
|
||||
// this will already be defined
|
||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||
#include "catch_interfaces_registry_hub.h"
|
||||
#endif
|
||||
|
||||
#include "set"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class NullStreamingReporter : public SharedImpl<IStreamingReporter> {
|
||||
public:
|
||||
|
||||
virtual ~NullStreamingReporter();
|
||||
|
||||
static std::string getDescription() {
|
||||
return "null reporter";
|
||||
}
|
||||
|
||||
private: // IStreamingReporter
|
||||
|
||||
virtual ReporterPreferences getPreferences() const {
|
||||
return ReporterPreferences();
|
||||
}
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& ) {}
|
||||
virtual void testRunStarting( TestRunInfo const& ) {}
|
||||
virtual void testGroupStarting( GroupInfo const& ) {}
|
||||
virtual void testCaseStarting( TestCaseInfo const& ) {}
|
||||
virtual void sectionStarting( SectionInfo const& ) {}
|
||||
virtual void assertionStarting( AssertionInfo const& ) {}
|
||||
virtual bool assertionEnded( AssertionStats const& ) { return false; }
|
||||
virtual void sectionEnded( SectionStats const& ) {}
|
||||
virtual void testCaseEnded( TestCaseStats const& ) {}
|
||||
virtual void testGroupEnded( TestGroupStats const& ) {}
|
||||
virtual void testRunEnded( TestRunStats const& ) {}
|
||||
};
|
||||
|
||||
class EmbeddedRunner {
|
||||
|
||||
public:
|
||||
EmbeddedRunner() : m_reporter( new NullStreamingReporter() ) {}
|
||||
|
||||
Totals runMatching( const std::string& rawTestSpec,
|
||||
std::size_t groupIndex,
|
||||
std::size_t groupsCount,
|
||||
const std::string& reporter = "console" );
|
||||
|
||||
private:
|
||||
Ptr<IStreamingReporter> m_reporter;
|
||||
};
|
||||
|
||||
class MetaTestRunner {
|
||||
|
||||
public:
|
||||
struct Expected { enum Result {
|
||||
ToSucceed,
|
||||
ToFail
|
||||
}; };
|
||||
|
||||
MetaTestRunner( Expected::Result expectedResult, std::size_t groupIndex, std::size_t groupsCount )
|
||||
: m_expectedResult( expectedResult ),
|
||||
m_groupIndex( groupIndex ),
|
||||
m_groupsCount( groupsCount )
|
||||
{}
|
||||
|
||||
static void runMatching( const std::string& testSpec,
|
||||
Expected::Result expectedResult,
|
||||
std::size_t groupIndex,
|
||||
std::size_t groupsCount ) {
|
||||
forEach( getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec ),
|
||||
MetaTestRunner( expectedResult, groupIndex, groupsCount ) );
|
||||
}
|
||||
|
||||
void operator()( const TestCase& testCase ) {
|
||||
std::string name;
|
||||
Totals totals;
|
||||
{
|
||||
EmbeddedRunner runner;
|
||||
name = testCase.getTestCaseInfo().name;
|
||||
totals = runner.runMatching( name, m_groupIndex, m_groupsCount );
|
||||
}
|
||||
switch( m_expectedResult ) {
|
||||
case Expected::ToSucceed:
|
||||
if( totals.assertions.failed > 0 ) {
|
||||
FAIL( "Expected test case '"
|
||||
<< name
|
||||
<< "' to succeed but there was/ were "
|
||||
<< totals.assertions.failed << " failure(s)" );
|
||||
}
|
||||
else {
|
||||
SUCCEED( "Tests passed, as expected" );
|
||||
}
|
||||
break;
|
||||
case Expected::ToFail:
|
||||
if( totals.assertions.failed == 0 ) {
|
||||
FAIL( "Expected test case '"
|
||||
<< name
|
||||
<< "' to fail but there was/ were "
|
||||
<< totals.assertions.passed << " success(es)" );
|
||||
}
|
||||
else {
|
||||
SUCCEED( "Tests failed, as expected" );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Expected::Result m_expectedResult;
|
||||
std::size_t m_groupIndex;
|
||||
std::size_t m_groupsCount;
|
||||
};
|
||||
|
||||
|
||||
struct LineInfoRegistry {
|
||||
|
||||
static LineInfoRegistry& get() {
|
||||
static LineInfoRegistry s_instance;
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
void registerLineInfo( const std::string& name,
|
||||
const SourceLineInfo& info ) {
|
||||
m_registry.insert( std::make_pair( name, info ) );
|
||||
}
|
||||
|
||||
const SourceLineInfo* find( const std::string& name ) const {
|
||||
std::map<std::string, SourceLineInfo>::const_iterator it = m_registry.find( name );
|
||||
return it == m_registry.end() ? NULL : &(it->second);
|
||||
}
|
||||
|
||||
const std::string infoForName( const std::string& name ) const {
|
||||
std::map<std::string, SourceLineInfo>::const_iterator it = m_registry.find( name );
|
||||
if( it == m_registry.end() )
|
||||
return "";
|
||||
std::ostringstream oss;
|
||||
oss << it->second;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::map<std::string, SourceLineInfo> m_registry;
|
||||
};
|
||||
|
||||
struct LineInfoRegistrar {
|
||||
LineInfoRegistrar( const char* name, const SourceLineInfo& lineInfo ) {
|
||||
LineInfoRegistry::get().registerLineInfo( name, lineInfo );
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define CATCH_REGISTER_LINE_INFO( name ) ::Catch::LineInfoRegistrar INTERNAL_CATCH_UNIQUE_NAME( lineRegistrar )( name, ::Catch::SourceLineInfo( __FILE__, __LINE__ ) );
|
||||
#define CATCH_GET_LINE_INFO( name ) ::Catch::LineInfoRegistry::get().infoForName( name )
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED
|
@ -1,33 +0,0 @@
|
||||
========================================================================
|
||||
CONSOLE APPLICATION : TestCatch Project Overview
|
||||
========================================================================
|
||||
|
||||
AppWizard has created this TestCatch application for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your TestCatch application.
|
||||
|
||||
|
||||
TestCatch.vcproj
|
||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the version of Visual C++ that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
TestCatch.cpp
|
||||
This is the main application source file.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other standard files:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
These files are used to build a precompiled header (PCH) file
|
||||
named TestCatch.pch and a precompiled types file named StdAfx.obj.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other notes:
|
||||
|
||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
||||
should add to or customize.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -296,10 +296,6 @@
|
||||
RelativePath="..\..\..\..\include\internal\catch_section.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\include\internal\catch_self_test.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\include\internal\catch_stream.hpp"
|
||||
>
|
||||
@ -351,10 +347,6 @@
|
||||
RelativePath="..\..\..\SelfTest\BDDTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\SelfTest\catch_self_test.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\SelfTest\ClassTests.cpp"
|
||||
>
|
||||
@ -396,10 +388,6 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
@ -1,8 +0,0 @@
|
||||
// TestCatch.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,7 +96,6 @@
|
||||
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp" />
|
||||
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
|
||||
<ClCompile Include="..\..\..\SelfTest\catch_self_test.cpp" />
|
||||
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
|
||||
<ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp" />
|
||||
<ClCompile Include="..\..\..\SelfTest\ExceptionTests.cpp" />
|
||||
@ -135,7 +134,6 @@
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_resultinfo.hpp" />
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_runner_impl.hpp" />
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_section.hpp" />
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_self_test.hpp" />
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_stream.hpp" />
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_info.hpp" />
|
||||
<ClInclude Include="..\..\..\..\include\internal\catch_test_case_registry_impl.hpp" />
|
||||
|
@ -36,7 +36,6 @@
|
||||
4AB3D9A01616219100C9A0F8 /* catch_interfaces_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AB3D99F1616219100C9A0F8 /* catch_interfaces_config.cpp */; };
|
||||
4AB3D9A2161621B500C9A0F8 /* catch_interfaces_generators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AB3D9A1161621B500C9A0F8 /* catch_interfaces_generators.cpp */; };
|
||||
4ACE21CC166CA1B300FB5509 /* catch_option.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ACE21CA166CA1B300FB5509 /* catch_option.cpp */; };
|
||||
4AE1840B14EE4F230066340D /* catch_self_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AE1840A14EE4F230066340D /* catch_self_test.cpp */; };
|
||||
4AEE032016142F910071E950 /* catch_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AEE031F16142F910071E950 /* catch_common.cpp */; };
|
||||
4AEE032316142FC70071E950 /* catch_debugger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AEE032216142FC70071E950 /* catch_debugger.cpp */; };
|
||||
4AEE032516142FF10071E950 /* catch_stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AEE032416142FF10071E950 /* catch_stream.cpp */; };
|
||||
@ -95,7 +94,6 @@
|
||||
4A6D0C20149B3D3B00DB3EAA /* CatchSelfTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CatchSelfTest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = CatchSelfTest.1; sourceTree = "<group>"; };
|
||||
4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ApproxTests.cpp; path = ../../../SelfTest/ApproxTests.cpp; sourceTree = "<group>"; };
|
||||
4A6D0C2E149B3D9E00DB3EAA /* catch_self_test.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = catch_self_test.hpp; path = ../../../SelfTest/catch_self_test.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C2F149B3D9E00DB3EAA /* ClassTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClassTests.cpp; path = ../../../SelfTest/ClassTests.cpp; sourceTree = "<group>"; };
|
||||
4A6D0C30149B3D9E00DB3EAA /* ConditionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConditionTests.cpp; path = ../../../SelfTest/ConditionTests.cpp; sourceTree = "<group>"; };
|
||||
4A6D0C31149B3D9E00DB3EAA /* ExceptionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExceptionTests.cpp; path = ../../../SelfTest/ExceptionTests.cpp; sourceTree = "<group>"; };
|
||||
@ -163,7 +161,6 @@
|
||||
4AC91CD0155D8DA600DC5117 /* catch_expression_decomposer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_expression_decomposer.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
4ACE21C8166CA19700FB5509 /* catch_option.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_option.hpp; sourceTree = "<group>"; };
|
||||
4ACE21CA166CA1B300FB5509 /* catch_option.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_option.cpp; path = ../../../SelfTest/SurrogateCpps/catch_option.cpp; sourceTree = "<group>"; };
|
||||
4AE1840A14EE4F230066340D /* catch_self_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_self_test.cpp; path = ../../../SelfTest/catch_self_test.cpp; sourceTree = "<group>"; };
|
||||
4AEE031F16142F910071E950 /* catch_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_common.cpp; path = ../../../SelfTest/SurrogateCpps/catch_common.cpp; sourceTree = "<group>"; };
|
||||
4AEE032216142FC70071E950 /* catch_debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_debugger.cpp; path = ../../../SelfTest/SurrogateCpps/catch_debugger.cpp; sourceTree = "<group>"; };
|
||||
4AEE032416142FF10071E950 /* catch_stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_stream.cpp; path = ../../../SelfTest/SurrogateCpps/catch_stream.cpp; sourceTree = "<group>"; };
|
||||
@ -220,8 +217,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4A6D0C35149B3D9E00DB3EAA /* TestMain.cpp */,
|
||||
4A6D0C2E149B3D9E00DB3EAA /* catch_self_test.hpp */,
|
||||
4AE1840A14EE4F230066340D /* catch_self_test.cpp */,
|
||||
266E9AD317290E710061DAB2 /* Introspective Tests */,
|
||||
4A6D0C40149B3DAB00DB3EAA /* Tests */,
|
||||
4A6D0C41149B3DE900DB3EAA /* Catch */,
|
||||
@ -499,7 +494,6 @@
|
||||
4A6D0C3D149B3D9E00DB3EAA /* MiscTests.cpp in Sources */,
|
||||
4A6D0C3E149B3D9E00DB3EAA /* TestMain.cpp in Sources */,
|
||||
4A6D0C3F149B3D9E00DB3EAA /* TrickyTests.cpp in Sources */,
|
||||
4AE1840B14EE4F230066340D /* catch_self_test.cpp in Sources */,
|
||||
4A8E4DD2160A352200194CBD /* catch_tags.cpp in Sources */,
|
||||
4AEE032016142F910071E950 /* catch_common.cpp in Sources */,
|
||||
4AEE032316142FC70071E950 /* catch_debugger.cpp in Sources */,
|
||||
|
Loading…
Reference in New Issue
Block a user