diff --git a/runner/config.go b/runner/config.go index 8aa4c91f..ac32a4f1 100644 --- a/runner/config.go +++ b/runner/config.go @@ -330,7 +330,10 @@ func (c *Config) preprocess() error { c.Build.Bin, err = filepath.Abs(c.Build.Bin) // Account for spaces in filepath - c.Build.Bin = fmt.Sprintf("%q", c.Build.Bin) + + if runtime.GOOS != "windows" { + c.Build.Bin = fmt.Sprintf("'%s'", c.Build.Bin) + } return err } @@ -367,8 +370,14 @@ func (c *Config) killDelay() time.Duration { } func (c *Config) binPath() string { - bin := strings.Trim(c.Build.Bin, "\"") - return fmt.Sprintf("%q", filepath.Join(c.Root, bin)) + + if runtime.GOOS != "windows" { + bin := strings.Trim(c.Build.Bin, "'") + return fmt.Sprintf("'%s'", filepath.Join(c.Root, bin)) + } + + return filepath.Join(c.Root, c.Build.Bin) + } func (c *Config) tmpPath() string { diff --git a/runner/config_test.go b/runner/config_test.go index 75a91825..54be29a9 100644 --- a/runner/config_test.go +++ b/runner/config_test.go @@ -125,12 +125,15 @@ func TestConfPreprocess(t *testing.T) { { name: "no spaces", space: false, - suffix: "/_testdata/toml/tmp/main\"", + suffix: "/_testdata/toml/tmp/main'", + + }, { name: "with spaces", space: true, - suffix: "/_testdata/toml/tmp space/main\"", + suffix: "/_testdata/toml/tmp space/main'", + }, } @@ -153,7 +156,7 @@ func TestConfPreprocess(t *testing.T) { binPath := df.Build.Bin if !strings.HasSuffix(binPath, tt.suffix) { - t.Fatalf("%s: bin path is %s, but not have suffix %s.", tt.name, binPath, tt.suffix) + t.Fatalf("%s: bin path is %q, but not have suffix %q", tt.name, binPath, tt.suffix) } err = os.Chdir(oWD) diff --git a/runner/engine_test.go b/runner/engine_test.go index f416e119..f7204cee 100644 --- a/runner/engine_test.go +++ b/runner/engine_test.go @@ -723,7 +723,7 @@ func TestRebuildWhenRunCmdUsingDLV(t *testing.T) { engine.config.Build.FullBin = fmt.Sprintf("dlv exec --accept-multiclient --log --headless --continue --listen :%d --api-version 2 ./tmp/main", dlvPort) err = engine.config.preprocess() if err != nil { - t.Fatal("config preprocess fialed! - Error: ", err) + t.Fatal("config preprocess failed! - Error: ", err) } go func() { engine.Run()