mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Revert "watch: fix inotify tests on windows" (#3147)
This reverts commit 74ac7997b1c8f497babbbd499ff1f047563d699a.
This commit is contained in:
parent
dda0362b6e
commit
d2d4d05264
@ -1,3 +1,5 @@
|
|||||||
|
// +build !windows
|
||||||
|
|
||||||
package watch
|
package watch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -39,9 +41,6 @@ func TestNoWatches(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEventOrdering(t *testing.T) {
|
func TestEventOrdering(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("Skipping on windows for now")
|
|
||||||
}
|
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
defer f.tearDown()
|
defer f.tearDown()
|
||||||
|
|
||||||
@ -74,9 +73,6 @@ func TestEventOrdering(t *testing.T) {
|
|||||||
// of directories, creates files in them, then deletes
|
// of directories, creates files in them, then deletes
|
||||||
// them all quickly. Make sure there are no errors.
|
// them all quickly. Make sure there are no errors.
|
||||||
func TestGitBranchSwitch(t *testing.T) {
|
func TestGitBranchSwitch(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("Skipping on windows for now")
|
|
||||||
}
|
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
defer f.tearDown()
|
defer f.tearDown()
|
||||||
|
|
||||||
@ -147,11 +143,10 @@ func TestWatchesAreRecursive(t *testing.T) {
|
|||||||
f.events = nil
|
f.events = nil
|
||||||
// change sub directory
|
// change sub directory
|
||||||
changeFilePath := filepath.Join(subPath, "change")
|
changeFilePath := filepath.Join(subPath, "change")
|
||||||
h, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
|
_, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer h.Close()
|
|
||||||
|
|
||||||
f.assertEvents(changeFilePath)
|
f.assertEvents(changeFilePath)
|
||||||
}
|
}
|
||||||
@ -173,12 +168,10 @@ func TestNewDirectoriesAreRecursivelyWatched(t *testing.T) {
|
|||||||
|
|
||||||
// change something inside sub directory
|
// change something inside sub directory
|
||||||
changeFilePath := filepath.Join(subPath, "change")
|
changeFilePath := filepath.Join(subPath, "change")
|
||||||
h, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
|
_, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer h.Close()
|
|
||||||
|
|
||||||
f.assertEvents(subPath, changeFilePath)
|
f.assertEvents(subPath, changeFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,9 +278,6 @@ func TestSingleFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteBrokenLink(t *testing.T) {
|
func TestWriteBrokenLink(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("Symlink creation requires admin privileges on Windows")
|
|
||||||
}
|
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
defer f.tearDown()
|
defer f.tearDown()
|
||||||
|
|
||||||
@ -302,9 +292,6 @@ func TestWriteBrokenLink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteGoodLink(t *testing.T) {
|
func TestWriteGoodLink(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("Symlink creation requires admin privileges on Windows")
|
|
||||||
}
|
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
defer f.tearDown()
|
defer f.tearDown()
|
||||||
|
|
||||||
@ -324,9 +311,6 @@ func TestWriteGoodLink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWatchBrokenLink(t *testing.T) {
|
func TestWatchBrokenLink(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("Symlink creation requires admin privileges on Windows")
|
|
||||||
}
|
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
defer f.tearDown()
|
defer f.tearDown()
|
||||||
|
|
||||||
@ -355,10 +339,6 @@ func TestWatchBrokenLink(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMoveAndReplace(t *testing.T) {
|
func TestMoveAndReplace(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip("Skipping on windows for now")
|
|
||||||
}
|
|
||||||
|
|
||||||
f := newNotifyFixture(t)
|
f := newNotifyFixture(t)
|
||||||
defer f.tearDown()
|
defer f.tearDown()
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/windmilleng/fsnotify"
|
"github.com/windmilleng/fsnotify"
|
||||||
@ -136,7 +135,7 @@ func (d *naiveNotify) loop() {
|
|||||||
defer close(d.wrappedEvents)
|
defer close(d.wrappedEvents)
|
||||||
for e := range d.events {
|
for e := range d.events {
|
||||||
if e.Op&fsnotify.Create != fsnotify.Create {
|
if e.Op&fsnotify.Create != fsnotify.Create {
|
||||||
if d.shouldNotify(e.Name) && !isSpuriousWindowsDirChange(e) {
|
if d.shouldNotify(e.Name) {
|
||||||
d.wrappedEvents <- FileEvent{e.Name}
|
d.wrappedEvents <- FileEvent{e.Name}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -263,22 +262,6 @@ func newWatcher(paths []string, ignore PathMatcher, l logger.Logger) (*naiveNoti
|
|||||||
return wmw, nil
|
return wmw, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Windows' inotify implementation sometimes fires
|
|
||||||
// of spurious WRITE events on directories when the
|
|
||||||
// files inside change.
|
|
||||||
func isSpuriousWindowsDirChange(e fsnotify.Event) bool {
|
|
||||||
if runtime.GOOS != "windows" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if e.Op != fsnotify.Write {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
eIsDir, _ := isDir(e.Name)
|
|
||||||
return eIsDir
|
|
||||||
}
|
|
||||||
|
|
||||||
func isDir(pth string) (bool, error) {
|
func isDir(pth string) (bool, error) {
|
||||||
fi, err := os.Lstat(pth)
|
fi, err := os.Lstat(pth)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build !darwin
|
// +build !darwin,!windows
|
||||||
|
|
||||||
package watch
|
package watch
|
||||||
|
|
||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -93,9 +92,6 @@ func TestDontWatchEachFile(t *testing.T) {
|
|||||||
f.events = nil
|
f.events = nil
|
||||||
|
|
||||||
pid := os.Getpid()
|
pid := os.Getpid()
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
return // skip the inotify count
|
|
||||||
}
|
|
||||||
|
|
||||||
output, err := exec.Command("bash", "-c", fmt.Sprintf(
|
output, err := exec.Command("bash", "-c", fmt.Sprintf(
|
||||||
"find /proc/%d/fd -lname anon_inode:inotify -printf '%%hinfo/%%f\n' | xargs cat | grep -c '^inotify'", pid)).Output()
|
"find /proc/%d/fd -lname anon_inode:inotify -printf '%%hinfo/%%f\n' | xargs cat | grep -c '^inotify'", pid)).Output()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user