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.
5 // +build darwin,kqueue dragonfly freebsd netbsd openbsd
15 func kqremove(w *W, path string, files []string) WCase {
16 cas := remove(w, path)
17 cas.Events[0] = &Call{P: path, E: NoteDelete}
18 for _, f := range files {
19 cas.Events = append(cas.Events, &Call{P: f, E: NoteDelete})
24 func kqwrite(w *W, path string, p []byte) WCase {
25 cas := write(w, path, p)
26 path = cas.Events[0].Path()
27 cas.Events[0] = &Call{P: path, E: NoteExtend | NoteWrite}
31 func kqrename(w *W, path string, files []string) WCase {
35 file := filepath.Join(w.root, path)
36 if err := os.Rename(file, file+ext); err != nil {
37 w.Fatalf("Rename(%q, %q)=%v", path, path+ext, err)
41 &Call{P: path + ext, E: osSpecificCreate},
42 &Call{P: path, E: NoteRename},
45 for _, f := range files {
46 cas.Events = append(cas.Events, &Call{P: f, E: NoteRename})
51 func kqlink(w *W, path string) WCase {
55 file := filepath.Join(w.root, path)
56 if err := os.Link(file, file+ext); err != nil {
57 w.Fatalf("Link(%q, %q)=%v", path, path+ext, err)
61 &Call{P: path, E: NoteLink},
62 &Call{P: path + ext, E: osSpecificCreate},
77 func TestWatcherKqueue(t *testing.T) {
78 w := NewWatcherTest(t, "testdata/vfs.txt", events...)
82 kqremove(w, "src/github.com/ppknap/link/include/coost/link", []string{
83 "src/github.com/ppknap/link/include/coost/link/definitions.hpp",
84 "src/github.com/ppknap/link/include/coost/link/detail/bundle.hpp",
85 "src/github.com/ppknap/link/include/coost/link/detail/container_invoker.hpp",
86 "src/github.com/ppknap/link/include/coost/link/detail/container_value_trait.hpp",
87 "src/github.com/ppknap/link/include/coost/link/detail/dummy_type.hpp",
88 "src/github.com/ppknap/link/include/coost/link/detail/function_trait.hpp",
89 "src/github.com/ppknap/link/include/coost/link/detail/immediate_invoker.hpp",
90 "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers/always_same.hpp",
91 "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers/make_unique.hpp",
92 "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers",
93 "src/github.com/ppknap/link/include/coost/link/detail/vertex.hpp",
94 "src/github.com/ppknap/link/include/coost/link/detail/wire.hpp",
95 "src/github.com/ppknap/link/include/coost/link/detail",
96 "src/github.com/ppknap/link/include/coost/link/link.hpp",
99 kqwrite(w, "src/github.com/rjeczalik/fs/fs.go", []byte("XD")),
100 kqremove(w, "src/github.com/ppknap/link/README.md", nil),
101 kqlink(w, "src/github.com/rjeczalik/fs/LICENSE"),
102 kqrename(w, "src/github.com/rjeczalik/fs/fs.go", nil),
103 kqrename(w, "src/github.com/rjeczalik/fs/cmd/gotree", []string{
104 "src/github.com/rjeczalik/fs/cmd/gotree/go.go",
105 "src/github.com/rjeczalik/fs/cmd/gotree/main.go",
110 w.ExpectAll(cases[:])