mirror of https://github.com/golang/go.git
cmd/go: stat the archive file only when executing the commands
Fixes #14944 Change-Id: I73e0997cb6ebaeced1045b0ddadac893319bd78f Reviewed-on: https://go-review.googlesource.com/21065 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
8cb74e1d18
commit
edb19aa1cd
|
|
@ -2346,8 +2346,10 @@ func (gcToolchain) pack(b *builder, p *Package, objDir, afile string, ofiles []s
|
|||
|
||||
// The archive file should have been created by the compiler.
|
||||
// Since it used to not work that way, verify.
|
||||
if _, err := os.Stat(absAfile); err != nil {
|
||||
fatalf("os.Stat of archive file failed: %v", err)
|
||||
if !buildN {
|
||||
if _, err := os.Stat(absAfile); err != nil {
|
||||
fatalf("os.Stat of archive file failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if buildN || buildX {
|
||||
|
|
|
|||
|
|
@ -1982,6 +1982,27 @@ func TestCoverageUsesActualSettingToOverrideEvenForRace(t *testing.T) {
|
|||
checkCoverage(tg, data)
|
||||
}
|
||||
|
||||
func TestBuildDryRunWithCgo(t *testing.T) {
|
||||
if !canCgo {
|
||||
t.Skip("skipping because cgo not enabled")
|
||||
}
|
||||
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.tempFile("foo.go", `package main
|
||||
|
||||
/*
|
||||
#include <limits.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
println(C.INT_MAX)
|
||||
}`)
|
||||
tg.run("build", "-n", tg.path("foo.go"))
|
||||
tg.grepStderrNot(`os.Stat .* no such file or directory`, "unexpected stat of archive file")
|
||||
}
|
||||
|
||||
func TestCoverageWithCgo(t *testing.T) {
|
||||
if !canCgo {
|
||||
t.Skip("skipping because cgo not enabled")
|
||||
|
|
|
|||
Loading…
Reference in New Issue