Skip to content

Commit 7022a92

Browse files
committed
Use a different separator in Windows tests
1 parent 80f8104 commit 7022a92

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

test/e2e_test.go

+19-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os/exec"
88
"path/filepath"
99
"runtime"
10+
"strings"
1011
"syscall"
1112
"testing"
1213
"time"
@@ -16,10 +17,11 @@ import (
1617

1718
func TestCng(t *testing.T) {
1819
tests := []struct {
19-
name, stdout, stderr, exclude, pattern string
20-
verbose, kill, init, skip bool
21-
delay int
22-
steps func(write func(string))
20+
name, stderr, exclude, pattern string
21+
stdout []string
22+
verbose, kill, init, skip bool
23+
delay int
24+
steps func(write func(string))
2325
}{
2426
{
2527
name: "adds newly created files",
@@ -29,7 +31,7 @@ func TestCng(t *testing.T) {
2931
write("*.txt")
3032
}
3133
},
32-
stdout: "hello\nhello\nhello\n",
34+
stdout: []string{"hello", "hello", "hello"},
3335
},
3436
{
3537
name: "called when a file changes",
@@ -39,12 +41,12 @@ func TestCng(t *testing.T) {
3941
write("foo.txt")
4042
}
4143
},
42-
stdout: "hello\nhello\nhello\n",
44+
stdout: []string{"hello", "hello", "hello"},
4345
},
4446
{
4547
name: "init flag: should run on startup",
4648
pattern: "*.txt",
47-
stdout: "hello\n",
49+
stdout: []string{"hello"},
4850
init: true,
4951
},
5052
{
@@ -57,7 +59,7 @@ func TestCng(t *testing.T) {
5759
// should not be picked up by the watcher
5860
write("*.md")
5961
},
60-
stdout: "hello\n",
62+
stdout: []string{"hello"},
6163
},
6264
{
6365
name: "ignores default excluded dirs",
@@ -66,7 +68,7 @@ func TestCng(t *testing.T) {
6668
write(".git/foo.txt")
6769
write("node_modules/foo.txt")
6870
},
69-
stdout: "",
71+
stdout: []string{""},
7072
},
7173
// todo: should report helpful error if missing pattern
7274
// {
@@ -147,7 +149,14 @@ func TestCng(t *testing.T) {
147149
stdout := stdoutBuf.String()
148150
stderr := stderrBuf.String()
149151

150-
assert.Equal(t, test.stdout, stdout)
152+
var sep string
153+
if runtime.GOOS == "windows" {
154+
sep = "\r"
155+
} else {
156+
sep = "\n"
157+
}
158+
testStdout := strings.Join(test.stdout, sep)
159+
assert.Equal(t, testStdout, stdout)
151160
assert.Equal(t, test.stderr, stderr)
152161
})
153162
}

0 commit comments

Comments
 (0)