File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ func TestNoEvents(t *testing.T) {
28
28
f .assertEvents ()
29
29
}
30
30
31
+ func TestNoWatches (t * testing.T ) {
32
+ f := newNotifyFixture (t )
33
+ defer f .tearDown ()
34
+ f .paths = nil
35
+ f .rebuildWatcher ()
36
+ f .assertEvents ()
37
+ }
38
+
31
39
func TestEventOrdering (t * testing.T ) {
32
40
f := newNotifyFixture (t )
33
41
defer f .tearDown ()
@@ -586,6 +594,10 @@ func (f *notifyFixture) consumeEventsInBackground(ctx context.Context) chan erro
586
594
}
587
595
588
596
func (f * notifyFixture ) fsync () {
597
+ if len (f .paths ) == 0 {
598
+ return
599
+ }
600
+
589
601
syncPathBase := fmt .Sprintf ("sync-%d.txt" , time .Now ().UnixNano ())
590
602
syncPath := filepath .Join (f .paths [0 ], syncPathBase )
591
603
anySyncPath := filepath .Join (f .paths [0 ], "sync-" )
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ func (d *darwinNotify) initAdd(name string) {
89
89
}
90
90
91
91
func (d * darwinNotify ) Start () error {
92
+ if len (d .stream .Paths ) == 0 {
93
+ return nil
94
+ }
95
+
92
96
numberOfWatches .Add (int64 (len (d .stream .Paths )))
93
97
94
98
d .stream .Start ()
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ type naiveNotify struct {
35
35
}
36
36
37
37
func (d * naiveNotify ) Start () error {
38
+ if len (d .notifyList ) == 0 {
39
+ return nil
40
+ }
41
+
38
42
for name := range d .notifyList {
39
43
fi , err := os .Stat (name )
40
44
if err != nil && ! os .IsNotExist (err ) {
You can’t perform that action at this time.
0 commit comments