mirror of https://github.com/golang/go.git
cmd/go: better error for install of 'test-only' package
Fixes #7915. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/96210044
This commit is contained in:
parent
ee7bb07a53
commit
f409681925
|
|
@ -882,6 +882,10 @@ func (b *builder) build(a *action) (err error) {
|
|||
gofiles = append(gofiles, outGo...)
|
||||
}
|
||||
|
||||
if len(gofiles) == 0 {
|
||||
return &build.NoGoError{a.p.Dir}
|
||||
}
|
||||
|
||||
// If we're doing coverage, preprocess the .go files and put them in the work directory
|
||||
if a.p.coverMode != "" {
|
||||
for i, file := range gofiles {
|
||||
|
|
@ -915,21 +919,19 @@ func (b *builder) build(a *action) (err error) {
|
|||
inc := b.includeArgs("-I", a.deps)
|
||||
|
||||
// Compile Go.
|
||||
if len(gofiles) > 0 {
|
||||
ofile, out, err := buildToolchain.gc(b, a.p, a.objpkg, obj, inc, gofiles)
|
||||
if len(out) > 0 {
|
||||
b.showOutput(a.p.Dir, a.p.ImportPath, b.processOutput(out))
|
||||
if err != nil {
|
||||
return errPrintedOutput
|
||||
}
|
||||
}
|
||||
ofile, out, err := buildToolchain.gc(b, a.p, a.objpkg, obj, inc, gofiles)
|
||||
if len(out) > 0 {
|
||||
b.showOutput(a.p.Dir, a.p.ImportPath, b.processOutput(out))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ofile != a.objpkg {
|
||||
objects = append(objects, ofile)
|
||||
return errPrintedOutput
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ofile != a.objpkg {
|
||||
objects = append(objects, ofile)
|
||||
}
|
||||
|
||||
// Copy .h files named for goos or goarch or goos_goarch
|
||||
// to names using GOOS and GOARCH.
|
||||
|
|
|
|||
|
|
@ -759,6 +759,17 @@ fi
|
|||
rm -rf $d
|
||||
unset GOPATH
|
||||
|
||||
TEST 'go build in test-only directory fails with a good error'
|
||||
if ./testgo build ./testdata/testonly 2>testdata/err.out; then
|
||||
echo "go build ./testdata/testonly succeeded, should have failed"
|
||||
ok=false
|
||||
elif ! grep 'no buildable Go' testdata/err.out >/dev/null; then
|
||||
echo "go build ./testdata/testonly produced unexpected error:"
|
||||
cat testdata/err.out
|
||||
ok=false
|
||||
fi
|
||||
rm -f testdata/err.out
|
||||
|
||||
# clean up
|
||||
if $started; then stop; fi
|
||||
rm -rf testdata/bin testdata/bin1
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
package p
|
||||
Loading…
Reference in New Issue