Skip to content

Commit

Permalink
Remove shim passing from above in idb
Browse files Browse the repository at this point in the history
Summary: This no longer needs to be passed since it's fetched internally. This also no longer needs to be fetched within idb itself.

Reviewed By: jamescoggan

Differential Revision: D29518464

fbshipit-source-id: 59d6695f358dae9a672b5c9135c6217528ace712
  • Loading branch information
lawrencelomax authored and facebook-github-bot committed Jul 8, 2021
1 parent ec1d271 commit c9171bb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 75 deletions.
5 changes: 2 additions & 3 deletions FBControlCore/Configuration/FBXCTraceConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ - (instancetype)withShim:(FBXCTestShimConfiguration *)shim
- (NSString *)description
{
return [NSString stringWithFormat:
@"xctrace record: template %@ | duration %f | process to launch %@ | process to attach %@ | package %@ | target stdin %@ | target stdout %@ | target arguments %@ | target environment %@ | record all processes %@ | shim %@",
@"xctrace record: template %@ | duration %f | process to launch %@ | process to attach %@ | package %@ | target stdin %@ | target stdout %@ | target arguments %@ | target environment %@ | record all processes %@",
self.templateName,
self.timeLimit,
self.processToLaunch,
Expand All @@ -90,8 +90,7 @@ - (NSString *)description
self.targetStdout,
[FBCollectionInformation oneLineDescriptionFromArray:self.launchArgs],
[FBCollectionInformation oneLineDescriptionFromDictionary:self.processEnv],
self.allProcesses ? @"Yes" : @"No",
self.shim
self.allProcesses ? @"Yes" : @"No"
];
}

Expand Down
3 changes: 1 addition & 2 deletions idb_companion/Utility/FBXCTestDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,11 @@ The Initializer for UI Tests.
@param request the xctest run request
@param testApps the materialized Applications that are used as a part of testing.
@param shims the shims to use for relevant test runs
@param logger the logger to log to
@param queue the queue to be used for async operations
@return a Future wrapping the test launch configuration if constructed successfully or an error.
*/
- (FBFuture<FBTestLaunchConfiguration *> *)testConfigWithRunRequest:(FBXCTestRunRequest *)request testApps:(FBTestApplicationsPair *)testApps shims:(nullable FBXCTestShimConfiguration *)shims logger:(id<FBControlCoreLogger>)logger queue:(dispatch_queue_t)queue;
- (FBFuture<FBTestLaunchConfiguration *> *)testConfigWithRunRequest:(FBXCTestRunRequest *)request testApps:(FBTestApplicationsPair *)testApps logger:(id<FBControlCoreLogger>)logger queue:(dispatch_queue_t)queue;

/**
Obtains the Test Application Components for the provided target and request
Expand Down
131 changes: 61 additions & 70 deletions idb_companion/Utility/FBXCTestDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,62 +125,58 @@ - (BOOL)isUITest

- (FBFuture<FBIDBTestOperation *> *)startWithTestDescriptor:(id<FBXCTestDescriptor>)testDescriptor target:(id<FBiOSTarget>)target reporter:(id<FBXCTestReporter, FBXCTestReporterWithFiles>)reporter logger:(id<FBControlCoreLogger>)logger temporaryDirectory:(FBTemporaryDirectory *)temporaryDirectory
{
return [[FBXCTestShimConfiguration
defaultShimConfigurationWithLogger:logger]
onQueue:target.workQueue fmap:^ FBFuture<FBIDBTestOperation *> * (FBXCTestShimConfiguration *shims) {
NSError *error = nil;
NSURL *workingDirectory = [temporaryDirectory ephemeralTemporaryDirectory];
if (![NSFileManager.defaultManager createDirectoryAtURL:workingDirectory withIntermediateDirectories:YES attributes:nil error:&error]) {
return [FBFuture futureWithError:error];
}
NSError *error = nil;
NSURL *workingDirectory = [temporaryDirectory ephemeralTemporaryDirectory];
if (![NSFileManager.defaultManager createDirectoryAtURL:workingDirectory withIntermediateDirectories:YES attributes:nil error:&error]) {
return [FBFuture futureWithError:error];
}

NSString *logDirectoryPath = nil;
if (self.collectLogs) {
NSURL *dir = [temporaryDirectory ephemeralTemporaryDirectory];
if (![NSFileManager.defaultManager createDirectoryAtURL:dir withIntermediateDirectories:YES attributes:nil error:&error]) {
return [FBFuture futureWithError:error];
}
logDirectoryPath = dir.path;
[reporter setLogDirectoryPath:logDirectoryPath];
}
NSString *logDirectoryPath = nil;
if (self.collectLogs) {
NSURL *dir = [temporaryDirectory ephemeralTemporaryDirectory];
if (![NSFileManager.defaultManager createDirectoryAtURL:dir withIntermediateDirectories:YES attributes:nil error:&error]) {
return [FBFuture futureWithError:error];
}
logDirectoryPath = dir.path;
[reporter setLogDirectoryPath:logDirectoryPath];
}

NSString *coveragePath = nil;
if (self.collectCoverage) {
NSURL *dir = [temporaryDirectory ephemeralTemporaryDirectory];
NSString *coverageFileName = [NSString stringWithFormat:@"coverage_%@.profraw", NSUUID.UUID.UUIDString];
coveragePath = [dir.path stringByAppendingPathComponent:coverageFileName];
}
NSString *coveragePath = nil;
if (self.collectCoverage) {
NSURL *dir = [temporaryDirectory ephemeralTemporaryDirectory];
NSString *coverageFileName = [NSString stringWithFormat:@"coverage_%@.profraw", NSUUID.UUID.UUIDString];
coveragePath = [dir.path stringByAppendingPathComponent:coverageFileName];
}

NSString *testFilter = nil;
NSArray<NSString *> *testsToSkip = self.testsToSkip.allObjects ?: @[];
if (testsToSkip.count > 0) {
return [[FBXCTestError
describeFormat:@"'Tests to Skip' %@ provided, but Logic Tests to not support this.", [FBCollectionInformation oneLineDescriptionFromArray:testsToSkip]]
failFuture];
}
NSArray<NSString *> *testsToRun = self.testsToRun.allObjects ?: @[];
if (testsToRun.count > 1){
return [[FBXCTestError
describeFormat:@"More than one 'Tests to Run' %@ provided, but only one 'Tests to Run' is supported.", [FBCollectionInformation oneLineDescriptionFromArray:testsToRun]]
failFuture];
}
testFilter = testsToRun.firstObject;

NSTimeInterval timeout = self.testTimeout.boolValue ? self.testTimeout.doubleValue : FBLogicTestTimeout;
FBLogicTestConfiguration *configuration = [FBLogicTestConfiguration
configurationWithEnvironment:self.environment
workingDirectory:workingDirectory.path
testBundlePath:testDescriptor.testBundle.path
waitForDebugger:self.waitForDebugger
timeout:timeout
testFilter:testFilter
mirroring:FBLogicTestMirrorFileLogs
coveragePath:coveragePath
binaryPath:testDescriptor.testBundle.binary.path
logDirectoryPath:logDirectoryPath];

return [self startTestExecution:configuration target:target reporter:reporter logger:logger];
}];
NSString *testFilter = nil;
NSArray<NSString *> *testsToSkip = self.testsToSkip.allObjects ?: @[];
if (testsToSkip.count > 0) {
return [[FBXCTestError
describeFormat:@"'Tests to Skip' %@ provided, but Logic Tests to not support this.", [FBCollectionInformation oneLineDescriptionFromArray:testsToSkip]]
failFuture];
}
NSArray<NSString *> *testsToRun = self.testsToRun.allObjects ?: @[];
if (testsToRun.count > 1){
return [[FBXCTestError
describeFormat:@"More than one 'Tests to Run' %@ provided, but only one 'Tests to Run' is supported.", [FBCollectionInformation oneLineDescriptionFromArray:testsToRun]]
failFuture];
}
testFilter = testsToRun.firstObject;

NSTimeInterval timeout = self.testTimeout.boolValue ? self.testTimeout.doubleValue : FBLogicTestTimeout;
FBLogicTestConfiguration *configuration = [FBLogicTestConfiguration
configurationWithEnvironment:self.environment
workingDirectory:workingDirectory.path
testBundlePath:testDescriptor.testBundle.path
waitForDebugger:self.waitForDebugger
timeout:timeout
testFilter:testFilter
mirroring:FBLogicTestMirrorFileLogs
coveragePath:coveragePath
binaryPath:testDescriptor.testBundle.binary.path
logDirectoryPath:logDirectoryPath];

return [self startTestExecution:configuration target:target reporter:reporter logger:logger];
}

- (FBFuture<FBIDBTestOperation *> *)startTestExecution:(FBLogicTestConfiguration *)configuration target:(id<FBiOSTarget>)target reporter:(id<FBXCTestReporter, FBXCTestReporterWithFiles>)reporter logger:(id<FBControlCoreLogger>)logger
Expand Down Expand Up @@ -215,21 +211,16 @@ - (BOOL)isUITest

- (FBFuture<FBIDBTestOperation *> *)startWithTestDescriptor:(id<FBXCTestDescriptor>)testDescriptor target:(id<FBiOSTarget>)target reporter:(id<FBXCTestReporter, FBXCTestReporterWithFiles>)reporter logger:(id<FBControlCoreLogger>)logger temporaryDirectory:(FBTemporaryDirectory *)temporaryDirectory
{
return [[FBXCTestShimConfiguration
defaultShimConfigurationWithLogger:logger]
onQueue:target.workQueue fmap:^ FBFuture<FBIDBTestOperation *> * (FBXCTestShimConfiguration *shims) {
return [[testDescriptor
testAppPairForRequest:self target:target]
onQueue:target.workQueue fmap:^ FBFuture<FBIDBTestOperation *> * (FBTestApplicationsPair *pair) {
[logger logFormat:@"Obtaining launch configuration for App Pair %@ on descriptor %@", pair, testDescriptor];
FBFuture<FBTestLaunchConfiguration *> *launchConfigFuture = [testDescriptor testConfigWithRunRequest:self testApps:pair shims:shims logger:logger queue:target.workQueue];
return [launchConfigFuture onQueue:target.workQueue fmap:^ FBFuture<FBIDBTestOperation *> * (FBTestLaunchConfiguration *testConfig) {
[logger logFormat:@"Obtained launch configuration %@", testConfig];
[reporter setLogDirectoryPath:testConfig.logDirectoryPath];
return [FBXCTestRunRequest_AppTest startTestExecution:testConfig target:target reporter:reporter logger:logger];
}];

}];
return [[testDescriptor
testAppPairForRequest:self target:target]
onQueue:target.workQueue fmap:^ FBFuture<FBIDBTestOperation *> * (FBTestApplicationsPair *pair) {
[logger logFormat:@"Obtaining launch configuration for App Pair %@ on descriptor %@", pair, testDescriptor];
FBFuture<FBTestLaunchConfiguration *> *launchConfigFuture = [testDescriptor testConfigWithRunRequest:self testApps:pair logger:logger queue:target.workQueue];
return [launchConfigFuture onQueue:target.workQueue fmap:^ FBFuture<FBIDBTestOperation *> * (FBTestLaunchConfiguration *testConfig) {
[logger logFormat:@"Obtained launch configuration %@", testConfig];
[reporter setLogDirectoryPath:testConfig.logDirectoryPath];
return [FBXCTestRunRequest_AppTest startTestExecution:testConfig target:target reporter:reporter logger:logger];
}];
}];
}

Expand Down Expand Up @@ -482,7 +473,7 @@ - (NSSet *)architectures
}];
}

- (FBFuture<FBTestLaunchConfiguration *> *)testConfigWithRunRequest:(FBXCTestRunRequest *)request testApps:(FBTestApplicationsPair *)testApps shims:(FBXCTestShimConfiguration *)shims logger:(id<FBControlCoreLogger>)logger queue:(dispatch_queue_t)queue
- (FBFuture<FBTestLaunchConfiguration *> *)testConfigWithRunRequest:(FBXCTestRunRequest *)request testApps:(FBTestApplicationsPair *)testApps logger:(id<FBControlCoreLogger>)logger queue:(dispatch_queue_t)queue
{
BOOL uiTesting = NO;

Expand Down Expand Up @@ -596,7 +587,7 @@ - (NSSet *)architectures
return [FBFuture futureWithResult:[[FBTestApplicationsPair alloc] initWithApplicationUnderTest:nil testHostApp:nil]];
}

- (FBFuture<FBTestLaunchConfiguration *> *)testConfigWithRunRequest:(FBXCTestRunRequest *)request testApps:(FBTestApplicationsPair *)testApps shims:(FBXCTestShimConfiguration *)shims logger:(id<FBControlCoreLogger>)logger queue:(dispatch_queue_t)queue
- (FBFuture<FBTestLaunchConfiguration *> *)testConfigWithRunRequest:(FBXCTestRunRequest *)request testApps:(FBTestApplicationsPair *)testApps logger:(id<FBControlCoreLogger>)logger queue:(dispatch_queue_t)queue
{
NSString *resultBundleName = [NSString stringWithFormat:@"resultbundle_%@", NSUUID.UUID.UUIDString];
NSString *resultBundlePath = [self.targetAuxillaryDirectory stringByAppendingPathComponent:resultBundleName];
Expand Down

0 comments on commit c9171bb

Please sign in to comment.