From 2b64e00f164e951f24221c0d4c5b3fb66a604531 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 8 Mar 2012 08:32:38 -0500 Subject: [PATCH] cmd/go: rebuild external test package dependencies Was missing recompilation of packages imported only by external test packages (package foo_test), primarily because Root was not set, so those packages looked like they were from a different Go tree, so they were not recompiled if they already existed. Also clean things up so that only one call to computeStale is needed. Fixes #3238. R=golang-dev, r CC=golang-dev https://golang.org/cl/5786048 --- src/cmd/go/test.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/cmd/go/test.go b/src/cmd/go/test.go index db53deae4a..6aecbe7c06 100644 --- a/src/cmd/go/test.go +++ b/src/cmd/go/test.go @@ -258,6 +258,9 @@ func runTest(cmd *Command, args []string) { for _, path := range p.TestImports { deps[path] = true } + for _, path := range p.XTestImports { + deps[path] = true + } } // translate C to runtime/cgo @@ -454,12 +457,6 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, m[k] = append(m[k], v...) } ptest.build.ImportPos = m - computeStale(ptest) - a := b.action(modeBuild, modeBuild, ptest) - a.objdir = testDir + string(filepath.Separator) - a.objpkg = ptestObj - a.target = ptestObj - a.link = false } else { ptest = p } @@ -470,6 +467,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, Name: p.Name + "_test", ImportPath: p.ImportPath + "_test", localPrefix: p.localPrefix, + Root: p.Root, Dir: p.Dir, GoFiles: p.XTestGoFiles, Imports: p.XTestImports, @@ -481,11 +479,6 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, fake: true, Stale: true, } - computeStale(pxtest) - a := b.action(modeBuild, modeBuild, pxtest) - a.objdir = testDir + string(filepath.Separator) - a.objpkg = buildToolchain.pkgpath(testDir, pxtest) - a.target = a.objpkg } // Action for building pkg.test. @@ -494,6 +487,7 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, Dir: testDir, GoFiles: []string{"_testmain.go"}, ImportPath: "testmain", + Root: p.Root, imports: []*Package{ptest}, build: &build.Package{}, fake: true, @@ -516,6 +510,21 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, pmain.imports = append(pmain.imports, ptesting, pregexp) computeStale(pmain) + if ptest != p { + a := b.action(modeBuild, modeBuild, ptest) + a.objdir = testDir + string(filepath.Separator) + a.objpkg = ptestObj + a.target = ptestObj + a.link = false + } + + if pxtest != nil { + a := b.action(modeBuild, modeBuild, pxtest) + a.objdir = testDir + string(filepath.Separator) + a.objpkg = buildToolchain.pkgpath(testDir, pxtest) + a.target = a.objpkg + } + a := b.action(modeBuild, modeBuild, pmain) a.objdir = testDir + string(filepath.Separator) a.objpkg = filepath.Join(testDir, "main.a") -- 2.48.1