@@ -152,7 +152,14 @@ package foo
152
152
}
153
153
},
154
154
expectedEvents : []protocol.FileEvent {
155
- {URI : "foo/bar.go" , Type : protocol .Deleted },
155
+ // We only assert that the directory deletion event exists,
156
+ // because file system event behavior is inconsistent across
157
+ // platforms when deleting a non-empty directory.
158
+ // e.g. windows-amd64 may only emit a single dir removal event,
159
+ // freebsd-amd64 report dir removal before file removal,
160
+ // linux-amd64 report the reverse order.
161
+ // Therefore, the most reliable and cross-platform compatible
162
+ // signal is the deletion event for the directory itself.
156
163
{URI : "foo" , Type : protocol .Deleted },
157
164
},
158
165
},
@@ -226,6 +233,7 @@ package foo
226
233
227
234
matched := 0
228
235
foundAll := make (chan struct {})
236
+ var gots []protocol.FileEvent
229
237
var closeWG sync.WaitGroup
230
238
closeWG .Add (2 )
231
239
go func () {
@@ -242,6 +250,7 @@ package foo
242
250
// the received events. It confirms not only that all wanted events
243
251
// are present, but also that their relative order is preserved.
244
252
for events := range eventChan {
253
+ gots = append (gots , events ... )
245
254
for _ , got := range events {
246
255
if matched == len (tt .expectedEvents ) {
247
256
break
@@ -267,7 +276,7 @@ package foo
267
276
case <- foundAll :
268
277
case <- time .After (30 * time .Second ):
269
278
if matched < len (tt .expectedEvents ) {
270
- t .Errorf ("missing expected events: %#v\n all expected : %#v" , tt . expectedEvents [ matched ] , tt .expectedEvents )
279
+ t .Errorf ("found %v matching events\n all want : %#v\n all got : %#v" , matched , tt .expectedEvents , gots )
271
280
}
272
281
}
273
282
0 commit comments