Skip to content

Commit 08d3951

Browse files
authored
Do not retry crashed tests (#443)
Based on previous changes crashed tests are fatal and would always return a non-zero exit code. With this change, the crashed tests are NOT retried to make sure the app crash errors are surfaced without confusion. Also added new tests and fixed existing ones as per the new no-retry behavior.
1 parent 91ecdd6 commit 08d3951

File tree

4 files changed

+56
-13
lines changed

4 files changed

+56
-13
lines changed

bluepill/tests/BPIntegrationTests.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ - (void)testClonedSimulators {
9090
config.failureTolerance = @0;
9191
config.cloneSimulator = TRUE;
9292
// need to validate the configuration to fill in simDevice and simRuntime
93-
[config validateConfigWithError:nil];
94-
NSError *err;
93+
NSError *err = nil;
94+
[config validateConfigWithError:&err];
95+
XCTAssert(err == nil);
9596
BPApp *app = [BPApp appWithConfig:config
9697
withError:&err];
9798

bp/src/SimulatorMonitor.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ - (void)onOutputReceived:(NSString *)output {
195195
NSString *testClass = (__self.currentClassName ?: __self.previousClassName);
196196
NSString *testName = (__self.currentTestName ?: __self.previousTestName);
197197
if (__self.testsState == Running) {
198-
[BPUtils printInfo:CRASH withString:@"%@/%@ crashed app.", testClass, testName];
198+
[self updateExecutedTestCaseList:testName inClass:testClass];
199+
[BPUtils printInfo:CRASH withString:@"%@/%@ crashed app. Not retrying it.", testClass, testName];
199200
[[BPStats sharedStats] endTimer:[NSString stringWithFormat:TEST_CASE_FORMAT, [BPStats sharedStats].attemptNumber, testClass, testName] withResult:@"CRASHED"];
200201
} else {
201202
assert(__self.testsState == Idle);

bp/tests/BluepillTests.m

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,12 @@ - (void)testReportFailureOnTimeoutCrashAndPass {
346346
}
347347

348348
/**
349-
Execution plan: CRASH, TIMEOUT, PASS
349+
Execution plan: CRASH
350350
*/
351-
- (void)testReportFailureOnCrashTimeoutAndPass {
351+
- (void)testNoRetryOnCrash {
352352
self.config.stuckTimeout = @6;
353-
self.config.testing_ExecutionPlan = @"CRASH TIMEOUT PASS";
353+
self.config.testing_ExecutionPlan = @"CRASH"; // No retry
354+
self.config.errorRetriesCount = @4;
354355
self.config.onlyRetryFailed = TRUE;
355356
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
356357
self.config.testBundlePath = testBundlePath;
@@ -364,6 +365,49 @@ - (void)testReportFailureOnCrashTimeoutAndPass {
364365
XCTAssertTrue(exitCode == BPExitStatusAppCrashed);
365366
}
366367

368+
369+
/**
370+
Execution plan: One test CRASHes and another one TIMEs OUT and PASSes on retry
371+
*/
372+
- (void)testReportFailureOnCrashAndTimeoutTests {
373+
self.config.stuckTimeout = @6;
374+
self.config.testing_ExecutionPlan = @"CRASH; SKIP TIMEOUT PASS";
375+
self.config.onlyRetryFailed = TRUE;
376+
self.config.failureTolerance = @1;
377+
self.config.errorRetriesCount = @2;
378+
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
379+
self.config.testBundlePath = testBundlePath;
380+
NSString *tempDir = NSTemporaryDirectory();
381+
NSError *error;
382+
NSString *outputDir = [BPUtils mkdtemp:[NSString stringWithFormat:@"%@/AppHangingTestsSetTempDir", tempDir] withError:&error];
383+
NSLog(@"output directory is %@", outputDir);
384+
self.config.outputDirectory = outputDir;
385+
386+
BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration:self.config] run];
387+
XCTAssertTrue(exitCode == BPExitStatusAppCrashed);
388+
}
389+
390+
/**
391+
Execution plan: One test CRASHes and another one keeps timing out
392+
*/
393+
- (void)testReportBothCrashAndTimeout {
394+
self.config.stuckTimeout = @6;
395+
self.config.testing_ExecutionPlan = @"CRASH; SKIP TIMEOUT TIMEOUT";
396+
self.config.onlyRetryFailed = TRUE;
397+
self.config.failureTolerance = @1;
398+
self.config.errorRetriesCount = @2;
399+
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
400+
self.config.testBundlePath = testBundlePath;
401+
NSString *tempDir = NSTemporaryDirectory();
402+
NSError *error;
403+
NSString *outputDir = [BPUtils mkdtemp:[NSString stringWithFormat:@"%@/AppHangingTestsSetTempDir", tempDir] withError:&error];
404+
NSLog(@"output directory is %@", outputDir);
405+
self.config.outputDirectory = outputDir;
406+
407+
BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration:self.config] run];
408+
XCTAssertTrue(exitCode == (BPExitStatusAppCrashed | BPExitStatusTestTimeout));
409+
}
410+
367411
/**
368412
Execution plan: FAIL, TIMEOUT, PASS
369413
*/
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuites name="Selected tests" tests="1" failures="1" errors="0">
3-
<testsuite tests="1" failures="1" errors="0" name="BPSampleAppCrashingTests.xctest">
4-
<testsuite tests="1" failures="1" errors="0" name="BPSampleAppCrashingTests">
5-
<testcase classname="BPSampleAppCrashingTests" name="testAppCrash1">
6-
<failure type="Failure" message="App Crashed"></failure>
7-
<system-out></system-out>
8-
</testcase>
2+
<testsuites name="Selected tests" tests="1" failures="0" errors="0">
3+
<testsuite tests="1" failures="0" errors="0" name="BPSampleAppCrashingTests.xctest">
4+
<testsuite tests="1" failures="0" errors="0" name="BPSampleAppCrashingTests">
5+
<testcase classname="BPSampleAppCrashingTests" name="testAppCrash2"></testcase>
96
</testsuite>
107
</testsuite>
118
</testsuites>

0 commit comments

Comments
 (0)