Commit 0b248cea authored by Nodir Turakulov's avatar Nodir Turakulov Committed by Andrew Gerrand

cmd/go: fix `go test -n`

The <importPath>/_test directory is not actually created in -n mode, so
`go test` fails to write _testmain.go.

Do not write _testmain.go if -n is passed.

Change-Id: I825d5040cacbc9d9a8c89443e5a3f83e6f210ce4
Reviewed-on: https://go-review.googlesource.com/15433Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
parent 7c43975a
......@@ -817,10 +817,12 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
}
}
// writeTestmain writes _testmain.go. This must happen after recompileForTest,
// because recompileForTest modifies XXX.
if err := writeTestmain(filepath.Join(testDir, "_testmain.go"), t); err != nil {
return nil, nil, nil, err
if !buildN {
// writeTestmain writes _testmain.go. This must happen after recompileForTest,
// because recompileForTest modifies XXX.
if err := writeTestmain(filepath.Join(testDir, "_testmain.go"), t); err != nil {
return nil, nil, nil, err
}
}
computeStale(pmain)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment