Ignore patterns should be case insensitive on OS X and Windows

This commit is contained in:
Jakob Borg
2014-09-16 23:14:03 +02:00
parent 592b13d7db
commit 384c543ab9
3 changed files with 45 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ package ignore_test
import (
"bytes"
"path/filepath"
"runtime"
"testing"
"github.com/syncthing/syncthing/ignore"
@@ -106,3 +107,29 @@ func TestBadPatterns(t *testing.T) {
}
}
}
func TestCaseSensitivity(t *testing.T) {
ign, _ := ignore.Parse(bytes.NewBufferString("test"), ".stignore")
match := []string{"test"}
dontMatch := []string{"foo"}
switch runtime.GOOS {
case "darwin", "windows":
match = append(match, "TEST", "Test", "tESt")
default:
dontMatch = append(dontMatch, "TEST", "Test", "tESt")
}
for _, tc := range match {
if !ign.Match(tc) {
t.Errorf("Incorrect match for %q: should be matched", tc)
}
}
for _, tc := range dontMatch {
if ign.Match(tc) {
t.Errorf("Incorrect match for %q: should not be matched", tc)
}
}
}