Skip to content

Commit

Permalink
Bluepill w/ Xcode 11 support, more logging, minor fixes and partial r…
Browse files Browse the repository at this point in the history
…evert of bugfix in PR#338 (#361)

* Add more logging

* Minor fixes to fix some warnings and fixing the bluepill.sh for missing xcpretty tool

* Partial revert of "Fix wrong exit status (linkedin#338)"
  • Loading branch information
ravimandala authored and ob committed Sep 26, 2019
1 parent 474b6b5 commit 7ddd815
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .bazel-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.27.0
0.27.1
2 changes: 1 addition & 1 deletion bp/src/BPConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ -(id)copyWithZone:(NSZone *)zone {
}

- (id)mutableCopyWithZone:(NSZone *)zone {
BPConfiguration *newConfig = [[BPConfiguration alloc] initWithProgram:self.program];
BPConfiguration *newConfig = [[BPConfiguration alloc] initWithProgram:(int)self.program];
assert(newConfig);
for(int i = 0; BPOptions[i].name; i++) {
const char *name = BPOptions[i].property;
Expand Down
9 changes: 8 additions & 1 deletion bp/src/Bluepill.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ - (void)retry {
if (self.failureTolerance == 0) {
// If there is no more retries, set the final exitCode to current context's exitCode
self.finalExitStatus = self.context.exitStatus | self.context.finalExitStatus;
[BPUtils printInfo:INFO withString:@"%s:%d finalExitStatus = %@", __FILE__, __LINE__, [BPExitStatusHelper stringFromExitStatus:self.finalExitStatus]];
self.exitLoop = YES;
return;
}
Expand Down Expand Up @@ -155,6 +156,7 @@ - (void)recover {
// If error retry reach to the max, then return
if (self.retries == [self.config.errorRetriesCount integerValue]) {
self.finalExitStatus = self.context.exitStatus | self.context.finalExitStatus;
[BPUtils printInfo:INFO withString:@"%s:%d finalExitStatus = %@", __FILE__, __LINE__, [BPExitStatusHelper stringFromExitStatus:self.finalExitStatus]];
self.exitLoop = YES;
[BPUtils printInfo:ERROR withString:@"Too many retries have occurred. Giving up."];
return;
Expand Down Expand Up @@ -182,6 +184,7 @@ - (void)recover {
- (void)proceed {
if (self.retries == [self.config.errorRetriesCount integerValue]) {
self.finalExitStatus = self.context.exitStatus | self.context.finalExitStatus;
[BPUtils printInfo:INFO withString:@"%s:%d finalExitStatus = %@", __FILE__, __LINE__, [BPExitStatusHelper stringFromExitStatus:self.finalExitStatus]];
self.exitLoop = YES;
[BPUtils printInfo:ERROR withString:@"Too many retries have occurred. Giving up."];
return;
Expand Down Expand Up @@ -600,7 +603,10 @@ - (void)finishWithContext:(BPExecutionContext *)context {

if (![self hasRemainingTestsInContext:context] && (context.attemptNumber <= [context.config.errorRetriesCount integerValue])) {
[BPUtils printInfo:INFO withString:@"No more tests to run."];
self.finalExitStatus = context.exitStatus;
[BPUtils printInfo:INFO withString:@"%s:%d finalExitStatus = %@", __FILE__, __LINE__, [BPExitStatusHelper stringFromExitStatus:self.finalExitStatus]];
// TODO: Temporarily disabling the fix from PR#338 while the issue is being investigated
// self.finalExitStatus = context.exitStatus;
self.finalExitStatus = context.finalExitStatus | context.exitStatus;
self.exitLoop = YES;
return;
}
Expand Down Expand Up @@ -651,6 +657,7 @@ - (void)finishWithContext:(BPExecutionContext *)context {
case BPExitStatusSimulatorDeleted:
case BPExitStatusSimulatorReuseFailed:
self.finalExitStatus = context.exitStatus;
[BPUtils printInfo:INFO withString:@"%s:%d finalExitStatus = %@", __FILE__, __LINE__, [BPExitStatusHelper stringFromExitStatus:self.finalExitStatus]];
self.exitLoop = YES;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions bp/src/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ int main(int argc, char * argv[]) {
NSString *fileName = [NSString stringWithFormat:@"%@-stats.json", [[config.testBundlePath lastPathComponent] stringByDeletingPathExtension]];
NSString *outputFile = [config.outputDirectory stringByAppendingPathComponent:fileName];
BPWriter *statsWriter = [[BPWriter alloc] initWithDestination:BPWriterDestinationFile andPath:outputFile];
[[BPStats sharedStats] exitWithWriter:statsWriter exitCode:exitCode];
[[BPStats sharedStats] exitWithWriter:statsWriter exitCode:(int)exitCode];
}

[BPUtils printInfo:INFO withString:@"BP exiting %ld", (long)exitCode];
return exitCode;
return (int)exitCode;
}
}
5 changes: 3 additions & 2 deletions bp/tests/BluepillTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ - (void)testReportWithAppCrashingAndRetryOnlyFailedTestsSet {
[self assertGotReport:junitReportPath isEqualToWantReport:expectedFilePath];
}

- (void)testAppCrashingAndRetryReportsCorrectExitCode {
// TODO: Enable this while re-enabling the fix from PR#338
- (void)DISABLE_testAppCrashingAndRetryReportsCorrectExitCode {
NSString *testBundlePath = [BPTestHelper sampleAppCrashingTestsBundlePath];
self.config.testBundlePath = testBundlePath;
NSString *tempDir = NSTemporaryDirectory();
Expand Down Expand Up @@ -416,7 +417,7 @@ - (void)testKeepSimulatorWithAppCrashingTestsSet {
}

//simulator shouldn't be kept in this case
- (void)testKeepSimulatorWithAppHaningTestsSet {
- (void)testKeepSimulatorWithAppHangingTestsSet {
NSString *testBundlePath = [BPTestHelper sampleAppHangingTestsBundlePath];
self.config.testBundlePath = testBundlePath;
self.config.keepSimulator = YES;
Expand Down
6 changes: 4 additions & 2 deletions scripts/bluepill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ bluepill_build_sample_app()

bluepill_instance_tests()
{
mkdir -p build/reports/
xcodebuild test \
-workspace Bluepill.xcworkspace \
-scheme bp-tests \
-derivedDataPath "build/" 2>&1 | tee result.txt | $XCPRETTY --output build/reports/instance.xml
-derivedDataPath "build/" 2>&1 | tee result.txt | $XCPRETTY | tee build/reports/instance.xml

if ! grep '\*\* TEST SUCCEEDED \*\*' result.txt; then
echo 'Test failed'
Expand All @@ -101,10 +102,11 @@ bluepill_instance_tests()

bluepill_runner_tests()
{
mkdir -p build/reports/
xcodebuild test \
-workspace Bluepill.xcworkspace \
-scheme bluepill-tests \
-derivedDataPath "build/" 2>&1 | tee result.txt | $XCPRETTY --output build/reports/runner.xml
-derivedDataPath "build/" 2>&1 | tee result.txt | $XCPRETTY | tee build/reports/runner.xml

if ! grep '\*\* TEST SUCCEEDED \*\*' result.txt; then
echo 'Test failed'
Expand Down

0 comments on commit 7ddd815

Please sign in to comment.