]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: create test binary in temp directory
authorIan Lance Taylor <iant@golang.org>
Fri, 26 Feb 2016 21:05:35 +0000 (13:05 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 26 Feb 2016 21:24:42 +0000 (21:24 +0000)
The new TestDashS was leaving a dreg "test" file in
cmd/compile/internal/gc.  Create it in the temporary directory instead.

Also change path.Join to filepath.Join throughout global_test.go.

Change-Id: Ib7707fada2b3ab5e8abc2ba74e4c402821c1408b
Reviewed-on: https://go-review.googlesource.com/19965
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/global_test.go

index 80781e61a861ee79d9ae8ab42b50bf8f240323b7..bd1391d9ad150e88276ed1ba38b92ac3b191d375 100644 (file)
@@ -11,7 +11,7 @@ import (
        "log"
        "os"
        "os/exec"
-       "path"
+       "path/filepath"
        "strings"
        "testing"
 )
@@ -29,7 +29,7 @@ func TestScanfRemoval(t *testing.T) {
        defer os.RemoveAll(dir)
 
        // Create source.
-       src := path.Join(dir, "test.go")
+       src := filepath.Join(dir, "test.go")
        f, err := os.Create(src)
        if err != nil {
                log.Fatalf("could not create source file: %v", err)
@@ -44,7 +44,7 @@ func main() {
        f.Close()
 
        // Name of destination.
-       dst := path.Join(dir, "test")
+       dst := filepath.Join(dir, "test")
 
        // Compile source.
        cmd := exec.Command("go", "build", "-o", dst, src)
@@ -76,7 +76,7 @@ func TestDashS(t *testing.T) {
        defer os.RemoveAll(dir)
 
        // Create source.
-       src := path.Join(dir, "test.go")
+       src := filepath.Join(dir, "test.go")
        f, err := os.Create(src)
        if err != nil {
                log.Fatalf("could not create source file: %v", err)
@@ -91,7 +91,7 @@ func main() {
        f.Close()
 
        // Compile source.
-       cmd := exec.Command("go", "build", "-gcflags", "-S", src)
+       cmd := exec.Command("go", "build", "-gcflags", "-S", "-o", filepath.Join(dir, "test"), src)
        out, err := cmd.CombinedOutput()
        if err != nil {
                log.Fatalf("could not build target: %v", err)