Commit f849f6b7 authored by Russ Cox's avatar Russ Cox

cmd/go: give full import stack for errors in dependencies of test dependencies

Fixes #9558.

Change-Id: I68506af58088155d38d492b49b19c5fc2048b087
Reviewed-on: https://go-review.googlesource.com/12176Reviewed-by: default avatarRob Pike <r@golang.org>
parent 6ab582a8
......@@ -2094,3 +2094,17 @@ func TestGoTestRaceInstallCgo(t *testing.T) {
t.Fatalf("go test -i runtime/race reinstalled cmd/cgo")
}
}
func TestGoTestImportErrorStack(t *testing.T) {
const out = `package testdep/p1 (test)
imports testdep/p2
imports testdep/p3: no buildable Go source files`
tg := testgo(t)
defer tg.cleanup()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
tg.runFail("test", "testdep/p1")
if !strings.Contains(tg.stderr.String(), out) {
t.Fatal("did not give full import stack:\n\n%s", tg.stderr.String())
}
}
......@@ -578,6 +578,11 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
if p1.Error != nil {
return nil, nil, nil, p1.Error
}
if len(p1.DepsErrors) > 0 {
err := p1.DepsErrors[0]
err.Pos = "" // show full import stack
return nil, nil, nil, err
}
if contains(p1.Deps, p.ImportPath) || p1.ImportPath == p.ImportPath {
// Same error that loadPackage returns (via reusePackage) in pkg.go.
// Can't change that code, because that code is only for loading the
......@@ -604,6 +609,11 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
if p1.Error != nil {
return nil, nil, nil, p1.Error
}
if len(p1.DepsErrors) > 0 {
err := p1.DepsErrors[0]
err.Pos = "" // show full import stack
return nil, nil, nil, err
}
ximports = append(ximports, p1)
p.XTestImports[i] = p1.ImportPath
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment