Avoid Start-Process errors for Windows full_bin (#872)
This commit is contained in:
@@ -303,8 +303,6 @@ func adaptToVariousPlatforms(c *Config) {
|
||||
// Fix the default configuration is not used in Windows
|
||||
// Use the unix configuration on Windows
|
||||
if runtime.GOOS == PlatformWindows {
|
||||
|
||||
runName := "start"
|
||||
extName := ".exe"
|
||||
originBin := c.Build.Bin
|
||||
|
||||
@@ -313,9 +311,6 @@ func adaptToVariousPlatforms(c *Config) {
|
||||
if !strings.HasSuffix(c.Build.FullBin, extName) {
|
||||
c.Build.FullBin += extName
|
||||
}
|
||||
if !strings.HasPrefix(c.Build.FullBin, runName) {
|
||||
c.Build.FullBin = runName + " /wait /b " + c.Build.FullBin
|
||||
}
|
||||
}
|
||||
|
||||
// bin=/tmp/main cmd=go build -o ./tmp/main.exe main.go
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAdaptToVariousPlatformsFullBinWindows(t *testing.T) {
|
||||
if runtime.GOOS != PlatformWindows {
|
||||
t.Skip("windows-only behavior")
|
||||
}
|
||||
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
fullBin string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "exe already",
|
||||
fullBin: `.\tmp\main.exe`,
|
||||
expected: `.\tmp\main.exe`,
|
||||
},
|
||||
{
|
||||
name: "append exe",
|
||||
fullBin: `.\tmp\main`,
|
||||
expected: `.\tmp\main.exe`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
config := &Config{
|
||||
Build: cfgBuild{
|
||||
FullBin: tt.fullBin,
|
||||
},
|
||||
}
|
||||
adaptToVariousPlatforms(config)
|
||||
if config.Build.FullBin != tt.expected {
|
||||
t.Fatalf("expected full_bin %q, got %q", tt.expected, config.Build.FullBin)
|
||||
}
|
||||
if strings.HasPrefix(strings.ToLower(config.Build.FullBin), "start ") {
|
||||
t.Fatalf("unexpected start prefix in full_bin: %q", config.Build.FullBin)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user