]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: rebuild external test package dependencies
authorRuss Cox <rsc@golang.org>
Thu, 8 Mar 2012 13:32:38 +0000 (08:32 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 8 Mar 2012 13:32:38 +0000 (08:32 -0500)
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

index db53deae4a5779fe0d8c77e5b37c903388e77f24..6aecbe7c06df147918298a7fe78cd48fe4f66610 100644 (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")