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>
// 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 {
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")