Skip to content

Commit

Permalink
Do not retry crashed tests
Browse files Browse the repository at this point in the history
Based on recent change crashed tests are fatal and would always return a non-zero exit code. After 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.
  • Loading branch information
ravimandala committed May 21, 2020
1 parent 89010ca commit ba6d530
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bp/src/SimulatorMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ - (void)onOutputReceived:(NSString *)output {
NSString *testClass = (__self.currentClassName ?: __self.previousClassName);
NSString *testName = (__self.currentTestName ?: __self.previousTestName);
if (__self.testsState == Running) {
[BPUtils printInfo:CRASH withString:@"%@/%@ crashed app.", testClass, testName];
[self updateExecutedTestCaseList:testName inClass:testClass];
[BPUtils printInfo:CRASH withString:@"%@/%@ crashed app. Not retrying it.", testClass, testName];
[[BPStats sharedStats] endTimer:[NSString stringWithFormat:TEST_CASE_FORMAT, [BPStats sharedStats].attemptNumber, testClass, testName] withResult:@"CRASHED"];
} else {
assert(__self.testsState == Idle);
Expand Down
50 changes: 47 additions & 3 deletions bp/tests/BluepillTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@ - (void)testReportFailureOnTimeoutCrashAndPass {
}

/**
Execution plan: CRASH, TIMEOUT, PASS
Execution plan: CRASH
*/
- (void)testReportFailureOnCrashTimeoutAndPass {
- (void)testNoRetryOnCrash {
self.config.stuckTimeout = @6;
self.config.testing_ExecutionPlan = @"CRASH TIMEOUT PASS";
self.config.testing_ExecutionPlan = @"CRASH"; // No retry
self.config.errorRetriesCount = @4;
self.config.onlyRetryFailed = TRUE;
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
self.config.testBundlePath = testBundlePath;
Expand All @@ -364,6 +365,49 @@ - (void)testReportFailureOnCrashTimeoutAndPass {
XCTAssertTrue(exitCode == BPExitStatusAppCrashed);
}


/**
Execution plan: One test CRASHes and another one TIMEs OUT and PASSes on retry
*/
- (void)testReportFailureOnCrashAndTimeoutTests {
self.config.stuckTimeout = @6;
self.config.testing_ExecutionPlan = @"CRASH; SKIP TIMEOUT PASS";
self.config.onlyRetryFailed = TRUE;
self.config.failureTolerance = @1;
self.config.errorRetriesCount = @2;
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
self.config.testBundlePath = testBundlePath;
NSString *tempDir = NSTemporaryDirectory();
NSError *error;
NSString *outputDir = [BPUtils mkdtemp:[NSString stringWithFormat:@"%@/AppHangingTestsSetTempDir", tempDir] withError:&error];
NSLog(@"output directory is %@", outputDir);
self.config.outputDirectory = outputDir;

BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration:self.config] run];
XCTAssertTrue(exitCode == BPExitStatusAppCrashed);
}

/**
Execution plan: One test CRASHes and another one keeps timing out
*/
- (void)testReportBothCrashAndTimeout {
self.config.stuckTimeout = @6;
self.config.testing_ExecutionPlan = @"CRASH; SKIP TIMEOUT TIMEOUT";
self.config.onlyRetryFailed = TRUE;
self.config.failureTolerance = @1;
self.config.errorRetriesCount = @2;
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
self.config.testBundlePath = testBundlePath;
NSString *tempDir = NSTemporaryDirectory();
NSError *error;
NSString *outputDir = [BPUtils mkdtemp:[NSString stringWithFormat:@"%@/AppHangingTestsSetTempDir", tempDir] withError:&error];
NSLog(@"output directory is %@", outputDir);
self.config.outputDirectory = outputDir;

BPExitStatus exitCode = [[[Bluepill alloc ] initWithConfiguration:self.config] run];
XCTAssertTrue(exitCode == (BPExitStatusAppCrashed | BPExitStatusTestTimeout));
}

/**
Execution plan: FAIL, TIMEOUT, PASS
*/
Expand Down

0 comments on commit ba6d530

Please sign in to comment.