1
0
mirror of https://github.com/golang/go synced 2024-11-25 01:08:02 -07:00

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
This commit is contained in:
Russ Cox 2012-03-08 08:32:38 -05:00
parent 5ca13f6378
commit 2b64e00f16

View File

@ -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")