diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2015-09-08 11:55:22 -0400 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2015-09-08 11:55:22 -0400 |
commit | 6df21e0bf547d2193e14ad861db8455bc4e9d4e8 (patch) | |
tree | f50d825f4ee0384f0605733e3288c1b2eb15c065 /UnitTesting | |
parent | b631ec80abb5ce8f081bb883d432676c4ad957c0 (diff) |
Relay the real argc/argv to testing::InitGoogleTest
Diffstat (limited to 'UnitTesting')
-rw-r--r-- | UnitTesting/GTMGoogleTestRunner.mm | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/UnitTesting/GTMGoogleTestRunner.mm b/UnitTesting/GTMGoogleTestRunner.mm index 494a073..0bcb500 100644 --- a/UnitTesting/GTMGoogleTestRunner.mm +++ b/UnitTesting/GTMGoogleTestRunner.mm @@ -137,12 +137,23 @@ NSString *SelectorNameFromGTestName(NSString *testName) { @implementation GTMGoogleTestRunner -+ (id)defaultTestSuite { - int argc = 0; - char *argv = NULL; ++ (void)initGoogleTest { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSArray *arguments = [NSProcessInfo processInfo].arguments; + int argc = (int)arguments.count; + char **argv = static_cast<char **>(alloca((sizeof(char *) * (argc + 1)))); + for (int index = 0; index < argc; index++) { + argv[index] = const_cast<char *> ([arguments[index] UTF8String]); + } + argv[argc] = NULL; - // Initialize GoogleTest with no values. - testing::InitGoogleTest(&argc, &argv); + testing::InitGoogleTest(&argc, argv); + }); +} + ++ (id)defaultTestSuite { + [GTMGoogleTestRunner initGoogleTest]; SenTestSuite *result = [[SenTestSuite alloc] initWithName:NSStringFromClass(self)]; UnitTest *test = UnitTest::GetInstance(); @@ -198,10 +209,7 @@ NSString *SelectorNameFromGTestName(NSString *testName) { } - (void)runGoogleTest { - // Initialize GoogleTest with no values. - int argc = 0; - char *argv = NULL; - testing::InitGoogleTest(&argc, &argv); + [GTMGoogleTestRunner initGoogleTest]; // Gets hold of the event listener list. TestEventListeners& listeners = UnitTest::GetInstance()->listeners(); |