Skip to content

Commit

Permalink
Do not retry crashed tests (#443)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ravimandala authored Jun 15, 2020
1 parent 91ecdd6 commit 08d3951
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
5 changes: 3 additions & 2 deletions bluepill/tests/BPIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ - (void)testClonedSimulators {
config.failureTolerance = @0;
config.cloneSimulator = TRUE;
// need to validate the configuration to fill in simDevice and simRuntime
[config validateConfigWithError:nil];
NSError *err;
NSError *err = nil;
[config validateConfigWithError:&err];
XCTAssert(err == nil);
BPApp *app = [BPApp appWithConfig:config
withError:&err];

Expand Down
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
11 changes: 4 additions & 7 deletions bp/tests/Resource Files/crash_tests_with_retry_attempt_2.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Selected tests" tests="1" failures="1" errors="0">
<testsuite tests="1" failures="1" errors="0" name="BPSampleAppCrashingTests.xctest">
<testsuite tests="1" failures="1" errors="0" name="BPSampleAppCrashingTests">
<testcase classname="BPSampleAppCrashingTests" name="testAppCrash1">
<failure type="Failure" message="App Crashed"></failure>
<system-out></system-out>
</testcase>
<testsuites name="Selected tests" tests="1" failures="0" errors="0">
<testsuite tests="1" failures="0" errors="0" name="BPSampleAppCrashingTests.xctest">
<testsuite tests="1" failures="0" errors="0" name="BPSampleAppCrashingTests">
<testcase classname="BPSampleAppCrashingTests" name="testAppCrash2"></testcase>
</testsuite>
</testsuite>
</testsuites>

0 comments on commit 08d3951

Please sign in to comment.