diff --git a/pkg/ignore/ignore_test.go b/pkg/ignore/ignore_test.go index 36d021b5..5df40443 100644 --- a/pkg/ignore/ignore_test.go +++ b/pkg/ignore/ignore_test.go @@ -2,7 +2,7 @@ package ignore import ( "os" - "runtime" + "path/filepath" "testing" "github.com/rs/zerolog" @@ -17,15 +17,14 @@ func TestIgnore_Match(t *testing.T) { i := NewIgnore([]string{"my/files/*"}) assert.NotNil(t, i) + // Test if rules with backslashes match on windows assert.False(t, i.Match("not/foo")) assert.True(t, i.Match("my/files/file1")) assert.False(t, i.Match("my/files")) - if runtime.GOOS == "windows" { - assert.False(t, i.Match(`not\foo`)) - assert.True(t, i.Match(`my\files\file1`)) - assert.False(t, i.Match(`my\files`)) - } + assert.False(t, i.Match(filepath.Join("not", "foo"))) + assert.True(t, i.Match(filepath.Join("my", "files", "file1"))) + assert.False(t, i.Match(filepath.Join("my", "files"))) } // Test all default ignore files, except for .git/info/exclude, since