Skip to content

Commit

Permalink
Trigger the test when the bundle is actually connected (#547)
Browse files Browse the repository at this point in the history
Signed-off-by: Nan Wang <[email protected]>

Signed-off-by: Nan Wang <[email protected]>
  • Loading branch information
nanwng authored and Shawn Chen committed Dec 20, 2022
1 parent dd6d563 commit 304ddfb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bp/src/BPTMDRunnerConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ @interface BPTMDRunnerConnection()<XCTMessagingChannel_DaemonToIDE, XCTMessaging

@property (nonatomic, weak) id<BPTestBundleConnectionDelegate> 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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 304ddfb

Please sign in to comment.