From 1e7c605f495d3c2c0fe075716e0c18cace02c53b Mon Sep 17 00:00:00 2001 From: Aleksey Kononov Date: Sun, 20 Sep 2015 00:06:58 -0700 Subject: [PATCH] Make compatable with xctool and Xcode 7 --- Bundle/GoogleTests.mm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Bundle/GoogleTests.mm b/Bundle/GoogleTests.mm index 069a123..52ac0d8 100644 --- a/Bundle/GoogleTests.mm +++ b/Bundle/GoogleTests.mm @@ -85,6 +85,7 @@ void OnTestPartResult(const TestPartResult& test_part_result) { * Google Test cases or individual tests via Xcode. */ @interface GoogleTestLoader : NSObject ++ (void)registerTestClasses; @end /** @@ -95,6 +96,11 @@ @interface GoogleTestCase : XCTestCase @implementation GoogleTestCase ++ (void)initialize +{ + [GoogleTestLoader registerTestClasses]; +} + /** * Associates generated Google Test classes with the test bundle. * @@ -172,11 +178,15 @@ @implementation GoogleTestLoader + (void)load { NSBundle *bundle = [NSBundle bundleForClass:self]; [[NSNotificationCenter defaultCenter] addObserverForName:NSBundleDidLoadNotification object:bundle queue:nil usingBlock:^(NSNotification *notification) { - [self registerTestClasses]; + [GoogleTestCase initialize]; }]; } + (void)registerTestClasses { + if ([GoogleTestFilterMap count]) { + return; + } + // Pass the command-line arguments to Google Test to support the --gtest options NSArray *arguments = [[NSProcessInfo processInfo] arguments]; @@ -241,6 +251,10 @@ + (void)registerTestClasses { methodName = [@"_" stringByAppendingString:methodName]; } + // Google Test set test method name in parameterized tests to /. + // Replace / with a _ to create a valid method name. + methodName = [methodName stringByReplacingOccurrencesOfString:@"/" withString:@"_"]; + NSString *testKey = [NSString stringWithFormat:@"%@.%@", className, methodName]; NSString *testFilter = [NSString stringWithFormat:@"%@.%@", testCaseName, testName]; testFilterMap[testKey] = testFilter;