]> Cypherpunks repositories - gostls13.git/commit
testing: do not require os.Exit in TestMain
authorChangkun Ou <hi@changkun.us>
Sun, 16 Feb 2020 13:42:29 +0000 (14:42 +0100)
committerIan Lance Taylor <iant@golang.org>
Tue, 17 Mar 2020 00:45:15 +0000 (00:45 +0000)
commit2f54081adfc967836842c96619d241378400ece6
treef60d3f67c7ca1c815b2a4a8e8456fce4264c76f1
parent2fbca94db7e14fc1d18162cd203d7afc19b520e8
testing: do not require os.Exit in TestMain

If TestMain reports a wrong exit code to os.Exit, the test will be
exited with exist code inconsist with test results.

This CL eliminates the requirement of calling os.Exit in TestMain.
Now, m.Run records the execution status of its test, the outer
main func will call os.Exit with that exit code if TestMain does
not call os.Exit.

If TestMain does not call m.Run, the outer main func remain calls
os.Exit(0) as before.

Fixes #34129

Change-Id: I9598023e03b0a6260f0217f34df41c231c7d6489
Reviewed-on: https://go-review.googlesource.com/c/go/+/219639
Reviewed-by: Ian Lance Taylor <iant@golang.org>
doc/go1.15.html
src/cmd/go/internal/load/test.go
src/cmd/go/testdata/script/list_importmap.txt
src/cmd/go/testdata/script/list_test_imports.txt
src/cmd/go/testdata/script/test_main.txt
src/testing/testing.go