Skip to content

Commit

Permalink
Added coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jonreid committed Mar 25, 2012
1 parent 9f9c7ae commit e6d4f83
Show file tree
Hide file tree
Showing 24 changed files with 17,259 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,5 @@ build/
*.perspectivev3
xcuserdata/
Source/TestSupport/env.sh

Source/TestSupport/environment.sh
28 changes: 23 additions & 5 deletions Source/OCMockito.xcodeproj/project.pbxproj
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
08068ED21505A59700FA2D8F /* MKTTestLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 08068ED11505A59700FA2D8F /* MKTTestLocation.m */; };
08068ED31505A59700FA2D8F /* MKTTestLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 08068ED11505A59700FA2D8F /* MKTTestLocation.m */; };
080BFE2D151FE38900EC8721 /* libprofile_rt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 080BFE2C151FE38900EC8721 /* libprofile_rt.dylib */; };
080BFE39151FE46100EC8721 /* fixCoverage.c in Sources */ = {isa = PBXBuildFile; fileRef = 080BFE38151FE46100EC8721 /* fixCoverage.c */; };
0827E83D1352B1AE00C39A57 /* OCMockito.h in Headers */ = {isa = PBXBuildFile; fileRef = 0827E83313526E7300C39A57 /* OCMockito.h */; settings = {ATTRIBUTES = (Public, ); }; };
0827E83F1352B1C000C39A57 /* OCMockito.h in Headers */ = {isa = PBXBuildFile; fileRef = 0827E83313526E7300C39A57 /* OCMockito.h */; settings = {ATTRIBUTES = (Public, ); }; };
0827E8421352B6FC00C39A57 /* MKTMockitoCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 0827E8401352B6FC00C39A57 /* MKTMockitoCore.h */; };
Expand Down Expand Up @@ -150,6 +152,8 @@

/* Begin PBXFileReference section */
08068ED11505A59700FA2D8F /* MKTTestLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MKTTestLocation.m; sourceTree = "<group>"; };
080BFE2C151FE38900EC8721 /* libprofile_rt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libprofile_rt.dylib; path = usr/lib/libprofile_rt.dylib; sourceTree = DEVELOPER_DIR; };
080BFE38151FE46100EC8721 /* fixCoverage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fixCoverage.c; path = TestSupport/fixCoverage.c; sourceTree = "<group>"; };
0827E83313526E7300C39A57 /* OCMockito.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCMockito.h; sourceTree = "<group>"; };
0827E83413526E7300C39A57 /* OCMockito.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCMockito.m; sourceTree = "<group>"; };
0827E8401352B6FC00C39A57 /* MKTMockitoCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MKTMockitoCore.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -230,6 +234,7 @@
085D30071351254000EBBE91 /* libocmockito.a in Frameworks */,
08C61DB414E23938003D0843 /* SenTestingKit.framework in Frameworks */,
088475831509CF0E00A65050 /* OCHamcrestIOS.framework in Frameworks */,
080BFE2D151FE38900EC8721 /* libprofile_rt.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -286,6 +291,7 @@
08C61DB214E23938003D0843 /* SenTestingKit.framework */,
0884757E1509CEF700A65050 /* OCHamcrest.framework */,
088475811509CF0E00A65050 /* OCHamcrestIOS.framework */,
080BFE2C151FE38900EC8721 /* libprofile_rt.dylib */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -360,6 +366,7 @@
08BED07F1350DE4900CCBF76 /* OCMockito-Info.plist */,
08BED0801350DE4900CCBF76 /* OCMockito-Prefix.pch */,
08BED0811350DE4900CCBF76 /* Tests-Info.plist */,
080BFE38151FE46100EC8721 /* fixCoverage.c */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -606,6 +613,7 @@
08FD4B2D1509BEA90004E1FA /* MKTBaseMockObject.m in Sources */,
638F68DA150FC21A0081DEE6 /* MKTClassObjectMock.m in Sources */,
08E9DC261516738200BD7FB4 /* MKTObjectAndProtocolMock.m in Sources */,
080BFE39151FE46100EC8721 /* fixCoverage.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -703,14 +711,13 @@
GCC_PREFIX_HEADER = "OCMockito-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = 4.2;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lgcov";
SDKROOT = macosx;
WARNING_CFLAGS = (
"-Wmost",
Expand Down Expand Up @@ -788,11 +795,14 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Tests-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
);
OTHER_LDFLAGS = (
"-lstdc++",
"-ObjC",
"-all_load",
"-lgcov",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -849,6 +859,10 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Tests-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
);
OTHER_LDFLAGS = (
"-lstdc++",
"-ObjC",
Expand All @@ -873,6 +887,10 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Tests-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/usr/lib\"",
);
OTHER_LDFLAGS = (
"-lstdc++",
"-ObjC",
Expand All @@ -896,7 +914,7 @@
GCC_PREFIX_HEADER = "OCMockito-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -922,7 +940,7 @@
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMockito-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand Down
5 changes: 3 additions & 2 deletions Source/TestSupport/cleancov.sh
@@ -1,7 +1,8 @@
#!/bin/sh
source env.sh
source environment.sh

LCOV_PATH=${SRCROOT}/TestSupport/lcov-1.9/bin
OBJ_DIR=${OBJECT_FILE_DIR_normal}/${NATIVE_ARCH}

# Clean out the old data
lcov -d ${OBJ_DIR} --zerocounters
"${LCOV_PATH}/lcov" -d "${OBJ_DIR}" --zerocounters
2 changes: 1 addition & 1 deletion Source/TestSupport/exportenv.sh
@@ -1 +1 @@
export | egrep '( BUILT_PRODUCTS_DIR)|(NATIVE_ARCH=)|(OBJECT_FILE_DIR_normal)|(SRCROOT)' > TestSupport/env.sh
export | egrep '( BUILT_PRODUCTS_DIR)|(NATIVE_ARCH=)|(OBJECT_FILE_DIR_normal)|(SRCROOT)' > TestSupport/environment.sh
18 changes: 18 additions & 0 deletions Source/TestSupport/fixCoverage.c
@@ -0,0 +1,18 @@
// Include this source in your primary target (not your test bundle).
// http://www.infinite-loop.dk/blog/2012/02/code-coverage-and-fopen-unix2003-problems/

#include <stdio.h>

FILE *fopen$UNIX2003( const char *filename, const char *mode );
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d );


FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
return fopen(filename, mode);
}

size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
15 changes: 8 additions & 7 deletions Source/TestSupport/getcov.sh
@@ -1,7 +1,8 @@
#!/bin/bash
source env.sh
#!/bin/sh
source environment.sh

LCOV_INFO=OCMockito.info
LCOV_INFO=Coverage.info
LCOV_PATH=${SRCROOT}/TestSupport/lcov-1.9/bin
OBJ_DIR=${OBJECT_FILE_DIR_normal}/${NATIVE_ARCH}

# Remove old report
Expand All @@ -17,12 +18,12 @@ mkdir lcov
cd lcov

# Gather coverage data
lcov -d ${OBJ_DIR} --capture -o ${LCOV_INFO}
"${LCOV_PATH}/lcov" -d "${OBJ_DIR}" --capture -o ${LCOV_INFO}

# Exclude things we don't want to track
lcov -d ${OBJ_DIR} --remove ${LCOV_INFO} "/Developer/*" -o ${LCOV_INFO}
lcov -d ${OBJ_DIR} --remove ${LCOV_INFO} "/xcode_4.1_and_ios_sdk_4.3/*" -o ${LCOV_INFO}
"${LCOV_PATH}/lcov" -d "${OBJ_DIR}" --remove ${LCOV_INFO} "/xcode_4.2_and_ios_5_sdk_for_snow_leopard/*" -o ${LCOV_INFO}
"${LCOV_PATH}/lcov" -d "${OBJ_DIR}" --remove ${LCOV_INFO} "TestSupport/*" -o ${LCOV_INFO}

# Generate and display html
genhtml --output-directory . ${LCOV_INFO}
"${LCOV_PATH}/genhtml" --output-directory . ${LCOV_INFO}
open index.html

0 comments on commit e6d4f83

Please sign in to comment.