mirror of https://github.com/golang/go.git
cmd/go: fix compile -p flag for building test of main package
Fixes #23180. Change-Id: I52404ee98dcc60b96972d4242c13db0ec4340d0d Reviewed-on: https://go-review.googlesource.com/86235 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7c2cf4e779
commit
5d647f2b51
|
|
@ -1589,6 +1589,19 @@ func TestPackageMainTestImportsArchiveNotBinary(t *testing.T) {
|
||||||
tg.run("test", "main_test")
|
tg.run("test", "main_test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPackageMainTestCompilerFlags(t *testing.T) {
|
||||||
|
tg := testgo(t)
|
||||||
|
defer tg.cleanup()
|
||||||
|
tg.parallel()
|
||||||
|
tg.makeTempdir()
|
||||||
|
tg.setenv("GOPATH", tg.path("."))
|
||||||
|
tg.tempFile("src/p1/p1.go", "package main\n")
|
||||||
|
tg.tempFile("src/p1/p1_test.go", "package main\nimport \"testing\"\nfunc Test(t *testing.T){}\n")
|
||||||
|
tg.run("test", "-c", "-n", "p1")
|
||||||
|
tg.grepBothNot(`[\\/]compile.* -p main.*p1\.go`, "should not have run compile -p main p1.go")
|
||||||
|
tg.grepStderr(`[\\/]compile.* -p p1.*p1\.go`, "should have run compile -p p1 p1.go")
|
||||||
|
}
|
||||||
|
|
||||||
// The runtime version string takes one of two forms:
|
// The runtime version string takes one of two forms:
|
||||||
// "go1.X[.Y]" for Go releases, and "devel +hash" at tip.
|
// "go1.X[.Y]" for Go releases, and "devel +hash" at tip.
|
||||||
// Determine whether we are in a released copy by
|
// Determine whether we are in a released copy by
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a
|
||||||
pkgpath := p.ImportPath
|
pkgpath := p.ImportPath
|
||||||
if cfg.BuildBuildmode == "plugin" {
|
if cfg.BuildBuildmode == "plugin" {
|
||||||
pkgpath = pluginPath(a)
|
pkgpath = pluginPath(a)
|
||||||
} else if p.Name == "main" {
|
} else if p.Name == "main" && !p.Internal.ForceLibrary {
|
||||||
pkgpath = "main"
|
pkgpath = "main"
|
||||||
}
|
}
|
||||||
gcargs := []string{"-p", pkgpath}
|
gcargs := []string{"-p", pkgpath}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue