aboutsummaryrefslogtreecommitdiff
path: root/test/sinit_run.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2019-11-18 13:58:58 +0000
committerBryan C. Mills <bcmills@google.com>2019-11-18 14:40:07 +0000
commitafac2c0508208ce0baf0cf2f0ba9b86ee7b60469 (patch)
tree5b36426e150e74235bb481e99528475f82d5c9d4 /test/sinit_run.go
parent2bde3c13f6e31662c682f1b5830c5e3fd9f5494c (diff)
downloadgo-afac2c0508208ce0baf0cf2f0ba9b86ee7b60469.tar.gz
go-afac2c0508208ce0baf0cf2f0ba9b86ee7b60469.zip
test: avoid writing temporary files to GOROOT
This reverts CL 207477, restoring CL 207352 with a fix for the regression observed in the Windows builders. cmd/compile evidently does not fully support NUL as an output on Windows, so this time we write ignored 'compile' outputs to temporary files (instead of os.DevNull as in CL 207352). Updates #28387 Fixes #35619 Change-Id: I2edc5727c3738fa1bccb4b74e50d114cf2a7fcff Reviewed-on: https://go-review.googlesource.com/c/go/+/207602 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/sinit_run.go')
-rw-r--r--test/sinit_run.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/sinit_run.go b/test/sinit_run.go
index fdd19c492f..c37fc9b88c 100644
--- a/test/sinit_run.go
+++ b/test/sinit_run.go
@@ -12,20 +12,32 @@ package main
import (
"bytes"
"fmt"
+ "io/ioutil"
"os"
"os/exec"
)
func main() {
- cmd := exec.Command("go", "tool", "compile", "-S", "sinit.go")
+ f, err := ioutil.TempFile("", "sinit-*.o")
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ f.Close()
+
+ cmd := exec.Command("go", "tool", "compile", "-o", f.Name(), "-S", "sinit.go")
out, err := cmd.CombinedOutput()
+ os.Remove(f.Name())
if err != nil {
fmt.Println(string(out))
fmt.Println(err)
os.Exit(1)
}
- os.Remove("sinit.o")
+ if len(bytes.TrimSpace(out)) == 0 {
+ fmt.Println("'go tool compile -S sinit.go' printed no output")
+ os.Exit(1)
+ }
if bytes.Contains(out, []byte("initdone")) {
fmt.Println("sinit generated an init function")
os.Exit(1)