diff --git a/xctool/xctool-tests/OTestQueryTests.m b/xctool/xctool-tests/OTestQueryTests.m index a687c3ee7..32add472f 100644 --- a/xctool/xctool-tests/OTestQueryTests.m +++ b/xctool/xctool-tests/OTestQueryTests.m @@ -84,4 +84,16 @@ - (void)testQueryFailsWhenDYLDRejectsBundle_iOS assertThat(error, containsString(@"no suitable image found.")); } +- (void)testIOSAppTestQueryFailsWhenTestHostExecutableIsMissing +{ + NSString *error = nil; + NSString *latestSDK = GetAvailableSDKsAndAliases()[@"iphonesimulator"]; + NSArray *classes = OTestQueryTestCasesInIOSBundleWithTestHost(TEST_DATA @"otest-query-tests-ios-test-bundle/TestProject-LibraryTests.octest", + @"/path/to/executable/that/does/not/exist", + latestSDK, + &error); + assertThat(classes, equalTo(nil)); + assertThat(error, containsString(@"The test host executable is missing: '/path/to/executable/that/does/not/exist'")); +} + @end diff --git a/xctool/xctool/OTestQuery.m b/xctool/xctool/OTestQuery.m index 720653f83..c52654cea 100644 --- a/xctool/xctool/OTestQuery.m +++ b/xctool/xctool/OTestQuery.m @@ -75,6 +75,11 @@ { NSCAssert([sdk hasPrefix:@"iphonesimulator"], @"Only iphonesimulator SDKs are supported."); + if (![[NSFileManager defaultManager] isExecutableFileAtPath:testHostExecutablePath]) { + *error = [NSString stringWithFormat:@"The test host executable is missing: '%@'", testHostExecutablePath]; + return nil; + } + NSString *version = [sdk stringByReplacingOccurrencesOfString:@"iphonesimulator" withString:@""]; DTiPhoneSimulatorSystemRoot *systemRoot = [DTiPhoneSimulatorSystemRoot rootWithSDKVersion:version]; NSCAssert(systemRoot != nil, @"Cannot get systemRoot");