Skip to content

Commit

Permalink
Use a different separator in Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danawoodman committed Feb 27, 2024
1 parent 80f8104 commit 7022a92
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strings"
"syscall"
"testing"
"time"
Expand All @@ -16,10 +17,11 @@ import (

func TestCng(t *testing.T) {
tests := []struct {
name, stdout, stderr, exclude, pattern string
verbose, kill, init, skip bool
delay int
steps func(write func(string))
name, stderr, exclude, pattern string
stdout []string
verbose, kill, init, skip bool
delay int
steps func(write func(string))
}{
{
name: "adds newly created files",
Expand All @@ -29,7 +31,7 @@ func TestCng(t *testing.T) {
write("*.txt")
}
},
stdout: "hello\nhello\nhello\n",
stdout: []string{"hello", "hello", "hello"},
},
{
name: "called when a file changes",
Expand All @@ -39,12 +41,12 @@ func TestCng(t *testing.T) {
write("foo.txt")
}
},
stdout: "hello\nhello\nhello\n",
stdout: []string{"hello", "hello", "hello"},
},
{
name: "init flag: should run on startup",
pattern: "*.txt",
stdout: "hello\n",
stdout: []string{"hello"},
init: true,
},
{
Expand All @@ -57,7 +59,7 @@ func TestCng(t *testing.T) {
// should not be picked up by the watcher
write("*.md")
},
stdout: "hello\n",
stdout: []string{"hello"},
},
{
name: "ignores default excluded dirs",
Expand All @@ -66,7 +68,7 @@ func TestCng(t *testing.T) {
write(".git/foo.txt")
write("node_modules/foo.txt")
},
stdout: "",
stdout: []string{""},
},
// todo: should report helpful error if missing pattern
// {
Expand Down Expand Up @@ -147,7 +149,14 @@ func TestCng(t *testing.T) {
stdout := stdoutBuf.String()
stderr := stderrBuf.String()

assert.Equal(t, test.stdout, stdout)
var sep string
if runtime.GOOS == "windows" {
sep = "\r"
} else {
sep = "\n"
}
testStdout := strings.Join(test.stdout, sep)
assert.Equal(t, testStdout, stdout)
assert.Equal(t, test.stderr, stderr)
})
}
Expand Down

0 comments on commit 7022a92

Please sign in to comment.