mirror of
https://github.com/golang/go
synced 2024-11-26 17:46:57 -07:00
Revert "cmd/go/internal/test: wrap os.Stdout always"
This reverts CL 400877. Reason for revert: broke TestScript/test_output_wait and the regression test for #18153 on certain builders. Fixes #52461. Change-Id: I98627ce5e22088b0784be502c459480c41ba353a Reviewed-on: https://go-review.googlesource.com/c/go/+/401494 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
b941a10e38
commit
115852077f
@ -1261,11 +1261,7 @@ func (c *runCache) builderRunTest(b *work.Builder, ctx context.Context, a *work.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// The os/exec package treats an *os.File differently to an io.Writer.
|
var stdout io.Writer = os.Stdout
|
||||||
// Embed os.Stdout in an io.Writer struct so that we get the same
|
|
||||||
// behavior regardless of whether we wrap it below.
|
|
||||||
// See golang.org/issue/24050
|
|
||||||
var stdout io.Writer = struct{ io.Writer }{os.Stdout}
|
|
||||||
var err error
|
var err error
|
||||||
if testJSON {
|
if testJSON {
|
||||||
json := test2json.NewConverter(lockedStdout{}, a.Package.ImportPath, test2json.Timestamp)
|
json := test2json.NewConverter(lockedStdout{}, a.Package.ImportPath, test2json.Timestamp)
|
||||||
|
35
src/cmd/go/testdata/script/test_output_wait.txt
vendored
35
src/cmd/go/testdata/script/test_output_wait.txt
vendored
@ -1,35 +0,0 @@
|
|||||||
# Wait for test output from sub-processes whether or not the package name is
|
|
||||||
# provided on the command-line.
|
|
||||||
go test -v
|
|
||||||
stdout 'PASS\s+WAIT\s+ok'
|
|
||||||
go test -v .
|
|
||||||
stdout 'PASS\s+WAIT\s+ok'
|
|
||||||
|
|
||||||
-- go.mod --
|
|
||||||
module x
|
|
||||||
|
|
||||||
-- x_test.go --
|
|
||||||
package x
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
if os.Getenv("WAIT") == "true" {
|
|
||||||
os.Stdout.Write([]byte("WAIT\n"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWait(t *testing.T) {
|
|
||||||
cmd := exec.Command(os.Args[0])
|
|
||||||
cmd.Env = []string{"WAIT=true"}
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
if err := cmd.Start(); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user