lib/fs: Evaluate root when watching not on fs creation (fixes #5043) (#5105)

This commit is contained in:
Simon Frei
2018-08-11 22:24:36 +02:00
committed by Jakob Borg
parent b37c05c6b8
commit e20679afe1
5 changed files with 83 additions and 53 deletions

View File

@@ -33,11 +33,17 @@ func TestMain(m *testing.M) {
if err != nil {
panic("Cannot get absolute path to working dir")
}
dir, err = filepath.EvalSymlinks(dir)
if err != nil {
panic("Cannot get real path to working dir")
}
testDirAbs = filepath.Join(dir, testDir)
if runtime.GOOS == "windows" {
testDirAbs = longFilenameSupport(testDirAbs)
}
testFs = NewFilesystem(FilesystemTypeBasic, testDirAbs)
backendBuffer = 10
@@ -154,7 +160,7 @@ func TestWatchOutside(t *testing.T) {
}
cancel()
}()
fs.watchLoop(".", backendChan, outChan, fakeMatcher{}, ctx)
fs.watchLoop(".", testDirAbs, backendChan, outChan, fakeMatcher{}, ctx)
}()
backendChan <- fakeEventInfo(filepath.Join(filepath.Dir(testDirAbs), "outside"))
@@ -177,7 +183,7 @@ func TestWatchSubpath(t *testing.T) {
fs := newBasicFilesystem(testDirAbs)
abs, _ := fs.rooted("sub")
go fs.watchLoop("sub", backendChan, outChan, fakeMatcher{}, ctx)
go fs.watchLoop("sub", testDirAbs, backendChan, outChan, fakeMatcher{}, ctx)
backendChan <- fakeEventInfo(filepath.Join(abs, "file"))
@@ -291,7 +297,7 @@ func TestUnrootedChecked(t *testing.T) {
}
}()
fs := newBasicFilesystem(testDirAbs)
unrooted = fs.unrootedChecked("/random/other/path")
unrooted = fs.unrootedChecked("/random/other/path", testDirAbs)
}
func TestWatchIssue4877(t *testing.T) {