Skip to content

Commit fdcbe3b

Browse files
authored
Googletest - Xcode integration improvements (#7005)
* Fixed use of deprecated unarchiveObjectWithFile method * FSTGoogleTestTests - added support for skipping tests
1 parent 739d21a commit fdcbe3b

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

Firestore/core/test/unit/FSTGoogleTestTests.mm

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,27 @@ @interface GoogleTests : XCTestCase
8282
return nil;
8383
}
8484

85-
id config = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
85+
id config;
86+
NSError* error;
87+
if (@available(macOS 10.13, iOS 11, tvOS 11, *)) {
88+
NSData* data = [NSData dataWithContentsOfFile:filePath
89+
options:kNilOptions
90+
error:&error];
91+
if (!data) {
92+
NSLog(@"Failed to fill data with contents of file. %@", error);
93+
return nil;
94+
}
95+
96+
config = [NSKeyedUnarchiver unarchivedObjectOfClass:NSObject.class
97+
fromData:data
98+
error:&error];
99+
} else {
100+
config = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
101+
}
102+
86103
if (!config) {
87-
NSLog(@"Failed to load any configuaration from %@=%@", configEnvVar,
88-
filePath);
104+
NSLog(@"Failed to load any configuaration from %@=%@. %@", configEnvVar,
105+
filePath, error);
89106
return nil;
90107
}
91108

@@ -214,6 +231,13 @@ void XCTestMethod(XCTestCase* self, SEL _cmd) {
214231
// Let XCode know that the test ran and succeeded.
215232
XCTAssertTrue(true);
216233
return;
234+
} else if (result->Skipped()) {
235+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130400 || \
236+
__TV_OS_VERSION_MAX_ALLOWED >= 130400 || \
237+
__MAC_OS_X_VERSION_MAX_ALLOWED >= 101504
238+
// Let XCode know that the test was skipped.
239+
XCTSkip();
240+
#endif
217241
}
218242

219243
// Test failed :-(. Record the failure such that XCode will navigate directly

0 commit comments

Comments
 (0)