lib/fs: Fix watcher panic due to casing on windows (fixes #4877) (#4878)

This commit is contained in:
Simon Frei
2018-04-16 20:07:00 +02:00
committed by Jakob Borg
parent 8f6d587ecb
commit 01aef75c96
3 changed files with 48 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ import (
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
"testing"
"time"
@@ -256,6 +257,35 @@ func TestUnrootedChecked(t *testing.T) {
unrooted = fs.unrootedChecked("/random/other/path")
}
func TestWatchIssue4877(t *testing.T) {
if runtime.GOOS != "windows" {
t.Skip("Windows specific test")
}
name := "Issue4877"
file := "file"
testCase := func() {
createTestFile(name, file)
}
expectedEvents := []Event{
{file, NonRemove},
}
allowedEvents := []Event{
{name, NonRemove},
}
origTestFs := testFs
testFs = NewFilesystem(FilesystemTypeBasic, strings.ToLower(testDirAbs[:1])+strings.ToUpper(testDirAbs[1:]))
defer func() {
testFs = origTestFs
}()
testScenario(t, name, testCase, expectedEvents, allowedEvents, "")
}
// path relative to folder root, also creates parent dirs if necessary
func createTestFile(name string, file string) string {
joined := filepath.Join(name, file)