mirror of
https://github.com/golang/go
synced 2024-11-25 21:18:02 -07:00
cmd/go: send output of build and install to stderr
"go build" and "go install" were mixing stdout and stderr from the toolchain, then putting it all on stdout. With this change, it stays mixed, and is sent to stderr. Because the toolchain does not create output in a clean compile/install, sending all output to stderr makese more sense. Also fix test.bash because of "mktemp: too few X's in template `testgo'" on Linux. Fixes #4917. R=golang-dev, rsc, adg CC=golang-dev https://golang.org/cl/7393073
This commit is contained in:
parent
77d6cf1cd5
commit
53f034c7a8
@ -391,7 +391,9 @@ var (
|
|||||||
|
|
||||||
func (b *builder) init() {
|
func (b *builder) init() {
|
||||||
var err error
|
var err error
|
||||||
b.print = fmt.Print
|
b.print = func(a ...interface{}) (int, error) {
|
||||||
|
return fmt.Fprint(os.Stderr, a...)
|
||||||
|
}
|
||||||
b.actionCache = make(map[cacheKey]*action)
|
b.actionCache = make(map[cacheKey]*action)
|
||||||
b.mkdirCache = make(map[string]bool)
|
b.mkdirCache = make(map[string]bool)
|
||||||
|
|
||||||
@ -1632,7 +1634,7 @@ func (b *builder) libgcc(p *Package) (string, error) {
|
|||||||
// print function to capture the command-line. This
|
// print function to capture the command-line. This
|
||||||
// let's us assign it to $LIBGCC and produce a valid
|
// let's us assign it to $LIBGCC and produce a valid
|
||||||
// buildscript for cgo packages.
|
// buildscript for cgo packages.
|
||||||
b.print = func(a ...interface{}) (n int, err error) {
|
b.print = func(a ...interface{}) (int, error) {
|
||||||
return fmt.Fprint(&buf, a...)
|
return fmt.Fprint(&buf, a...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,19 @@ ok=true
|
|||||||
unset GOPATH
|
unset GOPATH
|
||||||
unset GOBIN
|
unset GOBIN
|
||||||
|
|
||||||
# Test that error messages have file:line information
|
# Test that error messages have file:line information at beginning of
|
||||||
# at beginning of line.
|
# the line. Also test issue 4917: that the error is on stderr.
|
||||||
for i in testdata/errmsg/*.go
|
d=$(mktemp -d -t testgoXXX)
|
||||||
do
|
fn=$d/err.go
|
||||||
# TODO: |cat should not be necessary here but is.
|
echo "package main" > $fn
|
||||||
./testgo test $i 2>&1 | cat >err.out || true
|
echo 'import "bar"' >> $fn
|
||||||
if ! grep -q "^$i:" err.out; then
|
./testgo run $fn 2>$d/err.out || true
|
||||||
echo "$i: missing file:line in error message"
|
if ! grep -q "^$fn:" $d/err.out; then
|
||||||
cat err.out
|
echo "missing file:line in error message"
|
||||||
|
cat $d/err.out
|
||||||
ok=false
|
ok=false
|
||||||
fi
|
fi
|
||||||
done
|
rm -r $d
|
||||||
|
|
||||||
# Test local (./) imports.
|
# Test local (./) imports.
|
||||||
testlocal() {
|
testlocal() {
|
||||||
@ -51,7 +52,7 @@ testlocal() {
|
|||||||
ok=false
|
ok=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f err.out hello.out hello
|
rm -f hello.out hello
|
||||||
|
|
||||||
# Test that go install x.go fails.
|
# Test that go install x.go fails.
|
||||||
if ./testgo install "testdata/$local/easy.go" >/dev/null 2>&1; then
|
if ./testgo install "testdata/$local/easy.go" >/dev/null 2>&1; then
|
||||||
@ -183,7 +184,7 @@ fi
|
|||||||
|
|
||||||
# issue 4186. go get cannot be used to download packages to $GOROOT
|
# issue 4186. go get cannot be used to download packages to $GOROOT
|
||||||
# Test that without GOPATH set, go get should fail
|
# Test that without GOPATH set, go get should fail
|
||||||
d=$(mktemp -d -t testgo)
|
d=$(mktemp -d -t testgoXXX)
|
||||||
mkdir -p $d/src/pkg
|
mkdir -p $d/src/pkg
|
||||||
if GOPATH= GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch ; then
|
if GOPATH= GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch ; then
|
||||||
echo 'go get code.google.com/p/go.codereview/cmd/hgpatch should not succeed with $GOPATH unset'
|
echo 'go get code.google.com/p/go.codereview/cmd/hgpatch should not succeed with $GOPATH unset'
|
||||||
@ -191,7 +192,7 @@ if GOPATH= GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch
|
|||||||
fi
|
fi
|
||||||
rm -rf $d
|
rm -rf $d
|
||||||
# Test that with GOPATH=$GOROOT, go get should fail
|
# Test that with GOPATH=$GOROOT, go get should fail
|
||||||
d=$(mktemp -d -t testgo)
|
d=$(mktemp -d -t testgoXXX)
|
||||||
mkdir -p $d/src/pkg
|
mkdir -p $d/src/pkg
|
||||||
if GOPATH=$d GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch ; then
|
if GOPATH=$d GOROOT=$d ./testgo get -d code.google.com/p/go.codereview/cmd/hgpatch ; then
|
||||||
echo 'go get code.google.com/p/go.codereview/cmd/hgpatch should not succeed with GOPATH=$GOROOT'
|
echo 'go get code.google.com/p/go.codereview/cmd/hgpatch should not succeed with GOPATH=$GOROOT'
|
||||||
@ -200,7 +201,7 @@ fi
|
|||||||
rm -rf $d
|
rm -rf $d
|
||||||
|
|
||||||
# issue 3941: args with spaces
|
# issue 3941: args with spaces
|
||||||
d=$(mktemp -d -t testgo)
|
d=$(mktemp -d -t testgoXXX)
|
||||||
cat >$d/main.go<<EOF
|
cat >$d/main.go<<EOF
|
||||||
package main
|
package main
|
||||||
var extern string
|
var extern string
|
||||||
@ -226,7 +227,7 @@ rm -f strings.prof strings.test
|
|||||||
|
|
||||||
# issue 4568. test that symlinks don't screw things up too badly.
|
# issue 4568. test that symlinks don't screw things up too badly.
|
||||||
old=$(pwd)
|
old=$(pwd)
|
||||||
d=$(mktemp -d -t testgo)
|
d=$(mktemp -d -t testgoXXX)
|
||||||
mkdir -p $d/src
|
mkdir -p $d/src
|
||||||
(
|
(
|
||||||
ln -s $d $d/src/dir1
|
ln -s $d $d/src/dir1
|
||||||
@ -247,7 +248,7 @@ fi
|
|||||||
rm -rf $d
|
rm -rf $d
|
||||||
|
|
||||||
# issue 4515.
|
# issue 4515.
|
||||||
d=$(mktemp -d -t testgo)
|
d=$(mktemp -d -t testgoXXX)
|
||||||
mkdir -p $d/src/example/a $d/src/example/b $d/bin
|
mkdir -p $d/src/example/a $d/src/example/b $d/bin
|
||||||
cat >$d/src/example/a/main.go <<EOF
|
cat >$d/src/example/a/main.go <<EOF
|
||||||
package main
|
package main
|
||||||
@ -280,7 +281,7 @@ unset GOPATH
|
|||||||
rm -rf $d
|
rm -rf $d
|
||||||
|
|
||||||
# issue 4773. case-insensitive collisions
|
# issue 4773. case-insensitive collisions
|
||||||
d=$(mktemp -d -t testgo)
|
d=$(mktemp -d -t testgoXXX)
|
||||||
export GOPATH=$d
|
export GOPATH=$d
|
||||||
mkdir -p $d/src/example/a $d/src/example/b
|
mkdir -p $d/src/example/a $d/src/example/b
|
||||||
cat >$d/src/example/a/a.go <<EOF
|
cat >$d/src/example/a/a.go <<EOF
|
||||||
|
3
src/cmd/go/testdata/errmsg/x.go
vendored
3
src/cmd/go/testdata/errmsg/x.go
vendored
@ -1,3 +0,0 @@
|
|||||||
package foo
|
|
||||||
|
|
||||||
import "bar"
|
|
3
src/cmd/go/testdata/errmsg/x1_test.go
vendored
3
src/cmd/go/testdata/errmsg/x1_test.go
vendored
@ -1,3 +0,0 @@
|
|||||||
package foo_test
|
|
||||||
|
|
||||||
import "bar"
|
|
3
src/cmd/go/testdata/errmsg/x_test.go
vendored
3
src/cmd/go/testdata/errmsg/x_test.go
vendored
@ -1,3 +0,0 @@
|
|||||||
package foo
|
|
||||||
|
|
||||||
import "bar"
|
|
Loading…
Reference in New Issue
Block a user