Skip to content

Commit

Permalink
Fix test timeout hang (#247)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bayareabear authored and ob committed Feb 22, 2018
1 parent c666708 commit 0aab054
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

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

- (void)setParserStateCompleted;

@end

@protocol BPMonitorCallbackProtocol <NSObject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
- (void)completedFinalRun;
- (void)cleanup;
- (nullable NSString *)generateLog:(nonnull id<BPReporter>)reporter;
- (void)setParserStateCompleted;

@end
2 changes: 2 additions & 0 deletions Bluepill-cli/Bluepill-cli/Simulator/BPSimulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

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

- (void)setParserStateCompleted;

- (BOOL)useSimulatorWithDeviceUDID:(NSUUID *)deviceUDID;

- (BOOL)uninstallApplicationAndReturnError:(NSError **)error;
Expand Down
4 changes: 4 additions & 0 deletions Bluepill-cli/Bluepill-cli/Simulator/BPSimulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ - (void)launchApplicationAndExecuteTestsWithParser:(BPTreeParser *)parser andCom
});
dispatch_source_set_cancel_handler(source, ^{
blockSelf.monitor.appState = Completed;
[parser.delegate setParserStateCompleted];
// Post a APPCLOSED signal to the fifo
[blockSelf.stdOutHandle writeData:[@"\nBP_APP_PROC_ENDED\n" dataUsingEncoding:NSUTF8StringEncoding]];
});
Expand Down Expand Up @@ -470,4 +471,7 @@ - (NSDictionary *)appInfo:(NSString *)bundleID error:(NSError **)error {
return appInfo;
}

- (void)setParserStateCompleted {
}

@end
5 changes: 4 additions & 1 deletion Bluepill-cli/Bluepill-cli/Simulator/SimulatorMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ - (void)onTestSuiteEnded:(NSString *)testSuiteName
- (void)onOutputReceived:(NSString *)output {
NSDate *currentTime = [NSDate date];

assert(self.parserState != Completed);
if (self.parserState == Idle) {
self.parserState = Running;
}
Expand Down Expand Up @@ -286,4 +285,8 @@ - (void)saveScreenshotForFailedTestWithName:(NSString *)testName inClass:(NSStri
[self.screenshotService saveScreenshotForFailedTestWithName:fullTestName];
}

- (void)setParserStateCompleted {
self.parserState = Completed;
}

@end
3 changes: 1 addition & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ compile:

test:
override:
- ./scripts/bluepill.sh test

- ./scripts/bluepill.sh test

0 comments on commit 0aab054

Please sign in to comment.