diff --git a/FBControlCore/Commands/FBXCTestCommands.h b/FBControlCore/Commands/FBXCTestCommands.h index 66499d853..2ada1068c 100644 --- a/FBControlCore/Commands/FBXCTestCommands.h +++ b/FBControlCore/Commands/FBXCTestCommands.h @@ -56,6 +56,11 @@ NS_ASSUME_NONNULL_BEGIN */ - (FBFuture *> *)listTestsForBundleAtPath:(NSString *)bundlePath timeout:(NSTimeInterval)timeout withAppAtPath:(nullable NSString *)appPath; +/** + Returns the platform specific shims. + */ +- (FBFuture *)extendedTestShim; + /** The Path to the xctest executable. */ diff --git a/FBSimulatorControl/Commands/FBSimulatorXCTestCommands.m b/FBSimulatorControl/Commands/FBSimulatorXCTestCommands.m index 8c9569ee0..551fa72db 100644 --- a/FBSimulatorControl/Commands/FBSimulatorXCTestCommands.m +++ b/FBSimulatorControl/Commands/FBSimulatorXCTestCommands.m @@ -79,22 +79,17 @@ - (instancetype)initWithSimulator:(FBSimulator *)simulator - (FBFuture *> *)listTestsForBundleAtPath:(NSString *)bundlePath timeout:(NSTimeInterval)timeout withAppAtPath:(NSString *)appPath { - return [[FBXCTestShimConfiguration - defaultShimConfigurationWithLogger:self.simulator.logger] - onQueue:self.simulator.workQueue fmap:^(FBXCTestShimConfiguration *shims) { - FBListTestConfiguration *configuration = [FBListTestConfiguration - configurationWithShims:shims - environment:@{} - workingDirectory:self.simulator.auxillaryDirectory - testBundlePath:bundlePath - runnerAppPath:appPath - waitForDebugger:NO - timeout:timeout]; - - return [[[FBListTestStrategy alloc] - initWithTarget:self.simulator configuration:configuration shimPath:shims.iOSSimulatorTestShimPath logger:self.simulator.logger] - listTests]; - }]; + FBListTestConfiguration *configuration = [FBListTestConfiguration + configurationWithEnvironment:@{} + workingDirectory:self.simulator.auxillaryDirectory + testBundlePath:bundlePath + runnerAppPath:appPath + waitForDebugger:NO + timeout:timeout]; + + return [[[FBListTestStrategy alloc] + initWithTarget:self.simulator configuration:configuration logger:self.simulator.logger] + listTests]; } - (FBFutureContext *)transportForTestManagerService @@ -141,6 +136,15 @@ - (instancetype)initWithSimulator:(FBSimulator *)simulator }]; } +- (FBFuture *)extendedTestShim +{ + return [[FBXCTestShimConfiguration + defaultShimConfigurationWithLogger:self.simulator.logger] + onQueue:self.simulator.asyncQueue map:^(FBXCTestShimConfiguration *shims) { + return shims.iOSSimulatorTestShimPath; + }]; +} + - (NSString *)xctestPath { return [FBXcodeConfiguration.developerDirectory diff --git a/XCTestBootstrap/Configuration/FBXCTestConfiguration.h b/XCTestBootstrap/Configuration/FBXCTestConfiguration.h index dab296c14..2a827703b 100644 --- a/XCTestBootstrap/Configuration/FBXCTestConfiguration.h +++ b/XCTestBootstrap/Configuration/FBXCTestConfiguration.h @@ -49,12 +49,7 @@ extern FBXCTestType const FBXCTestTypeListTest; The Default Initializer. This should not be called directly. */ -- (instancetype)initWithShims:(nullable FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout; - -/** - The Shims to use for relevant test runs. - */ -@property (nonatomic, copy, nullable, readonly) FBXCTestShimConfiguration *shims; +- (instancetype)initWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout; /** The Environment Variables for the Process-Under-Test that is launched. @@ -107,7 +102,7 @@ extern FBXCTestType const FBXCTestTypeListTest; /** The Designated Initializer. */ -+ (instancetype)configurationWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath runnerAppPath:(nullable NSString *)runnerAppPath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout; ++ (instancetype)configurationWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath runnerAppPath:(nullable NSString *)runnerAppPath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout; @property (nonatomic, copy, readonly) NSString *runnerAppPath; @@ -156,7 +151,7 @@ extern FBXCTestType const FBXCTestTypeListTest; /** The Designated Initializer. */ -+ (instancetype)configurationWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout runnerAppPath:(NSString *)runnerAppPath testTargetAppPath:(nullable NSString *)testTargetAppPath testFilter:(nullable NSString *)testFilter videoRecordingPath:(nullable NSString *)videoRecordingPath testArtifactsFilenameGlobs:(nullable NSArray *)testArtifactsFilenameGlobs osLogPath:(nullable NSString *)osLogPath; ++ (instancetype)configurationWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout runnerAppPath:(NSString *)runnerAppPath testTargetAppPath:(nullable NSString *)testTargetAppPath testFilter:(nullable NSString *)testFilter videoRecordingPath:(nullable NSString *)videoRecordingPath testArtifactsFilenameGlobs:(nullable NSArray *)testArtifactsFilenameGlobs osLogPath:(nullable NSString *)osLogPath; @end @@ -202,7 +197,7 @@ typedef NS_OPTIONS(NSUInteger, FBLogicTestMirrorLogs) { /** The Designated Initializer. */ -+ (instancetype)configurationWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout testFilter:(nullable NSString *)testFilter mirroring:(FBLogicTestMirrorLogs)mirroring coveragePath:(nullable NSString *)coveragePath binaryPath:(nullable NSString *)binaryPath logDirectoryPath:(nullable NSString *)logDirectoryPath; ++ (instancetype)configurationWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout testFilter:(nullable NSString *)testFilter mirroring:(FBLogicTestMirrorLogs)mirroring coveragePath:(nullable NSString *)coveragePath binaryPath:(nullable NSString *)binaryPath logDirectoryPath:(nullable NSString *)logDirectoryPath; @end diff --git a/XCTestBootstrap/Configuration/FBXCTestConfiguration.m b/XCTestBootstrap/Configuration/FBXCTestConfiguration.m index dc643e7fd..6b8e72716 100644 --- a/XCTestBootstrap/Configuration/FBXCTestConfiguration.m +++ b/XCTestBootstrap/Configuration/FBXCTestConfiguration.m @@ -22,14 +22,13 @@ @implementation FBXCTestConfiguration #pragma mark Initializers -- (instancetype)initWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout +- (instancetype)initWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout { self = [super init]; if (!self) { return nil; } - _shims = shims; _processUnderTestEnvironment = environment ?: @{}; _workingDirectory = workingDirectory; _testBundlePath = testBundlePath; @@ -99,8 +98,7 @@ - (BOOL)isEqual:(FBXCTestConfiguration *)object if (![object isMemberOfClass:self.class]) { return NO; } - return (self.shims == object.shims || [self.shims isEqual:object.shims]) - && (self.processUnderTestEnvironment == object.processUnderTestEnvironment || [self.processUnderTestEnvironment isEqualToDictionary:object.processUnderTestEnvironment]) + return (self.processUnderTestEnvironment == object.processUnderTestEnvironment || [self.processUnderTestEnvironment isEqualToDictionary:object.processUnderTestEnvironment]) && (self.workingDirectory == object.workingDirectory || [self.workingDirectory isEqualToString:object.workingDirectory]) && (self.testBundlePath == object.testBundlePath || [self.testBundlePath isEqualToString:object.testBundlePath]) && (self.testType == object.testType || [self.testType isEqualToString:object.testType]) @@ -110,7 +108,7 @@ - (BOOL)isEqual:(FBXCTestConfiguration *)object - (NSUInteger)hash { - return self.shims.hash ^ self.processUnderTestEnvironment.hash ^ self.workingDirectory.hash ^ self.testBundlePath.hash ^ self.testType.hash ^ ((NSUInteger) self.waitForDebugger) ^ ((NSUInteger) self.testTimeout); + return self.processUnderTestEnvironment.hash ^ self.workingDirectory.hash ^ self.testBundlePath.hash ^ self.testType.hash ^ ((NSUInteger) self.waitForDebugger) ^ ((NSUInteger) self.testTimeout); } #pragma mark JSON @@ -120,7 +118,6 @@ - (NSUInteger)hash static NSString *const KeyOSLogPath = @"os_log_path"; static NSString *const KeyRunnerAppPath = @"test_host_path"; static NSString *const KeyRunnerTargetPath = @"test_target_path"; -static NSString *const KeyShims = @"shims"; static NSString *const KeyTestArtifactsFilenameGlobs = @"test_artifacts_filename_globs"; static NSString *const KeyTestBundlePath = @"test_bundle_path"; static NSString *const KeyTestFilter = @"test_filter"; @@ -157,14 +154,14 @@ @implementation FBListTestConfiguration #pragma mark Initializers -+ (instancetype)configurationWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath runnerAppPath:(nullable NSString *)runnerAppPath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout ++ (instancetype)configurationWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath runnerAppPath:(nullable NSString *)runnerAppPath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout { - return [[FBListTestConfiguration alloc] initWithShims:shims environment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath runnerAppPath:runnerAppPath waitForDebugger:waitForDebugger timeout:timeout]; + return [[FBListTestConfiguration alloc] initWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath runnerAppPath:runnerAppPath waitForDebugger:waitForDebugger timeout:timeout]; } -- (instancetype)initWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath runnerAppPath:(nullable NSString *)runnerAppPath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout +- (instancetype)initWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath runnerAppPath:(nullable NSString *)runnerAppPath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout { - self = [super initWithShims:shims environment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout]; + self = [super initWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout]; if (!self) { return nil; } @@ -197,14 +194,14 @@ @implementation FBTestManagerTestConfiguration #pragma mark Initializers -+ (instancetype)configurationWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout runnerAppPath:(NSString *)runnerAppPath testTargetAppPath:(NSString *)testTargetAppPath testFilter:(NSString *)testFilter videoRecordingPath:(NSString *)videoRecordingPath testArtifactsFilenameGlobs:(nullable NSArray *)testArtifactsFilenameGlobs osLogPath:(nullable NSString *)osLogPath ++ (instancetype)configurationWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout runnerAppPath:(NSString *)runnerAppPath testTargetAppPath:(NSString *)testTargetAppPath testFilter:(NSString *)testFilter videoRecordingPath:(NSString *)videoRecordingPath testArtifactsFilenameGlobs:(nullable NSArray *)testArtifactsFilenameGlobs osLogPath:(nullable NSString *)osLogPath { - return [[FBTestManagerTestConfiguration alloc] initWithShims:shims environment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout runnerAppPath:runnerAppPath testTargetAppPath:testTargetAppPath testFilter:testFilter videoRecordingPath:videoRecordingPath testArtifactsFilenameGlobs:testArtifactsFilenameGlobs osLogPath:osLogPath]; + return [[FBTestManagerTestConfiguration alloc] initWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout runnerAppPath:runnerAppPath testTargetAppPath:testTargetAppPath testFilter:testFilter videoRecordingPath:videoRecordingPath testArtifactsFilenameGlobs:testArtifactsFilenameGlobs osLogPath:osLogPath]; } -- (instancetype)initWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout runnerAppPath:(NSString *)runnerAppPath testTargetAppPath:(NSString *)testTargetAppPath testFilter:(NSString *)testFilter videoRecordingPath:(NSString *)videoRecordingPath testArtifactsFilenameGlobs:(NSArray *)testArtifactsFilenameGlobs osLogPath:(nullable NSString *)osLogPath +- (instancetype)initWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout runnerAppPath:(NSString *)runnerAppPath testTargetAppPath:(NSString *)testTargetAppPath testFilter:(NSString *)testFilter videoRecordingPath:(NSString *)videoRecordingPath testArtifactsFilenameGlobs:(NSArray *)testArtifactsFilenameGlobs osLogPath:(nullable NSString *)osLogPath { - self = [super initWithShims:shims environment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout]; + self = [super initWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout]; if (!self) { return nil; } @@ -246,14 +243,14 @@ @implementation FBLogicTestConfiguration #pragma mark Initializers -+ (instancetype)configurationWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout testFilter:(NSString *)testFilter mirroring:(FBLogicTestMirrorLogs)mirroring coveragePath:(nullable NSString *)coveragePath binaryPath:(nullable NSString *)binaryPath logDirectoryPath:(NSString *)logDirectoryPath ++ (instancetype)configurationWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout testFilter:(NSString *)testFilter mirroring:(FBLogicTestMirrorLogs)mirroring coveragePath:(nullable NSString *)coveragePath binaryPath:(nullable NSString *)binaryPath logDirectoryPath:(NSString *)logDirectoryPath { - return [[FBLogicTestConfiguration alloc] initWithShims:shims environment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout testFilter:testFilter mirroring:mirroring coveragePath:coveragePath binaryPath:binaryPath logDirectoryPath:logDirectoryPath]; + return [[FBLogicTestConfiguration alloc] initWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout testFilter:testFilter mirroring:mirroring coveragePath:coveragePath binaryPath:binaryPath logDirectoryPath:logDirectoryPath]; } -- (instancetype)initWithShims:(FBXCTestShimConfiguration *)shims environment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout testFilter:(NSString *)testFilter mirroring:(FBLogicTestMirrorLogs)mirroring coveragePath:(nullable NSString *)coveragePath binaryPath:(nullable NSString *)binaryPath logDirectoryPath:(NSString *)logDirectoryPath +- (instancetype)initWithEnvironment:(NSDictionary *)environment workingDirectory:(NSString *)workingDirectory testBundlePath:(NSString *)testBundlePath waitForDebugger:(BOOL)waitForDebugger timeout:(NSTimeInterval)timeout testFilter:(NSString *)testFilter mirroring:(FBLogicTestMirrorLogs)mirroring coveragePath:(nullable NSString *)coveragePath binaryPath:(nullable NSString *)binaryPath logDirectoryPath:(NSString *)logDirectoryPath { - self = [super initWithShims:shims environment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout]; + self = [super initWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger timeout:timeout]; if (!self) { return nil; } diff --git a/XCTestBootstrap/MacStrategies/FBMacDevice.m b/XCTestBootstrap/MacStrategies/FBMacDevice.m index 21f5383d8..7898de831 100644 --- a/XCTestBootstrap/MacStrategies/FBMacDevice.m +++ b/XCTestBootstrap/MacStrategies/FBMacDevice.m @@ -130,6 +130,15 @@ - (NSString *)xctestPath stringByAppendingPathComponent:@"usr/bin/xctest"]; } +- (FBFuture *)extendedTestShim +{ + return [[FBXCTestShimConfiguration + defaultShimConfigurationWithLogger:self.logger] + onQueue:self.asyncQueue map:^(FBXCTestShimConfiguration *shims) { + return shims.macOSTestShimPath; + }]; +} + + (NSString *)resolveDeviceUDID { io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); @@ -417,25 +426,19 @@ - (NSString *)customDeviceSetPath - (nonnull FBFuture *> *)listTestsForBundleAtPath:(nonnull NSString *)bundlePath timeout:(NSTimeInterval)timeout withAppAtPath:(NSString *)appPath { - return [[FBXCTestShimConfiguration - defaultShimConfigurationWithLogger:self.logger] - onQueue:self.workQueue fmap:^(FBXCTestShimConfiguration *shims) { - FBListTestConfiguration *configuration = [FBListTestConfiguration - configurationWithShims:shims - environment:@{} - workingDirectory:self.auxillaryDirectory - testBundlePath:bundlePath - runnerAppPath:appPath - waitForDebugger:NO - timeout:timeout]; - - return [[[FBListTestStrategy alloc] - initWithTarget:self - configuration:configuration - shimPath:shims.macOSTestShimPath - logger:self.logger] - listTests]; - }]; + FBListTestConfiguration *configuration = [FBListTestConfiguration + configurationWithEnvironment:@{} + workingDirectory:self.auxillaryDirectory + testBundlePath:bundlePath + runnerAppPath:appPath + waitForDebugger:NO + timeout:timeout]; + + return [[[FBListTestStrategy alloc] + initWithTarget:self + configuration:configuration + logger:self.logger] + listTests]; } - (nonnull FBFuture> *)tailLog:(nonnull NSArray *)arguments consumer:(nonnull id)consumer diff --git a/XCTestBootstrap/Strategies/FBListTestStrategy.h b/XCTestBootstrap/Strategies/FBListTestStrategy.h index ada6794a6..13447989b 100644 --- a/XCTestBootstrap/Strategies/FBListTestStrategy.h +++ b/XCTestBootstrap/Strategies/FBListTestStrategy.h @@ -29,10 +29,9 @@ NS_ASSUME_NONNULL_BEGIN @param target the target to run against. @param configuration the the configuration to use. - @param shimPath the path to the shim dylib. @return a new FBListTestStrategy instance. */ -- (instancetype)initWithTarget:(id)target configuration:(FBListTestConfiguration *)configuration shimPath:(NSString *)shimPath logger:(id)logger; +- (instancetype)initWithTarget:(id)target configuration:(FBListTestConfiguration *)configuration logger:(id)logger; #pragma mark Public Methods diff --git a/XCTestBootstrap/Strategies/FBListTestStrategy.m b/XCTestBootstrap/Strategies/FBListTestStrategy.m index 5409a7e93..e9bc5bbc4 100644 --- a/XCTestBootstrap/Strategies/FBListTestStrategy.m +++ b/XCTestBootstrap/Strategies/FBListTestStrategy.m @@ -20,7 +20,6 @@ @interface FBListTestStrategy () @property (nonatomic, strong, readonly) FBListTestConfiguration *configuration; @property (nonatomic, strong, readonly) id target; @property (nonatomic, strong, readonly) id logger; -@property (nonatomic, copy, readonly) NSString *shimPath; @end @@ -71,7 +70,7 @@ - (instancetype)initWithStrategy:(FBListTestStrategy *)strategy reporter:(id)target configuration:(FBListTestConfiguration *)configuration shimPath:(NSString *)shimPath logger:(id)logger +- (instancetype)initWithTarget:(id)target configuration:(FBListTestConfiguration *)configuration logger:(id)logger { self = [super init]; if (!self) { @@ -80,7 +79,6 @@ - (instancetype)initWithTarget:(id *> *)listTests { id shimBuffer = FBDataBuffer.consumableBuffer; - return [[[FBProcessOutput - outputForDataConsumer:shimBuffer] - providedThroughFile] - onQueue:self.target.workQueue fmap:^(id shimOutput) { - return [self listTestsWithShimOutput:shimOutput shimBuffer:shimBuffer]; + return [[FBFuture + futureWithFutures:@[ + [self.target extendedTestShim], + [[FBProcessOutput outputForDataConsumer:shimBuffer] providedThroughFile], + ]] + onQueue:self.target.workQueue fmap:^(NSArray *tuple) { + return [self listTestsWithShimPath:tuple[0] shimOutput:tuple[1] shimBuffer:shimBuffer]; }]; } #pragma mark Private -- (FBFuture *> *)listTestsWithShimOutput:(id)shimOutput shimBuffer:(id)shimBuffer +- (FBFuture *> *)listTestsWithShimPath:(NSString *)shimPath shimOutput:(id)shimOutput shimBuffer:(id)shimBuffer { id stdOutBuffer = FBDataBuffer.consumableBuffer; id stdOutConsumer = [FBCompositeDataConsumer consumerWithConsumers:@[ @@ -115,7 +115,7 @@ - (instancetype)initWithTarget:(id * (NSArray *libraries){ - NSDictionary *environment = [self setupEnvironmentWithDylibs:libraries shimOutputFilePath:shimOutput.filePath bundlePath:self.configuration.testBundlePath]; + NSDictionary *environment = [FBListTestStrategy setupEnvironmentWithDylibs:libraries shimPath:shimPath shimOutputFilePath:shimOutput.filePath bundlePath:self.configuration.testBundlePath]; return [[FBListTestStrategy listTestProcessWithTarget:self.target @@ -137,9 +137,9 @@ - (instancetype)initWithTarget:(id *)setupEnvironmentWithDylibs:(NSArray *)libraries shimOutputFilePath:(NSString *)shimOutputFilePath bundlePath:(NSString *)bundlePath ++ (NSDictionary *)setupEnvironmentWithDylibs:(NSArray *)libraries shimPath:(NSString *)shimPath shimOutputFilePath:(NSString *)shimOutputFilePath bundlePath:(NSString *)bundlePath { - NSMutableArray *librariesWithShim = [NSMutableArray arrayWithObject:self.shimPath]; + NSMutableArray *librariesWithShim = [NSMutableArray arrayWithObject:shimPath]; [librariesWithShim addObjectsFromArray:libraries]; NSDictionary *environment = @{ @"DYLD_INSERT_LIBRARIES": [librariesWithShim componentsJoinedByString:@":"], diff --git a/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.h b/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.h index 41cb436a3..ab5408d1b 100644 --- a/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.h +++ b/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.h @@ -27,12 +27,11 @@ NS_ASSUME_NONNULL_BEGIN @param target the target to run against. @param configuration the Configuration to use. - @param shimPath the path to the shim dylib. @param reporter the reporter to report to. @param logger the logger to use. @return a new Logic Test Strategy. */ -- (instancetype)initWithTarget:(id)target configuration:(FBLogicTestConfiguration *)configuration shimPath:(NSString *)shimPath reporter:(id)reporter logger:(id)logger; +- (instancetype)initWithTarget:(id)target configuration:(FBLogicTestConfiguration *)configuration reporter:(id)reporter logger:(id)logger; @end diff --git a/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.m b/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.m index 9f2c857b2..317d42988 100644 --- a/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.m +++ b/XCTestBootstrap/Strategies/FBLogicTestRunStrategy.m @@ -53,15 +53,13 @@ @interface FBLogicTestRunStrategy () @property (nonatomic, strong, readonly) id reporter; @property (nonatomic, strong, readonly) id logger; -@property (nonatomic, copy, readonly) NSString *shimPath; - @end @implementation FBLogicTestRunStrategy #pragma mark Initializers -- (instancetype)initWithTarget:(id)target configuration:(FBLogicTestConfiguration *)configuration shimPath:(NSString *)shimPath reporter:(id)reporter logger:(id)logger +- (instancetype)initWithTarget:(id)target configuration:(FBLogicTestConfiguration *)configuration reporter:(id)reporter logger:(id)logger { self = [super init]; if (!self) { @@ -70,7 +68,6 @@ - (instancetype)initWithTarget:(id *tuple) { + return [self testFutureWithOutputs:tuple[0] shimPath:tuple[1] uuid:uuid]; }]; } #pragma mark Private -- (FBFuture *)testFutureWithOutputs:(FBLogicTestRunOutputs *)outputs uuid:(NSUUID *)uuid +- (FBFuture *)testFutureWithOutputs:(FBLogicTestRunOutputs *)outputs shimPath:(NSString *)shimPath uuid:(NSUUID *)uuid { [self.logger logFormat:@"Starting Logic Test execution of %@", self.configuration]; id reporter = self.reporter; [reporter didBeginExecutingTestPlan]; NSString *xctestPath = self.target.xctestPath; - NSString *shimPath = self.shimPath; // Get the Launch Path and Arguments for the xctest process. NSString *testSpecifier = self.configuration.testFilter ?: @"All"; diff --git a/fbxctest/FBXCTestKit/Configuration/FBXCTestCommandLine.m b/fbxctest/FBXCTestKit/Configuration/FBXCTestCommandLine.m index 5a9ad3012..8d03e7ecc 100644 --- a/fbxctest/FBXCTestKit/Configuration/FBXCTestCommandLine.m +++ b/fbxctest/FBXCTestKit/Configuration/FBXCTestCommandLine.m @@ -47,13 +47,12 @@ + (nullable instancetype)commandLineFromArguments:(NSArray *)argumen if (!destination) { return nil; } - FBXCTestShimConfiguration *shims = nil; NSString *testBundlePath = nil; NSString *runnerAppPath = nil; NSString *testFilter = nil; NSString *testTargetPathOut = nil; BOOL waitForDebugger = NO; - if (![FBXCTestCommandLine loadWithArguments:arguments shimsOut:&shims testBundlePathOut:&testBundlePath runnerAppPathOut:&runnerAppPath testTargetPathOut:&testTargetPathOut testFilterOut:&testFilter waitForDebuggerOut:&waitForDebugger error:error]) { + if (![FBXCTestCommandLine loadWithArguments:arguments testBundlePathOut:&testBundlePath runnerAppPathOut:&runnerAppPath testTargetPathOut:&testTargetPathOut testFilterOut:&testFilter waitForDebuggerOut:&waitForDebugger error:error]) { return nil; } NSSet *argumentSet = [NSSet setWithArray:arguments]; @@ -63,8 +62,7 @@ + (nullable instancetype)commandLineFromArguments:(NSArray *)argumen runnerAppPath = nil; } configuration = [FBListTestConfiguration - configurationWithShims:shims - environment:environment + configurationWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath runnerAppPath:runnerAppPath @@ -72,8 +70,7 @@ + (nullable instancetype)commandLineFromArguments:(NSArray *)argumen timeout:timeout]; } else if ([argumentSet containsObject:@"-logicTest"]) { configuration = [FBLogicTestConfiguration - configurationWithShims:shims - environment:environment + configurationWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger @@ -93,8 +90,7 @@ + (nullable instancetype)commandLineFromArguments:(NSArray *)argumen NSString *osLogPath = allEnvironment[@"FBXCTEST_OS_LOG_PATH"]; configuration = [FBTestManagerTestConfiguration - configurationWithShims:shims - environment:environment + configurationWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger @@ -107,8 +103,7 @@ + (nullable instancetype)commandLineFromArguments:(NSArray *)argumen osLogPath:osLogPath]; } else if ([argumentSet containsObject:@"-uiTest"]) { configuration = [FBTestManagerTestConfiguration - configurationWithShims:shims - environment:environment + configurationWithEnvironment:environment workingDirectory:workingDirectory testBundlePath:testBundlePath waitForDebugger:waitForDebugger @@ -128,12 +123,10 @@ + (nullable instancetype)commandLineFromArguments:(NSArray *)argumen return [[FBXCTestCommandLine alloc] initWithConfiguration:configuration destination:destination]; } -+ (BOOL)loadWithArguments:(NSArray *)arguments shimsOut:(FBXCTestShimConfiguration **)shimsOut testBundlePathOut:(NSString **)testBundlePathOut runnerAppPathOut:(NSString **)runnerAppPathOut testTargetPathOut:(NSString **)testTargetPathOut testFilterOut:(NSString **)testFilterOut waitForDebuggerOut:(BOOL *)waitForDebuggerOut error:(NSError **)error ++ (BOOL)loadWithArguments:(NSArray *)arguments testBundlePathOut:(NSString **)testBundlePathOut runnerAppPathOut:(NSString **)runnerAppPathOut testTargetPathOut:(NSString **)testTargetPathOut testFilterOut:(NSString **)testFilterOut waitForDebuggerOut:(BOOL *)waitForDebuggerOut error:(NSError **)error { NSUInteger nextArgument = 0; NSString *testFilter = nil; - BOOL shimsRequired = YES; - while (nextArgument < arguments.count) { NSString *argument = arguments[nextArgument++]; if ([argument isEqualToString:@"run-tests"]) { @@ -208,14 +201,6 @@ + (BOOL)loadWithArguments:(NSArray *)arguments shimsOut:(FBXCTestShi } } - if (shimsRequired) { - NSError *innerError = nil; - FBXCTestShimConfiguration *shimConfiguration = [[FBXCTestShimConfiguration defaultShimConfigurationWithLogger:nil] await:&innerError]; - if (!shimConfiguration) { - return [FBXCTestError failBoolWithError:innerError errorOut:error]; - } - *shimsOut = shimConfiguration; - } if (testFilter != nil) { NSString *expectedPrefix = [*testBundlePathOut stringByAppendingString:@":"]; if (![testFilter hasPrefix:expectedPrefix]) { diff --git a/fbxctest/FBXCTestKit/Runners/FBXCTestBaseRunner.m b/fbxctest/FBXCTestKit/Runners/FBXCTestBaseRunner.m index 12db51adf..442d4a11f 100644 --- a/fbxctest/FBXCTestKit/Runners/FBXCTestBaseRunner.m +++ b/fbxctest/FBXCTestKit/Runners/FBXCTestBaseRunner.m @@ -75,7 +75,6 @@ - (FBXCTestConfiguration *)configuration - (FBFuture *)runMacTest { FBMacDevice *device = [[FBMacDevice alloc] initWithLogger:self.context.logger]; - NSString *shimPath = self.configuration.shims.macOSTestShimPath; if ([self.configuration isKindOfClass:FBTestManagerTestConfiguration.class]) { return [[[FBTestRunStrategy strategyWithTarget:device configuration:(FBTestManagerTestConfiguration *)self.configuration reporter:self.context.reporter logger:self.context.logger] execute] onQueue:device.workQueue chain:^(FBFuture *future) { @@ -84,10 +83,10 @@ - (FBXCTestConfiguration *)configuration } if ([self.configuration isKindOfClass:FBListTestConfiguration.class]) { - return [[[[FBListTestStrategy alloc] initWithTarget:device configuration:(FBListTestConfiguration *)self.configuration shimPath:shimPath logger:self.context.logger] wrapInReporter:self.context.reporter] execute]; + return [[[[FBListTestStrategy alloc] initWithTarget:device configuration:(FBListTestConfiguration *)self.configuration logger:self.context.logger] wrapInReporter:self.context.reporter] execute]; } FBLogicReporterAdapter *adapter = [[FBLogicReporterAdapter alloc] initWithReporter:self.context.reporter logger:self.context.logger]; - return [[[FBLogicTestRunStrategy alloc] initWithTarget:device configuration:(FBLogicTestConfiguration *)self.configuration shimPath:shimPath reporter:adapter logger:self.context.logger] execute]; + return [[[FBLogicTestRunStrategy alloc] initWithTarget:device configuration:(FBLogicTestConfiguration *)self.configuration reporter:adapter logger:self.context.logger] execute]; } - (FBFuture *)runiOSTest @@ -107,16 +106,14 @@ - (FBXCTestConfiguration *)configuration - (FBFuture *)runTestWithSimulator:(FBSimulator *)simulator { - NSString *shimPath = self.configuration.shims.iOSSimulatorTestShimPath; - if ([self.configuration isKindOfClass:FBTestManagerTestConfiguration.class]) { return [[FBTestRunStrategy strategyWithTarget:simulator configuration:(FBTestManagerTestConfiguration *)self.configuration reporter:self.context.reporter logger:self.context.logger] execute]; } if ([self.configuration isKindOfClass:FBListTestConfiguration.class]) { - return [[[[FBListTestStrategy alloc] initWithTarget:simulator configuration:(FBListTestConfiguration *)self.configuration shimPath:shimPath logger:self.context.logger] wrapInReporter:self.context.reporter] execute]; + return [[[[FBListTestStrategy alloc] initWithTarget:simulator configuration:(FBListTestConfiguration *)self.configuration logger:self.context.logger] wrapInReporter:self.context.reporter] execute]; } FBLogicReporterAdapter *adapter = [[FBLogicReporterAdapter alloc] initWithReporter:self.context.reporter logger:self.context.logger]; - return [[[FBLogicTestRunStrategy alloc] initWithTarget:simulator configuration:(FBLogicTestConfiguration *)self.configuration shimPath:shimPath reporter:adapter logger:self.context.logger] execute]; + return [[[FBLogicTestRunStrategy alloc] initWithTarget:simulator configuration:(FBLogicTestConfiguration *)self.configuration reporter:adapter logger:self.context.logger] execute]; } @end diff --git a/idb_companion/Utility/FBXCTestDescriptor.m b/idb_companion/Utility/FBXCTestDescriptor.m index 304439da1..d764a8b8c 100644 --- a/idb_companion/Utility/FBXCTestDescriptor.m +++ b/idb_companion/Utility/FBXCTestDescriptor.m @@ -168,8 +168,7 @@ - (BOOL)isUITest NSTimeInterval timeout = self.testTimeout.boolValue ? self.testTimeout.doubleValue : FBLogicTestTimeout; FBLogicTestConfiguration *configuration = [FBLogicTestConfiguration - configurationWithShims:shims - environment:self.environment + configurationWithEnvironment:self.environment workingDirectory:workingDirectory.path testBundlePath:testDescriptor.testBundle.path waitForDebugger:self.waitForDebugger @@ -186,19 +185,8 @@ - (BOOL)isUITest - (FBFuture *)startTestExecution:(FBLogicTestConfiguration *)configuration target:(id)target reporter:(id)reporter logger:(id)logger { - NSString *shimPath = nil; - if ([target isKindOfClass:FBSimulator.class]) { - shimPath = configuration.shims.iOSSimulatorTestShimPath; - } else if ([target isKindOfClass:FBMacDevice.class]) { - shimPath = configuration.shims.macOSTestShimPath; - } else { - return [[FBIDBError - describeFormat:@"%@ does not support logic tests", target] - failFuture]; - } - FBLogicReporterAdapter *adapter = [[FBLogicReporterAdapter alloc] initWithReporter:reporter logger:logger]; - FBLogicTestRunStrategy *runner = [[FBLogicTestRunStrategy alloc] initWithTarget:(id)target configuration:configuration shimPath:shimPath reporter:adapter logger:logger]; + FBLogicTestRunStrategy *runner = [[FBLogicTestRunStrategy alloc] initWithTarget:(id)target configuration:configuration reporter:adapter logger:logger]; FBFuture *completed = [runner execute]; if (completed.error) { return [FBFuture futureWithError:completed.error];