Skip to content

Commit

Permalink
Merge a few crash tickets fix and static linking fix (#198)
Browse files Browse the repository at this point in the history

* Add debug print out for crash at calling "logEntry.log = [logEntry.log stringByAppendingString:@"\n"];" and "return [BPTreeAssembler sharedInstance].currentTest;". Suspect these two crash are caused by nil pointers

* update with coding style changes for previous commit

* remove extra debug print out:TOOLS-154094, so far no more report for the two crash points

* TOOLS-155868: iOS simulator crash
Potential fix for two crash points, suspect both are caused by null pointers

Crash point:
10 bluepill 0x000000010a667769 -[BPRunner runWithBPXCTestFiles:] + 1932 (BPRunner.m:228)
11 bluepill 0x000000010a66186a main + 994 (main.m:101)

10 bp 0x000000010b187c01 +[BPUtils runShell:] + 269 (BPUtils.m:182)
11 bp 0x000000010b1a54e1 main + 1234 (main.m:36)

* add -s option to xargs for static linking

* Removed debug log
  • Loading branch information
bayareabear authored Sep 22, 2017
1 parent 7069db6 commit 86b664e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Bluepill-cli/Bluepill-cli/Bluepill/Reporters/BPTreeParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ - (void)parseLine:(nullable NSString *)line {
}
logEntry = self.current;
}
if (logEntry.log == nil) {
logEntry.log = @"";
}
logEntry.log = [logEntry.log stringByAppendingString:line];
logEntry.log = [logEntry.log stringByAppendingString:@"\n"];
}
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-runner/Bluepill-runner/BPRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ - (int)runWithBPXCTestFiles:(NSArray<BPXCTestFile *> *)xcTestFiles {
rc = (rc || [task terminationStatus]);
}];
if (!task) {
NSLog(@"Failed to launch: %@ %@", [task launchPath], [task arguments]);
[BPUtils printInfo:ERROR withString:@"task is nil!"];
exit(1);
}
[task launch];
Expand Down
1 change: 0 additions & 1 deletion Bluepill-runner/BluepillRunnerTests/BPIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ - (void)testTwoBPInstancesWithXCTestRunFile {
int rc = [runner runWithBPXCTestFiles:app.testBundles];
XCTAssert(app.testBundles[1].skipTestIdentifiers.count == 7);
XCTAssert(rc != 0); // this runs tests that fail

}

- (void)testTwoBPInstancesTestCaseFail {
Expand Down
17 changes: 13 additions & 4 deletions Source/Shared/BPUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,24 @@ + (BOOL)isStdOut:(NSString *)fileName {

+ (NSString *)runShell:(NSString *)command {
NSAssert(command, @"Command should not be nil");
NSTask *task = [NSTask new];
NSTask *task = [[NSTask alloc] init];
NSData *data;
task.launchPath = @"/bin/sh";
task.arguments = @[@"-c", command];
NSPipe *pipe = [NSPipe new];
NSPipe *pipe = [[NSPipe alloc] init];
task.standardError = pipe;
task.standardOutput = pipe;
NSFileHandle *fh = pipe.fileHandleForReading;
[task launch];
NSData *data = [fh readDataToEndOfFile];
if (task) {
[task launch];
} else {
NSAssert(task, @"task should not be nil");
}
if (fh) {
data = [fh readDataToEndOfFile];
} else {
NSAssert(task, @"fh should not be nil");
}
[task waitUntilExit];
return [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/BPXCTestFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@implementation BPXCTestFile

NSString *swiftNmCmdline = @"nm -gU '%@' | cut -d' ' -f3 | xargs xcrun swift-demangle | cut -d' ' -f3 | grep -e '[\\.|_]'test";
NSString *swiftNmCmdline = @"nm -gU '%@' | cut -d' ' -f3 | xargs -s 131072 xcrun swift-demangle | cut -d' ' -f3 | grep -e '[\\.|_]'test";
NSString *objcNmCmdline = @"nm -U '%@' | grep ' t ' | cut -d' ' -f3,4 | cut -d'-' -f2 | cut -d'[' -f2 | cut -d']' -f1 | grep ' test'";

+ (instancetype)BPXCTestFileFromXCTestBundle:(NSString *)testBundlePath
Expand Down

0 comments on commit 86b664e

Please sign in to comment.