]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: every test imports regexp
authorRuss Cox <rsc@golang.org>
Sat, 21 Jan 2012 04:35:28 +0000 (23:35 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 21 Jan 2012 04:35:28 +0000 (23:35 -0500)
This fixes the bug Rob ran into when editing package bytes.
Regexp imports regexp/syntax, which imports bytes, and
regexp/syntax was not being properly recompiled during a
test of a change to package bytes.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5555065

src/cmd/go/test.go

index fb222b139d2bd365c699dc3b9a04779cc430414b..e28eaeffcb01bef214842893327f11784e41c0aa 100644 (file)
@@ -406,6 +406,18 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
        if pxtest != nil {
                pmain.imports = append(pmain.imports, pxtest)
        }
+
+       // The generated main also imports testing and regexp.
+       ptesting, err := loadPackage("testing")
+       if err != nil {
+               return nil, nil, nil, err
+       }
+       pregexp, err := loadPackage("regexp")
+       if err != nil {
+               return nil, nil, nil, err
+       }
+       pmain.imports = append(pmain.imports, ptesting, pregexp)
+
        a := b.action(modeBuild, modeBuild, pmain)
        a.objdir = testDir + string(filepath.Separator)
        a.objpkg = filepath.Join(testDir, "main.a")