-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#185 #189 process termination code #190
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,9 @@ public enum TestSuiteOutcome: String, Codable { | |
} | ||
|
||
extension TestSuiteOutcome { | ||
public static func from(testLog: String) -> TestSuiteOutcome { | ||
public static func from(testLog: String, terminationStatus: Int32) -> TestSuiteOutcome { | ||
|
||
if logContainsRuntimeError(testLog) { | ||
if !terminationStatusIsSuccess(terminationStatus) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think regression tests are still passing, right? Because I think |
||
return .runtimeError | ||
} else if logContainsBuildError(testLog) { | ||
return .buildError | ||
|
@@ -53,8 +53,8 @@ extension TestSuiteOutcome { | |
return try! NSRegularExpression(pattern: "with ([1-9]{1}[0-9]{0,}) failure", options: []) | ||
} | ||
|
||
static private func logContainsRuntimeError(_ testLog: String) -> Bool { | ||
return testLog.contains("Fatal error") | ||
static private func terminationStatusIsSuccess(_ terminationStatus: Int32) -> Bool { | ||
return terminationStatus == 0 | ||
} | ||
|
||
static private func logContainsBuildError(_ testLog: String) -> Bool { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,55 +9,60 @@ class TestSuiteResultParsingSpec: QuickSpec { | |
context("when a test log doesn't contain a failure, runtime error, or build error") { | ||
it("returns a passed test result") { | ||
var contents = loadLogFile(named: "testRunWithoutFailures_withTestSucceededFooter.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.passed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.passed)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree (left a comment above b4 reading it, sorry 😄 ) |
||
|
||
contents = loadLogFile(named: "testRunWithoutFailures_withTestSucceededFooter_buckOutput.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.passed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.passed)) | ||
} | ||
} | ||
|
||
context("when a test log contains a failure") { | ||
it("returns a failed test result") { | ||
var contents = loadLogFile(named: "testRunWithFailures_withoutTestFailedFooter.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.failed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.failed)) | ||
|
||
contents = loadLogFile(named: "testRunWithFailures_withTestFailedFooter.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.failed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.failed)) | ||
|
||
contents = loadLogFile(named: "testRunWithFailures_withTestFailedFooter_singleTestFailure.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.failed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.failed)) | ||
|
||
contents = loadLogFile(named: "testRunWithFailures_withTestFailedFooter_noTestFailureCount.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.failed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.failed)) | ||
|
||
contents = loadLogFile(named: "testRunWithFailures_withTestFailedFooter_buckOutput.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.failed)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.failed)) | ||
} | ||
} | ||
|
||
context("when a test log contains a fatal error") { | ||
it("returns a runtime error") { | ||
it("does not return a runtime error if the termination status was 0") { | ||
let contents = loadLogFile(named: "runtimeError_fatalError.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.runtimeError)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.passed)) | ||
} | ||
it("returns a runtime error if the termination status was not 0") { | ||
let contents = loadLogFile(named: "runtimeError_fatalError.log") | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: -127)).to(equal(.runtimeError)) | ||
} | ||
|
||
} | ||
|
||
context("when a test log contains a build error") { | ||
it("returns a build error") { | ||
var contents = loadLogFile(named: "buildError_missingProjectFile.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.buildError)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.buildError)) | ||
|
||
contents = loadLogFile(named: "buildError_runScriptStepFailed.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.buildError)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.buildError)) | ||
|
||
contents = loadLogFile(named: "buildError_invalidSwiftCode.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.buildError)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.buildError)) | ||
|
||
contents = loadLogFile(named: "buildError_withTestFailedFooter.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.buildError)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.buildError)) | ||
|
||
contents = loadLogFile(named: "buildError_buckOutput.log") | ||
expect(TestSuiteOutcome.from(testLog: contents)).to(equal(.buildError)) | ||
expect(TestSuiteOutcome.from(testLog: contents, terminationStatus: 0)).to(equal(.buildError)) | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the same behaviour as we had before? It seems now that the file handle is closed after we attempt to read it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer happens right before the scope closes. It should be the same behavior as before, but now it'll still happen if we add an early return. I was originally going to use a
guard
in an earlier version of this PR. I ended up not doing it, but I still like usingdefer
foropen
/close
patterns.