Skip to content

Commit a5aaa33

Browse files
committed
Fix a problem with [terminateApplicationWithID] not working reliably.
Just kill it, it’s old school cool.
1 parent 72db61a commit a5aaa33

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ - (void)onOutputReceived:(NSString *)output {
204204
}
205205

206206
- (void)stopTestsWithErrorMessage:(NSString *)message forTestName:(NSString *)testName inClass:(NSString *)testClass {
207-
NSError *error = nil;
208207

209208
// Timeout or crash on a test means we should skip it when we rerun the tests
210209
[self updateExecutedTestCaseList:testName inClass:testClass];
211210

212211
if (![[self.device stateString] isEqualToString:@"Shutdown"]) {
213-
[self.device terminateApplicationWithID:self.hostBundleId error:&error];
214-
if (error) {
215-
fprintf(stderr, "stopTests: %s\n", [[error description] UTF8String]);
212+
// self.appPID can be zero when running the parsing tests
213+
// since we're not actually creating a simulator and running an app.
214+
if (self.appPID && (kill(self.appPID, SIGTERM) < 0)) {
215+
perror("kill");
216216
}
217217
}
218218

Bluepill-cli/Bluepill-cli/Simulator/SimulatorRunner.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ - (void)launchApplicationAndExecuteTestsWithParser:(BPTreeParser *)parser andCom
283283
dispatch_source_cancel(source);
284284
});
285285
__block __weak SimulatorRunner *weakSelf = self;
286+
weakSelf.monitor.appPID = pid;
286287
dispatch_source_set_cancel_handler(source, ^{
287288
// Post a APPCLOSED signal to the fifo
288289
[weakSelf.stdOutHandle writeData:[@"\nBP_APP_PROC_ENDED\n" dataUsingEncoding:NSUTF8StringEncoding]];

0 commit comments

Comments
 (0)