From 7d954dd5d16a4b2f7811660096bfcd0d8f331ede Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Thu, 16 Apr 2015 21:18:17 +0100 Subject: [PATCH] Fix tests on Windows (fixes #1531) --- internal/config/config_test.go | 4 ++-- internal/fnmatch/fnmatch_test.go | 4 +++- internal/model/sharedpullerstate_test.go | 1 + internal/scanner/walk_test.go | 8 ++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index fffdf06c8..2c6fe0877 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -341,8 +341,8 @@ func TestWindowsPaths(t *testing.T) { folder.RawPath = `relative\path` expected = folder.RawPath actual = folder.Path() - if actual != expected { - t.Errorf("%q != %q", actual, expected) + if actual == expected || !strings.HasPrefix(actual, "\\\\?\\") { + t.Errorf("%q == %q, expected absolutification", actual, expected) } } diff --git a/internal/fnmatch/fnmatch_test.go b/internal/fnmatch/fnmatch_test.go index 1d9aa396f..6cac943d2 100644 --- a/internal/fnmatch/fnmatch_test.go +++ b/internal/fnmatch/fnmatch_test.go @@ -69,7 +69,9 @@ var testcases = []testcase{ func TestMatch(t *testing.T) { switch runtime.GOOS { - case "windows", "darwin": + case "windows": + testcases = append(testcases, testcase{"foo.txt", "foo.TXT", 0, true}) + case "darwin": testcases = append(testcases, testcase{"foo.txt", "foo.TXT", 0, true}) fallthrough default: diff --git a/internal/model/sharedpullerstate_test.go b/internal/model/sharedpullerstate_test.go index 48194d3ad..a385f999d 100644 --- a/internal/model/sharedpullerstate_test.go +++ b/internal/model/sharedpullerstate_test.go @@ -78,4 +78,5 @@ func TestReadOnlyDir(t *testing.T) { } s.fail("Test done", nil) + s.finalClose() } diff --git a/internal/scanner/walk_test.go b/internal/scanner/walk_test.go index 85f862822..30545533f 100644 --- a/internal/scanner/walk_test.go +++ b/internal/scanner/walk_test.go @@ -203,6 +203,14 @@ func TestNormalization(t *testing.T) { "5-\xCD\xE2", // EUC-CN "wài" (外) -- ignored (not UTF8) } numInvalid := 2 + + if runtime.GOOS == "windows" { + // On Windows, in case 5 the character gets replaced with a + // replacement character \xEF\xBF\xBD at the point it's written to disk, + // which means it suddenly becomes valid (sort of). + numInvalid-- + } + numValid := len(tests) - numInvalid for _, s1 := range tests {