aboutsummaryrefslogtreecommitdiff
path: root/UnitTesting
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2013-11-26 16:00:18 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2013-11-26 16:00:18 +0000
commit6ef81aa11edbc435f9ab1eb2c1d6f47b1a93fa46 (patch)
tree705d20a91da688ae42254fd867673730e5689b6b /UnitTesting
parentc17345207f7d1dedb291d63b90d182759f519679 (diff)
- Add gcov flushes that will happen within the test bundles to also capture
the coverage data there. Needed if you link some of your code directly into the test bundles or if you have code in headers (inlines, c++ templates, etc.) - Add a preprocessor gate to only bring in the coverage support when enabled, lets you add the source, and then use a Xcode Configuration to control when it is needed, otherwise you can end up linking coverage into your Release builds. DELTA=28 (28 added, 0 deleted, 0 changed)
Diffstat (limited to 'UnitTesting')
-rw-r--r--UnitTesting/GTMCodeCoverageApp.m6
-rw-r--r--UnitTesting/GTMCodeCoverageTestsST.m11
-rw-r--r--UnitTesting/GTMCodeCoverageTestsXC.m11
3 files changed, 28 insertions, 0 deletions
diff --git a/UnitTesting/GTMCodeCoverageApp.m b/UnitTesting/GTMCodeCoverageApp.m
index 3bc7fae..415d0c0 100644
--- a/UnitTesting/GTMCodeCoverageApp.m
+++ b/UnitTesting/GTMCodeCoverageApp.m
@@ -25,6 +25,10 @@
#import "GTMCodeCoverageApp.h"
+// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
+// Xcode Configuration that wants CodeCoverage support.
+#if GTM_IS_COVERAGE_BUILD
+
extern void __gcov_flush();
@implementation UIApplication(GTMCodeCoverage)
@@ -54,3 +58,5 @@ extern void __gcov_flush();
#endif // GTM_USING_XCTEST
@end
+
+#endif // GTM_IS_COVERAGE_BUILD
diff --git a/UnitTesting/GTMCodeCoverageTestsST.m b/UnitTesting/GTMCodeCoverageTestsST.m
index a73fdad..0159a53 100644
--- a/UnitTesting/GTMCodeCoverageTestsST.m
+++ b/UnitTesting/GTMCodeCoverageTestsST.m
@@ -28,6 +28,12 @@
#import "GTMCodeCoverageApp.h"
+// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
+// Xcode Configuration that wants CodeCoverage support.
+#if GTM_IS_COVERAGE_BUILD
+
+extern void __gcov_flush();
+
static int gSuiteCount = 0;
@interface GTMCodeCoverageTests : NSObject
@@ -63,7 +69,12 @@ static int gSuiteCount = 0;
if ([application respondsToSelector:@selector(gtm_gcov_flush)]) {
[application performSelector:@selector(gtm_gcov_flush)];
}
+
+ // Call flush for this executable unit.
+ __gcov_flush();
}
}
@end
+
+#endif // GTM_IS_COVERAGE_BUILD
diff --git a/UnitTesting/GTMCodeCoverageTestsXC.m b/UnitTesting/GTMCodeCoverageTestsXC.m
index 39e4850..b960c26 100644
--- a/UnitTesting/GTMCodeCoverageTestsXC.m
+++ b/UnitTesting/GTMCodeCoverageTestsXC.m
@@ -28,6 +28,12 @@
#import "GTMCodeCoverageApp.h"
+// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
+// Xcode Configuration that wants CodeCoverage support.
+#if GTM_IS_COVERAGE_BUILD
+
+extern void __gcov_flush();
+
@interface GTMCodeCoverageTests : XCTestObserver
@end
@@ -42,6 +48,9 @@
[application performSelector:@selector(gtm_gcov_flush)];
}
+ // Call flush for this executable unit.
+ __gcov_flush();
+
// Reset defaults back to what they should be.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:XCTestObserverClassKey];
@@ -70,3 +79,5 @@
}
@end
+
+#endif // GTM_IS_COVERAGE_BUILD