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())
+ }
+}
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
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
}