mirror of https://github.com/docker/compose.git
watch: fix a flaky test by ignoring spurious events correctly (#162)
This commit is contained in:
parent
3850a34114
commit
4801d2b1a4
|
@ -231,6 +231,7 @@ func TestSingleFile(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.fsync()
|
||||
|
||||
d2 := []byte("hello\nworld\n")
|
||||
err = ioutil.WriteFile(path, d2, 0644)
|
||||
|
|
|
@ -34,7 +34,7 @@ func (d *darwinNotify) isTrackingPath(path string) bool {
|
|||
}
|
||||
|
||||
func (d *darwinNotify) loop() {
|
||||
ignoredSpuriousEvent := false
|
||||
ignoredSpuriousEvents := make(map[string]bool, 0)
|
||||
for {
|
||||
select {
|
||||
case <-d.stop:
|
||||
|
@ -50,8 +50,8 @@ func (d *darwinNotify) loop() {
|
|||
// ignore the first event that says the watched directory
|
||||
// has been created. these are fired spuriously on initiation.
|
||||
if e.Flags&fsevents.ItemCreated == fsevents.ItemCreated {
|
||||
if d.isTrackingPath(e.Path) && !ignoredSpuriousEvent {
|
||||
ignoredSpuriousEvent = true
|
||||
if !ignoredSpuriousEvents[e.Path] && d.isTrackingPath(e.Path) {
|
||||
ignoredSpuriousEvents[e.Path] = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue