Skip to content

Commit 27096db

Browse files
authored
Revert "FIX: Support working directories containing whitespace (#646)" (#665)
This reverts commit df13da5.
1 parent df13da5 commit 27096db

File tree

3 files changed

+11
-53
lines changed

3 files changed

+11
-53
lines changed

runner/config.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"reflect"
1010
"regexp"
1111
"runtime"
12-
"strings"
1312
"time"
1413

1514
"dario.cat/mergo"
@@ -308,7 +307,6 @@ func (c *Config) preprocess() error {
308307
if c.TestDataDir == "" {
309308
c.TestDataDir = "testdata"
310309
}
311-
312310
ed := c.Build.ExcludeDir
313311
for i := range ed {
314312
ed[i] = cleanPath(ed[i])
@@ -329,9 +327,6 @@ func (c *Config) preprocess() error {
329327
// CMD will not recognize relative path like ./tmp/server
330328
c.Build.Bin, err = filepath.Abs(c.Build.Bin)
331329

332-
// Account for spaces in filepath
333-
c.Build.Bin = fmt.Sprintf("%q", c.Build.Bin)
334-
335330
return err
336331
}
337332

@@ -367,8 +362,7 @@ func (c *Config) killDelay() time.Duration {
367362
}
368363

369364
func (c *Config) binPath() string {
370-
bin := strings.Trim(c.Build.Bin, "\"")
371-
return fmt.Sprintf("%q", filepath.Join(c.Root, bin))
365+
return filepath.Join(c.Root, c.Build.Bin)
372366
}
373367

374368
func (c *Config) tmpPath() string {

runner/config_test.go

+9-42
Original file line numberDiff line numberDiff line change
@@ -117,49 +117,16 @@ func TestReadConfByName(t *testing.T) {
117117
}
118118

119119
func TestConfPreprocess(t *testing.T) {
120-
tests := []struct {
121-
name string
122-
space bool
123-
suffix string
124-
}{
125-
{
126-
name: "no spaces",
127-
space: false,
128-
suffix: "/_testdata/toml/tmp/main\"",
129-
},
130-
{
131-
name: "with spaces",
132-
space: true,
133-
suffix: "/_testdata/toml/tmp space/main\"",
134-
},
120+
t.Setenv(airWd, "_testdata/toml")
121+
df := defaultConfig()
122+
err := df.preprocess()
123+
if err != nil {
124+
t.Fatalf("preprocess error %v", err)
135125
}
136-
137-
for _, tt := range tests {
138-
139-
oWD, err := os.Getwd()
140-
if err != nil {
141-
t.Fatalf("failed to get currWD: %v", err)
142-
}
143-
144-
t.Setenv(airWd, "_testdata/toml")
145-
df := defaultConfig()
146-
if tt.space {
147-
df.Build.Bin = "./tmp space/main"
148-
}
149-
err = df.preprocess()
150-
if err != nil {
151-
t.Fatalf("%s: preprocess error %v", tt.name, err)
152-
}
153-
154-
binPath := df.Build.Bin
155-
if !strings.HasSuffix(binPath, tt.suffix) {
156-
t.Fatalf("%s: bin path is %s, but not have suffix %s.", tt.name, binPath, tt.suffix)
157-
}
158-
159-
err = os.Chdir(oWD)
160-
if err != nil {
161-
t.Fatalf("failed to change back to original WD: %v", err)
162-
}
126+
suffix := "/_testdata/toml/tmp/main"
127+
binPath := df.Build.Bin
128+
if !strings.HasSuffix(binPath, suffix) {
129+
t.Fatalf("bin path is %s, but not have suffix %s.", binPath, suffix)
163130
}
164131
}
165132

runner/engine_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,7 @@ func TestRebuildWhenRunCmdUsingDLV(t *testing.T) {
721721
dlvPort, f := GetPort()
722722
f()
723723
engine.config.Build.FullBin = fmt.Sprintf("dlv exec --accept-multiclient --log --headless --continue --listen :%d --api-version 2 ./tmp/main", dlvPort)
724-
err = engine.config.preprocess()
725-
if err != nil {
726-
t.Fatal("config preprocess fialed! - Error: ", err)
727-
}
724+
_ = engine.config.preprocess()
728725
go func() {
729726
engine.Run()
730727
}()

0 commit comments

Comments
 (0)