Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
show friendly error if test bundle does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpotter committed Aug 29, 2013
1 parent a8b5a90 commit 6f3bebf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions xctool/xctool/OTestQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,27 @@
}
}

static BOOL SetErrorIfBundleDoesNotExist(NSString *bundlePath, NSString **error)
{
BOOL isDir = NO;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:bundlePath isDirectory:&isDir];

if (!IsRunningUnderTest() && !(exists && isDir)) {
*error = [NSString stringWithFormat:@"Test bundle not found at: %@", bundlePath];
return YES;
} else {
return NO;
}
}

NSArray *OTestQueryTestCasesInIOSBundle(NSString *bundlePath, NSString *sdk, NSString **error)
{
NSCAssert([sdk hasPrefix:@"iphonesimulator"], @"Only iphonesimulator SDKs are supported.");

if (SetErrorIfBundleDoesNotExist(bundlePath, error)) {
return nil;
}

NSString *version = [sdk stringByReplacingOccurrencesOfString:@"iphonesimulator" withString:@""];
DTiPhoneSimulatorSystemRoot *systemRoot = [DTiPhoneSimulatorSystemRoot rootWithSDKVersion:version];
NSCAssert(systemRoot != nil, @"Cannot get systemRoot");
Expand All @@ -75,6 +92,10 @@
{
NSCAssert([sdk hasPrefix:@"iphonesimulator"], @"Only iphonesimulator SDKs are supported.");

if (SetErrorIfBundleDoesNotExist(bundlePath, error)) {
return nil;
}

if (![[NSFileManager defaultManager] isExecutableFileAtPath:testHostExecutablePath]) {
*error = [NSString stringWithFormat:@"The test host executable is missing: '%@'", testHostExecutablePath];
return nil;
Expand Down Expand Up @@ -109,6 +130,10 @@

NSArray *OTestQueryTestCasesInOSXBundle(NSString *bundlePath, NSString *builtProductsDir, BOOL disableGC, NSString **error)
{
if (SetErrorIfBundleDoesNotExist(bundlePath, error)) {
return nil;
}

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:[XCToolLibExecPath() stringByAppendingPathComponent:@"otest-query-osx"]];
[task setArguments:@[bundlePath]];
Expand Down

0 comments on commit 6f3bebf

Please sign in to comment.