1 // Copyright (c) 2014-2015 The Notify Authors. All rights reserved.
2 // Use of this source code is governed by the MIT license that can be
3 // found in the LICENSE file.
12 func TestNonrecursiveTree(t *testing.T) {
13 n := NewNonrecursiveTreeTest(t, "testdata/vfs.txt")
18 watches := [...]RCase{
23 P: "src/github.com/rjeczalik/fs/fs.go",
30 P: "src/github.com/rjeczalik/fs/fs.go",
39 P: "src/github.com/rjeczalik/fs/cmd/...",
46 P: "src/github.com/rjeczalik/fs/cmd",
51 P: "src/github.com/rjeczalik/fs/cmd/gotree",
56 P: "src/github.com/rjeczalik/fs/cmd/mktree",
65 P: "src/github.com/rjeczalik/fs/cmd/...",
72 P: "src/github.com/rjeczalik/fs/cmd",
74 NE: Create | Remove | Rename,
78 P: "src/github.com/rjeczalik/fs/cmd/gotree",
80 NE: Create | Remove | Rename,
84 P: "src/github.com/rjeczalik/fs/cmd/mktree",
86 NE: Create | Remove | Rename,
94 P: "src/github.com/rjeczalik/fs/cmd/mktree/...",
101 P: "src/github.com/rjeczalik/fs/cmd/mktree",
102 E: Create | Remove | Rename,
103 NE: Create | Remove | Rename | Write,
111 P: "src/github.com/pblaszczyk/qttu/include",
118 P: "src/github.com/pblaszczyk/qttu/include",
127 P: "src/github.com/pblaszczyk/qttu/include/qttu/detail/...",
134 P: "src/github.com/pblaszczyk/qttu/include/qttu/detail",
143 P: "src/github.com/pblaszczyk/qttu/include/...",
150 P: "src/github.com/pblaszczyk/qttu/include",
156 P: "src/github.com/pblaszczyk/qttu/include/qttu",
161 P: "src/github.com/pblaszczyk/qttu/include/qttu/detail",
163 NE: Create | Write | Rename,
171 P: "src/github.com/pblaszczyk/...",
178 P: "src/github.com/pblaszczyk",
183 P: "src/github.com/pblaszczyk/qttu",
188 P: "src/github.com/pblaszczyk/qttu/include",
190 NE: Create | Rename | Write,
194 P: "src/github.com/pblaszczyk/qttu/include/qttu",
196 NE: Create | Rename | Write,
200 P: "src/github.com/pblaszczyk/qttu/src",
209 P: "src/github.com/pblaszczyk/qttu/include/...",
219 P: "src/github.com/pblaszczyk/qttu",
226 P: "src/github.com/pblaszczyk/qttu",
228 NE: Create | Write | Remove,
234 n.ExpectRecordedCalls(watches[:])
236 events := [...]TCase{
239 Event: Call{P: "src/github.com/rjeczalik/fs/fs.go", E: Rename},
240 Receiver: Chans{ch[0]},
244 Event: Call{P: "src/github.com/rjeczalik/fs/fs.go", E: Create},
249 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/cmd.go", E: Remove},
250 Receiver: Chans{ch[1]},
254 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/doc.go", E: Write},
259 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/mktree/main.go", E: Write},
260 Receiver: Chans{ch[2]},
264 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/mktree/tree.go", E: Create},
269 Event: Call{P: "src/github.com/pblaszczyk/qttu/include/.lock", E: Create},
270 Receiver: Chans{ch[3]},
274 Event: Call{P: "src/github.com/pblaszczyk/qttu/include/qttu/detail/registry.hh", E: Write},
275 Receiver: Chans{ch[3], ch[1], ch[4]},
279 Event: Call{P: "src/github.com/pblaszczyk/qttu/include/qttu", E: Remove},
284 Event: Call{P: "src/github.com/pblaszczyk/qttu/include", E: Remove},
285 Receiver: Chans{ch[3]},
289 n.ExpectTreeEvents(events[:], ch)
309 P: "src/github.com/pblaszczyk/qttu",
310 E: Create | Write | Remove,
324 P: "src/github.com/rjeczalik/fs/cmd",
325 E: Create | Remove | Rename,
330 P: "src/github.com/rjeczalik/fs/cmd/gotree",
331 E: Create | Remove | Rename,
336 P: "src/github.com/rjeczalik/fs/cmd/mktree",
337 E: Create | Remove | Rename | Write,
351 P: "src/github.com/pblaszczyk",
355 P: "src/github.com/pblaszczyk/qttu",
359 P: "src/github.com/pblaszczyk/qttu/include",
360 E: Create | Rename | Write,
365 P: "src/github.com/pblaszczyk/qttu/include/qttu",
366 E: Create | Rename | Write,
371 P: "src/github.com/pblaszczyk/qttu/include/qttu/detail",
372 E: Create | Rename | Write,
377 P: "src/github.com/pblaszczyk/qttu/src",
381 P: "src/github.com/rjeczalik/fs/cmd",
385 P: "src/github.com/rjeczalik/fs/cmd/gotree",
389 P: "src/github.com/rjeczalik/fs/cmd/mktree",
402 P: "src/github.com/pblaszczyk/qttu/include",
406 P: "src/github.com/pblaszczyk/qttu/include/qttu",
410 P: "src/github.com/pblaszczyk/qttu/include/qttu/detail",
414 P: "src/github.com/rjeczalik/fs/fs.go",
420 n.ExpectRecordedCalls(stops[:])
422 n.Walk(func(nd node) error {
423 if len(nd.Watch) != 0 {
424 return fmt.Errorf("unexpected watchpoint: name=%s, eventset=%v (len=%d)",
425 nd.Name, nd.Watch.Total(), len(nd.Watch))
431 func TestNonrecursiveTreeInternal(t *testing.T) {
432 n, c := NewNonrecursiveTreeTestC(t, "testdata/vfs.txt")
437 watches := [...]RCase{
442 P: "src/github.com/rjeczalik/fs/cmd/...",
449 P: "src/github.com/rjeczalik/fs/cmd",
454 P: "src/github.com/rjeczalik/fs/cmd/gotree",
459 P: "src/github.com/rjeczalik/fs/cmd/mktree",
468 P: "src/github.com/ppknap/link/include/coost/...",
475 P: "src/github.com/ppknap/link/include/coost",
480 P: "src/github.com/ppknap/link/include/coost/link",
485 P: "src/github.com/ppknap/link/include/coost/link/detail",
490 P: "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers",
497 n.ExpectRecordedCalls(watches[:])
499 events := [...]TCase{
502 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/dir", E: Create, Dir: true},
507 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/dir/another", E: Create, Dir: true},
512 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/file", E: Create, Dir: false},
517 Event: Call{P: "src/github.com/ppknap/link/include/coost/dir", E: Create, Dir: true},
518 Receiver: Chans{ch[1], c},
522 Event: Call{P: "src/github.com/ppknap/link/include/coost/dir/another", E: Create, Dir: true},
523 Receiver: Chans{ch[1], c},
527 Event: Call{P: "src/github.com/ppknap/link/include/coost/file", E: Create, Dir: false},
528 Receiver: Chans{ch[1]},
532 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/mktree", E: Remove},
533 Receiver: Chans{ch[0]},
537 Event: Call{P: "src/github.com/rjeczalik/fs/cmd/rmtree", E: Create, Dir: true},
542 n.ExpectTreeEvents(events[:], ch)