Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CompanionLib/FBIDBCommandExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ This enables the permission popup the first time we open a deeplink
*/
- (FBFuture<NSArray<NSString *> *> *)list_tests_in_bundle:(NSString *)bundleID with_app:(nullable NSString *)appPath;

/**
List the tests in an installed bundle using the file path of the bundle.

@return a Future that resolves with names of tests in the bundle.
*/
- (FBFuture<NSArray<NSString *> *> *)list_tests_in_bundle_file_path:(NSURL *)bundlePath;

/**
Uninstall an application

Expand Down
42 changes: 42 additions & 0 deletions CompanionLib/FBIDBCommandExecutor.m
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,48 @@ - (instancetype)initWithTarget:(id<FBiOSTarget>)target storageManager:(FBIDBStor
}];
}

- (FBFuture<NSArray<NSString *> *> *)list_tests_in_bundle_file_path:(nonnull NSURL *)bundlePath {
NSError *error = nil;
id<FBXCTestDescriptor> testDescriptor = nil;

if ([bundlePath.pathExtension isEqualToString:@"xctest"]) {
FBBundleDescriptor *bundle = [FBBundleDescriptor bundleWithFallbackIdentifierFromPath:bundlePath.path error:&error];

if (!bundle) {
return [FBFuture futureWithError:error];
}

testDescriptor = [[FBXCTestBootstrapDescriptor alloc] initWithURL:bundlePath name:bundle.name testBundle:bundle];
}
if ([bundlePath.pathExtension isEqualToString:@"xctestrun"]) {
NSArray<id<FBXCTestDescriptor>> *descriptors = [self.storageManager.xctest getXCTestRunDescriptorsFromURL:bundlePath error:&error];

if (!descriptors) {
return [FBFuture futureWithError:error];
}
if (descriptors.count != 1) {
return [[FBIDBError
describeFormat:@"Expected exactly one test in the xctestrun file, got: %lu", descriptors.count]
failFuture];
}

testDescriptor = descriptors[0];
}

if (!testDescriptor) {
return [FBFuture futureWithError:error];
}

id<FBXCTestExtendedCommands> commands = (id<FBXCTestExtendedCommands>) self.target;
if (![commands conformsToProtocol:@protocol(FBXCTestExtendedCommands)]) {
return [[FBIDBError
describeFormat:@"%@ does not conform to FBXCTestExtendedCommands", commands]
failFuture];
}

return [commands listTestsForBundleAtPath:testDescriptor.url.path timeout:ListTestBundleTimeout withAppAtPath:nil];
}

- (FBFuture<NSNull *> *)uninstall_application:(NSString *)bundleID
{
return [self.target uninstallApplicationWithBundleID:bundleID];
Expand Down