Skip to content

Commit 0aab054

Browse files
bayareabearob
authored andcommitted
Fix test timeout hang (#247)
We've seen cases where if a test times out, the `bp` process will hang waiting for the `BP_APP_PROC_ENDED` marker, which never gets put into the input. This fixes it by avoiding the marker entirely and just notifying the Simulator Monitor directly.
1 parent c666708 commit 0aab054

6 files changed

Lines changed: 14 additions & 3 deletions

File tree

Bluepill-cli/Bluepill-cli/Bluepill/Reporters/BPExecutionPhaseProtocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
- (void)onOutputReceived:(NSString *)output;
3434

35+
- (void)setParserStateCompleted;
36+
3537
@end
3638

3739
@protocol BPMonitorCallbackProtocol <NSObject>

Bluepill-cli/Bluepill-cli/Bluepill/Reporters/BPTreeParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@
5858
- (void)completedFinalRun;
5959
- (void)cleanup;
6060
- (nullable NSString *)generateLog:(nonnull id<BPReporter>)reporter;
61+
- (void)setParserStateCompleted;
6162

6263
@end

Bluepill-cli/Bluepill-cli/Simulator/BPSimulator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
- (void)createSimulatorWithDeviceName:(NSString *)deviceName completion:(void (^)(NSError *))completion;
3131

32+
- (void)setParserStateCompleted;
33+
3234
- (BOOL)useSimulatorWithDeviceUDID:(NSUUID *)deviceUDID;
3335

3436
- (BOOL)uninstallApplicationAndReturnError:(NSError **)error;

Bluepill-cli/Bluepill-cli/Simulator/BPSimulator.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ - (void)launchApplicationAndExecuteTestsWithParser:(BPTreeParser *)parser andCom
358358
});
359359
dispatch_source_set_cancel_handler(source, ^{
360360
blockSelf.monitor.appState = Completed;
361+
[parser.delegate setParserStateCompleted];
361362
// Post a APPCLOSED signal to the fifo
362363
[blockSelf.stdOutHandle writeData:[@"\nBP_APP_PROC_ENDED\n" dataUsingEncoding:NSUTF8StringEncoding]];
363364
});
@@ -470,4 +471,7 @@ - (NSDictionary *)appInfo:(NSString *)bundleID error:(NSError **)error {
470471
return appInfo;
471472
}
472473

474+
- (void)setParserStateCompleted {
475+
}
476+
473477
@end

Bluepill-cli/Bluepill-cli/Simulator/SimulatorMonitor.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ - (void)onTestSuiteEnded:(NSString *)testSuiteName
191191
- (void)onOutputReceived:(NSString *)output {
192192
NSDate *currentTime = [NSDate date];
193193

194-
assert(self.parserState != Completed);
195194
if (self.parserState == Idle) {
196195
self.parserState = Running;
197196
}
@@ -286,4 +285,8 @@ - (void)saveScreenshotForFailedTestWithName:(NSString *)testName inClass:(NSStri
286285
[self.screenshotService saveScreenshotForFailedTestWithName:fullTestName];
287286
}
288287

288+
- (void)setParserStateCompleted {
289+
self.parserState = Completed;
290+
}
291+
289292
@end

circle.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ compile:
88

99
test:
1010
override:
11-
- ./scripts/bluepill.sh test
12-
11+
- ./scripts/bluepill.sh test

0 commit comments

Comments
 (0)