Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows bug fix #664

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
15 changes: 12 additions & 3 deletions runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions runner/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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'",

},
}

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion runner/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading