-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: (*B).Fatal should cause non-zero exit status #14307
Comments
The subject of the issue does not match the behavior of the program, and there is no explanatory text. Please explain. |
|
t.Fatal does not terminate the program. It terminates the test function. b.Fatal seems to do that as well, or at least your example does not demonstrate otherwise. It looks like there is an issue that b.Fatal does not cause the program to exit with a non-zero exit code. Is that what you're saying? |
I am sorry, you are correct. But calling t.Fatal in a test will cause the On Sat, 13 Feb 2016, 09:32 Rob Pike notifications@github.com wrote:
|
@davecheney want to change the issue title? Maybe "testing: (*B).Fatal should cause non-zero exit status". I took a brief look at this. The code does this right now (irrelevant lines elided): testOk := RunTests(m.matchString, m.tests)
exampleOk := RunExamples(m.matchString, m.examples)
if !testOk || !exampleOk {
fmt.Println("FAIL")
return 1
}
fmt.Println("PASS")
RunBenchmarks(m.matchString, m.benchmarks)
return 0 Unfortunately the exported function RunBenchmarks doesn't return failure status. Perhaps we could modify InternalBenchmark to smuggle failure status through. If we fix this, should we also only print "PASS" if benchmarks pass, as well as tests and examples? |
Would adding a return value to RunBenchmarks break the compatibility promise? It seems to me it keeps the source compatibility since ignoring the single return value doesn't require any change to calling code. |
Yes. |
@bradfitz Thanks for the link. I wrote a CL that adds an extra field to the struct InternalBenchmark to pass the information (a "failed bool" field). It does pass the API check in all.bash, and seems "acceptable" from reading https://golang.org/doc/go1compat document, and the Internal in the name makes me thing is not widely used. On the other hand it doesn't pass the criteria from the post you've linked. So I'm a bit unsure whether is OK or not. Pushed the CL in https://go-review.googlesource.com/#/c/19889/. |
CL https://golang.org/cl/19889 mentions this issue. |
Ian had a better suggestion without having to add a field to the exported struct, it became patch set 3 in the CL. I'm still curious about the compatibility: because of the embedding explanation mentioned in the link, is adding fields a no-go for exported structs? |
In the compatibility doc (https://golang.org/doc/go1compat) we explicitly permit adding fields to exported structs. |
The text was updated successfully, but these errors were encountered: