test.go (go1.19.src) | : | test.go (go1.19.1.src) | ||
---|---|---|---|---|
skipping to change at line 747 | skipping to change at line 747 | |||
// (We implement go clean -testcache by writing an expiration date | // (We implement go clean -testcache by writing an expiration date | |||
// instead of searching out and deleting test result cache entries.) | // instead of searching out and deleting test result cache entries.) | |||
if dir := cache.DefaultDir(); dir != "off" { | if dir := cache.DefaultDir(); dir != "off" { | |||
if data, _ := lockedfile.Read(filepath.Join(dir, "testexpire.txt" )); len(data) > 0 && data[len(data)-1] == '\n' { | if data, _ := lockedfile.Read(filepath.Join(dir, "testexpire.txt" )); len(data) > 0 && data[len(data)-1] == '\n' { | |||
if t, err := strconv.ParseInt(string(data[:len(data)-1]), 10, 64); err == nil { | if t, err := strconv.ParseInt(string(data[:len(data)-1]), 10, 64); err == nil { | |||
testCacheExpire = time.Unix(0, t) | testCacheExpire = time.Unix(0, t) | |||
} | } | |||
} | } | |||
} | } | |||
var b work.Builder | b := work.NewBuilder("") | |||
b.Init() | ||||
if cfg.BuildI { | if cfg.BuildI { | |||
fmt.Fprint(os.Stderr, "go: -i flag is deprecated\n") | fmt.Fprint(os.Stderr, "go: -i flag is deprecated\n") | |||
cfg.BuildV = testV | cfg.BuildV = testV | |||
deps := make(map[string]bool) | deps := make(map[string]bool) | |||
for _, dep := range load.TestMainDeps { | for _, dep := range load.TestMainDeps { | |||
deps[dep] = true | deps[dep] = true | |||
} | } | |||
skipping to change at line 803 | skipping to change at line 802 | |||
// gccgo's standard library packages | // gccgo's standard library packages | |||
// can not be reinstalled. | // can not be reinstalled. | |||
continue | continue | |||
} | } | |||
a.Deps = append(a.Deps, b.CompileAction(work.ModeInstall, work.ModeInstall, p)) | a.Deps = append(a.Deps, b.CompileAction(work.ModeInstall, work.ModeInstall, p)) | |||
} | } | |||
b.Do(ctx, a) | b.Do(ctx, a) | |||
if !testC || a.Failed { | if !testC || a.Failed { | |||
return | return | |||
} | } | |||
b.Init() | ||||
// TODO(bcmills): I have no idea why the Builder must be reset he | ||||
re, but | ||||
// without this reset dance, TestGoTestDashIDashOWritesBinary fai | ||||
ls with | ||||
// lots of "vet config not found" errors. This was added in CL 56 | ||||
99088, | ||||
// which had almost no public discussion, a very short commit des | ||||
cription, | ||||
// and left no comment in the code to explain what is going on he | ||||
re. 🤯 | ||||
// | ||||
// Maybe this has the effect of removing actions that were regist | ||||
ered by the | ||||
// call to CompileAction above? | ||||
b = work.NewBuilder("") | ||||
} | } | |||
var builds, runs, prints []*work.Action | var builds, runs, prints []*work.Action | |||
if testCoverPaths != nil { | if testCoverPaths != nil { | |||
match := make([]func(*load.Package) bool, len(testCoverPaths)) | match := make([]func(*load.Package) bool, len(testCoverPaths)) | |||
matched := make([]bool, len(testCoverPaths)) | matched := make([]bool, len(testCoverPaths)) | |||
for i := range testCoverPaths { | for i := range testCoverPaths { | |||
match[i] = load.MatchPackage(testCoverPaths[i], base.Cwd( )) | match[i] = load.MatchPackage(testCoverPaths[i], base.Cwd( )) | |||
} | } | |||
skipping to change at line 919 | skipping to change at line 927 | |||
} | } | |||
} | } | |||
// Prepare build + run + print actions for all packages being tested. | // Prepare build + run + print actions for all packages being tested. | |||
for _, p := range pkgs { | for _, p := range pkgs { | |||
// sync/atomic import is inserted by the cover tool. See #18486 | // sync/atomic import is inserted by the cover tool. See #18486 | |||
if testCover && testCoverMode == "atomic" { | if testCover && testCoverMode == "atomic" { | |||
ensureImport(p, "sync/atomic") | ensureImport(p, "sync/atomic") | |||
} | } | |||
buildTest, runTest, printTest, err := builderTest(&b, ctx, pkgOpt s, p, allImports[p]) | buildTest, runTest, printTest, err := builderTest(b, ctx, pkgOpts , p, allImports[p]) | |||
if err != nil { | if err != nil { | |||
str := err.Error() | str := err.Error() | |||
str = strings.TrimPrefix(str, "\n") | str = strings.TrimPrefix(str, "\n") | |||
if p.ImportPath != "" { | if p.ImportPath != "" { | |||
base.Errorf("# %s\n%s", p.ImportPath, str) | base.Errorf("# %s\n%s", p.ImportPath, str) | |||
} else { | } else { | |||
base.Errorf("%s", str) | base.Errorf("%s", str) | |||
} | } | |||
fmt.Printf("FAIL\t%s [setup failed]\n", p.ImportPath) | fmt.Printf("FAIL\t%s [setup failed]\n", p.ImportPath) | |||
continue | continue | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 18 lines changed or added |