@@ -82,20 +82,21 @@ and even 'go test .').
82
82
83
83
In local directory mode, go test compiles and tests the package sources
84
84
found in the current directory and then runs the resulting test binary.
85
- In this mode, the test binary runs with standard output and standard error
86
- connected directly to the go command's own standard output and standard
87
- error, and test result caching (discussed below) is disabled.
88
- After the package test finishes, go test prints to standard output a
89
- summary line showing the test status ('ok' or 'FAIL'), package name,
90
- and elapsed time.
85
+ In this mode, caching (discussed below) is disabled. After the package test
86
+ finishes, go test prints a summary line showing the test status ('ok' or 'FAIL'),
87
+ package name, and elapsed time.
91
88
92
89
In package list mode, go test compiles and tests each of the packages
93
90
listed on the command line. If a package test passes, go test prints only
94
91
the final 'ok' summary line. If a package test fails, go test prints the
95
92
full test output. If invoked with the -bench or -v flag, go test prints
96
93
the full output even for passing package tests, in order to display the
97
- requested benchmark results or verbose logging. In package list mode,
98
- go test prints all test output and summary lines to standard output.
94
+ requested benchmark results or verbose logging.
95
+
96
+ All test output and summary lines are printed to the go command's standard
97
+ output, even if the test printed them to its own standard error.
98
+ (The go command's standard error is reserved for printing errors building
99
+ the tests.)
99
100
100
101
In package list mode, go test also caches successful package test results.
101
102
If go test has cached a previous test run using the same test binary and
@@ -1208,36 +1209,17 @@ func (c *runCache) builderRunTest(b *work.Builder, a *work.Action) error {
1208
1209
if len (pkgArgs ) == 0 || testBench {
1209
1210
// Stream test output (no buffering) when no package has
1210
1211
// been given on the command line (implicit current directory)
1211
- // or when benchmarking. Allowing stderr to pass through to
1212
- // stderr here is a bit of an historical mistake, but now a
1213
- // documented one. Except in this case, all output is merged
1214
- // to one stream written to stdout.
1212
+ // or when benchmarking.
1215
1213
cmd .Stdout = os .Stdout
1216
- cmd .Stderr = os .Stderr
1217
1214
} else {
1218
- // If we're only running a single package under test
1219
- // or if parallelism is set to 1, and if we're displaying
1220
- // all output (testShowPass), we can hurry the output along,
1221
- // echoing it as soon as it comes in. We still have to copy
1222
- // to &buf for caching the result. This special case was
1223
- // introduced in Go 1.5 and is intentionally undocumented:
1224
- // the rationale is that the exact details of output buffering
1225
- // are up to the go command and subject to change.
1226
- // NOTE(rsc): Originally this special case also had the effect of
1227
- // allowing stderr to pass through to os.Stderr, unlike
1228
- // the normal buffering that merges stdout and stderr into stdout.
1229
- // This had the truly mysterious result that on a multiprocessor,
1230
- // "go test -v math" could print to stderr,
1231
- // "go test -v math strings" could not, and
1232
- // "go test -p=1 -v math strings" could once again.
1233
- // While I'm willing to let the buffer flush timing
1234
- // fluctuate based on minor details like this,
1235
- // allowing the file descriptor to which output is sent
1236
- // to change as well seems like a serious mistake.
1237
- // Go 1.10 changed this code to allow the less aggressive
1238
- // buffering but still merge all output to standard output.
1239
- // I'd really like to remove this special case entirely,
1240
- // but it is surely very helpful to see progress being made
1215
+ // If we're only running a single package under test or if parallelism is
1216
+ // set to 1, and if we're displaying all output (testShowPass), we can
1217
+ // hurry the output along, echoing it as soon as it comes in.
1218
+ // We still have to copy to &buf for caching the result. This special
1219
+ // case was introduced in Go 1.5 and is intentionally undocumented:
1220
+ // the exact details of output buffering are up to the go command and
1221
+ // subject to change. It would be nice to remove this special case
1222
+ // entirely, but it is surely very helpful to see progress being made
1241
1223
// when tests are run on slow single-CPU ARM systems.
1242
1224
if testShowPass && (len (pkgs ) == 1 || cfg .BuildP == 1 ) {
1243
1225
// Write both to stdout and buf, for possible saving
@@ -1246,8 +1228,8 @@ func (c *runCache) builderRunTest(b *work.Builder, a *work.Action) error {
1246
1228
} else {
1247
1229
cmd .Stdout = & buf
1248
1230
}
1249
- cmd .Stderr = cmd .Stdout
1250
1231
}
1232
+ cmd .Stderr = cmd .Stdout
1251
1233
1252
1234
// If there are any local SWIG dependencies, we want to load
1253
1235
// the shared library from the build directory.
0 commit comments