forked from mirror/enumer
Fix End2End test for non-windows platforms
Binary name for string was hardcoded to `.exe`
This commit is contained in:
parent
6bcfe2edaa
commit
16ae335f48
|
@ -16,10 +16,24 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// GOEXE defines the executable file name suffix (".exe" on Windows, "" on other systems).
|
||||||
|
// Must be defined here, cannot be read from ENVIRONMENT variables
|
||||||
|
GOEXE = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Set GOEXE for Windows platform
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
GOEXE = ".exe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This file contains a test that compiles and runs each program in testdata
|
// This file contains a test that compiles and runs each program in testdata
|
||||||
// after generating the string method for its type. The rule is that for testdata/x.go
|
// after generating the string method for its type. The rule is that for testdata/x.go
|
||||||
// we run stringer -type X and then compile and run the program. The resulting
|
// we run stringer -type X and then compile and run the program. The resulting
|
||||||
|
@ -31,8 +45,9 @@ func TestEndToEnd(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
// Create stringer in temporary directory.
|
// Create stringer in temporary directory.
|
||||||
stringer := filepath.Join(dir, "stringer.exe")
|
stringer := filepath.Join(dir, fmt.Sprintf("stringer%s", GOEXE))
|
||||||
err = run("go", "build", "-o", stringer)
|
err = run("go", "build", "-o", stringer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("building stringer: %s", err)
|
t.Fatalf("building stringer: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue