Ability to register line# for testing

Factored file/ line storage and formatting into common class.
Used in a static registry so failure messages can be asserted to have the file/ line in.
This commit is contained in:
Phil Nash
2012-02-15 08:20:06 +00:00
parent 8d24143827
commit 7b449f7abe
11 changed files with 418 additions and 40 deletions

View File

@@ -17,6 +17,7 @@
4A6D0C3D149B3D9E00DB3EAA /* MiscTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C34149B3D9E00DB3EAA /* MiscTests.cpp */; };
4A6D0C3E149B3D9E00DB3EAA /* TestMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C35149B3D9E00DB3EAA /* TestMain.cpp */; };
4A6D0C3F149B3D9E00DB3EAA /* TrickyTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C36149B3D9E00DB3EAA /* TrickyTests.cpp */; };
4A73282E14E9A6390044823F /* catch_self_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A73282D14E9A6390044823F /* catch_self_test.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -82,6 +83,7 @@
4A6D0C66149B3E3D00DB3EAA /* catch_reporter_basic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_basic.hpp; sourceTree = "<group>"; };
4A6D0C67149B3E3D00DB3EAA /* catch_reporter_junit.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_junit.hpp; sourceTree = "<group>"; };
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
4A73282D14E9A6390044823F /* catch_self_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catch_self_test.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -115,6 +117,8 @@
isa = PBXGroup;
children = (
4A6D0C35149B3D9E00DB3EAA /* TestMain.cpp */,
4A6D0C2E149B3D9E00DB3EAA /* catch_self_test.hpp */,
4A73282D14E9A6390044823F /* catch_self_test.cpp */,
4A6D0C40149B3DAB00DB3EAA /* Tests */,
4A6D0C41149B3DE900DB3EAA /* Catch */,
4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */,
@@ -143,7 +147,6 @@
4A6D0C44149B3E1500DB3EAA /* catch.hpp */,
4A6D0C42149B3E1500DB3EAA /* catch_runner.hpp */,
4A6D0C43149B3E1500DB3EAA /* catch_with_main.hpp */,
4A6D0C2E149B3D9E00DB3EAA /* catch_self_test.hpp */,
4A6D0C45149B3E3D00DB3EAA /* internal */,
4A6D0C65149B3E3D00DB3EAA /* reporters */,
);
@@ -259,6 +262,7 @@
4A6D0C3D149B3D9E00DB3EAA /* MiscTests.cpp in Sources */,
4A6D0C3E149B3D9E00DB3EAA /* TestMain.cpp in Sources */,
4A6D0C3F149B3D9E00DB3EAA /* TrickyTests.cpp in Sources */,
4A73282E14E9A6390044823F /* catch_self_test.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -343,6 +347,7 @@
4A6D0C2C149B3D3B00DB3EAA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};

View File

@@ -0,0 +1,42 @@
/*
* catch_self_test.cpp
* Catch
*
* 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
{
///////////////////////////////////////////////////////////////////////////
std::size_t EmbeddedRunner::runMatching
(
const std::string& rawTestSpec
)
{
std::ostringstream oss;
Config config;
config.setStreamBuf( oss.rdbuf() );
config.setReporter( "basic" );
std::size_t result;
// Scoped because Runner doesn't report EndTesting until its destructor
{
Runner runner( config );
result = runner.runMatching( rawTestSpec );
m_successes = runner.getSuccessCount();
m_failures = runner.getFailureCount();
}
m_output = oss.str();
return result;
}
}

View File

@@ -0,0 +1,263 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
4A73280A14E66CFC0044823F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A73280914E66CFC0044823F /* UIKit.framework */; };
4A73280C14E66CFC0044823F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A73280B14E66CFC0044823F /* Foundation.framework */; };
4A73280E14E66CFC0044823F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A73280D14E66CFC0044823F /* CoreGraphics.framework */; };
4A73281414E66CFC0044823F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4A73281214E66CFC0044823F /* InfoPlist.strings */; };
4A73281614E66CFC0044823F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A73281514E66CFC0044823F /* main.m */; };
4A73281A14E66CFC0044823F /* TBCAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A73281914E66CFC0044823F /* TBCAppDelegate.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
4A73280514E66CFC0044823F /* iOSTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
4A73280914E66CFC0044823F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4A73280B14E66CFC0044823F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
4A73280D14E66CFC0044823F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
4A73281114E66CFC0044823F /* iOSTest-Info.plist */ = {isa = PBXFileReference; path = "iOSTest-Info.plist"; sourceTree = "<group>"; };
4A73281314E66CFC0044823F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4A73281514E66CFC0044823F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4A73281714E66CFC0044823F /* iOSTest-Prefix.pch */ = {isa = PBXFileReference; path = "iOSTest-Prefix.pch"; sourceTree = "<group>"; };
4A73281814E66CFC0044823F /* TBCAppDelegate.h */ = {isa = PBXFileReference; path = TBCAppDelegate.h; sourceTree = "<group>"; };
4A73281914E66CFC0044823F /* TBCAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TBCAppDelegate.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4A73280214E66CFC0044823F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4A73280A14E66CFC0044823F /* UIKit.framework in Frameworks */,
4A73280C14E66CFC0044823F /* Foundation.framework in Frameworks */,
4A73280E14E66CFC0044823F /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4A7327FA14E66CFC0044823F = {
isa = PBXGroup;
children = (
4A73280F14E66CFC0044823F /* iOSTest */,
4A73280814E66CFC0044823F /* Frameworks */,
4A73280614E66CFC0044823F /* Products */,
);
sourceTree = "<group>";
};
4A73280614E66CFC0044823F /* Products */ = {
isa = PBXGroup;
children = (
4A73280514E66CFC0044823F /* iOSTest.app */,
);
name = Products;
sourceTree = "<group>";
};
4A73280814E66CFC0044823F /* Frameworks */ = {
isa = PBXGroup;
children = (
4A73280914E66CFC0044823F /* UIKit.framework */,
4A73280B14E66CFC0044823F /* Foundation.framework */,
4A73280D14E66CFC0044823F /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
4A73280F14E66CFC0044823F /* iOSTest */ = {
isa = PBXGroup;
children = (
4A73281814E66CFC0044823F /* TBCAppDelegate.h */,
4A73281914E66CFC0044823F /* TBCAppDelegate.m */,
4A73281014E66CFC0044823F /* Supporting Files */,
);
path = iOSTest;
sourceTree = "<group>";
};
4A73281014E66CFC0044823F /* Supporting Files */ = {
isa = PBXGroup;
children = (
4A73281114E66CFC0044823F /* iOSTest-Info.plist */,
4A73281214E66CFC0044823F /* InfoPlist.strings */,
4A73281514E66CFC0044823F /* main.m */,
4A73281714E66CFC0044823F /* iOSTest-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
4A73280414E66CFC0044823F /* iOSTest */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4A73281D14E66CFC0044823F /* Build configuration list for PBXNativeTarget "iOSTest" */;
buildPhases = (
4A73280114E66CFC0044823F /* Sources */,
4A73280214E66CFC0044823F /* Frameworks */,
4A73280314E66CFC0044823F /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = iOSTest;
productName = iOSTest;
productReference = 4A73280514E66CFC0044823F /* iOSTest.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
4A7327FC14E66CFC0044823F /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0420;
};
buildConfigurationList = 4A7327FF14E66CFC0044823F /* Build configuration list for PBXProject "iOSTest" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 4A7327FA14E66CFC0044823F;
productRefGroup = 4A73280614E66CFC0044823F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
4A73280414E66CFC0044823F /* iOSTest */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
4A73280314E66CFC0044823F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4A73281414E66CFC0044823F /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
4A73280114E66CFC0044823F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4A73281614E66CFC0044823F /* main.m in Sources */,
4A73281A14E66CFC0044823F /* TBCAppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
4A73281214E66CFC0044823F /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
4A73281314E66CFC0044823F /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
4A73281B14E66CFC0044823F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
4A73281C14E66CFC0044823F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
4A73281E14E66CFC0044823F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "iOSTest/iOSTest-Prefix.pch";
INFOPLIST_FILE = "iOSTest/iOSTest-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
4A73281F14E66CFC0044823F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "iOSTest/iOSTest-Prefix.pch";
INFOPLIST_FILE = "iOSTest/iOSTest-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
4A7327FF14E66CFC0044823F /* Build configuration list for PBXProject "iOSTest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4A73281B14E66CFC0044823F /* Debug */,
4A73281C14E66CFC0044823F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4A73281D14E66CFC0044823F /* Build configuration list for PBXNativeTarget "iOSTest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4A73281E14E66CFC0044823F /* Debug */,
4A73281F14E66CFC0044823F /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 4A7327FC14E66CFC0044823F /* Project object */;
}