diff --git a/runner/config.go b/runner/config.go index 8aa4c91f..562ddc26 100644 --- a/runner/config.go +++ b/runner/config.go @@ -9,7 +9,6 @@ import ( "reflect" "regexp" "runtime" - "strings" "time" "dario.cat/mergo" @@ -308,7 +307,6 @@ func (c *Config) preprocess() error { if c.TestDataDir == "" { c.TestDataDir = "testdata" } - ed := c.Build.ExcludeDir for i := range ed { ed[i] = cleanPath(ed[i]) @@ -329,9 +327,6 @@ func (c *Config) preprocess() error { // CMD will not recognize relative path like ./tmp/server c.Build.Bin, err = filepath.Abs(c.Build.Bin) - // Account for spaces in filepath - c.Build.Bin = fmt.Sprintf("%q", c.Build.Bin) - return err } @@ -367,8 +362,7 @@ 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)) + 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..97a1bd2a 100644 --- a/runner/config_test.go +++ b/runner/config_test.go @@ -117,49 +117,16 @@ func TestReadConfByName(t *testing.T) { } func TestConfPreprocess(t *testing.T) { - tests := []struct { - name string - space bool - suffix string - }{ - { - name: "no spaces", - space: false, - suffix: "/_testdata/toml/tmp/main\"", - }, - { - name: "with spaces", - space: true, - suffix: "/_testdata/toml/tmp space/main\"", - }, + t.Setenv(airWd, "_testdata/toml") + df := defaultConfig() + err := df.preprocess() + if err != nil { + t.Fatalf("preprocess error %v", err) } - - for _, tt := range tests { - - oWD, err := os.Getwd() - if err != nil { - t.Fatalf("failed to get currWD: %v", err) - } - - t.Setenv(airWd, "_testdata/toml") - df := defaultConfig() - if tt.space { - df.Build.Bin = "./tmp space/main" - } - err = df.preprocess() - if err != nil { - t.Fatalf("%s: preprocess error %v", tt.name, err) - } - - 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) - } - - err = os.Chdir(oWD) - if err != nil { - t.Fatalf("failed to change back to original WD: %v", err) - } + suffix := "/_testdata/toml/tmp/main" + binPath := df.Build.Bin + if !strings.HasSuffix(binPath, suffix) { + t.Fatalf("bin path is %s, but not have suffix %s.", binPath, suffix) } } diff --git a/runner/engine_test.go b/runner/engine_test.go index f416e119..df181902 100644 --- a/runner/engine_test.go +++ b/runner/engine_test.go @@ -721,10 +721,7 @@ func TestRebuildWhenRunCmdUsingDLV(t *testing.T) { dlvPort, f := GetPort() f() 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) - } + _ = engine.config.preprocess() go func() { engine.Run() }()