From 304ddfb49eb73fa9d27104329e98d4fa2b62e856 Mon Sep 17 00:00:00 2001 From: Nan Wang Date: Thu, 8 Dec 2022 15:22:53 -0800 Subject: [PATCH] Trigger the test when the bundle is actually connected (#547) Signed-off-by: Nan Wang Signed-off-by: Nan Wang --- bp/src/BPTMDRunnerConnection.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bp/src/BPTMDRunnerConnection.m b/bp/src/BPTMDRunnerConnection.m index 978c6720..c43835ef 100644 --- a/bp/src/BPTMDRunnerConnection.m +++ b/bp/src/BPTMDRunnerConnection.m @@ -48,6 +48,7 @@ @interface BPTMDRunnerConnection() interface; @property (nonatomic, assign) BOOL connected; +@property (nonatomic, assign) BOOL testBundleReady; @property (nonatomic, strong) dispatch_queue_t queue; @property (nonatomic, strong) NSString *bundleID; @property (nonatomic, assign) pid_t appProcessPID; @@ -76,11 +77,14 @@ - (void)connectWithTimeout:(NSTimeInterval)timeout { // Pool connection status till it passes. [BPUtils runWithTimeOut:timeout until:^BOOL{ - return self.connected; + return self.connected && self.testBundleReady; }]; if (!self.connected) { [BPUtils printInfo:ERROR withString:@"Timeout establishing a runner session!"]; } + if (!self.testBundleReady) { + [BPUtils printInfo:ERROR withString:@"Timeout connecting to the test bundle!"]; + } } - (void)connect { @@ -279,12 +283,14 @@ - (id)_XCT_didBeginExecutingTestPlan { - (id)_XCT_testBundleReadyWithProtocolVersion:(NSNumber *)protocolVersion minimumVersion:(NSNumber *)minimumVersion { self.connected = YES; + self.testBundleReady = YES; [BPUtils printInfo:INFO withString:@"Test bundle is connected. ProtocolVersion= %@, minimumVersion = %@", protocolVersion, minimumVersion]; return nil; } - (id)_XCT_testRunnerReadyWithCapabilities:(XCTCapabilities *)capabilities { self.connected = YES; + self.testBundleReady = YES; [BPUtils printInfo:INFO withString:@"Test bundle is connected. Capabilities = %@", capabilities]; return nil; }