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.
15 func fremove(w *W, path string, files []string) WCase {
16 cas := remove(w, path)
17 cas.Events[0] = &Call{P: path, E: FileDelete}
18 for _, f := range files {
19 cas.Events = append(cas.Events, &Call{P: f, E: FileDelete})
24 func fwrite(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: FileModified}
31 func frename(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: FileRenameFrom},
45 for _, f := range files {
46 cas.Events = append(cas.Events, &Call{P: f, E: FileRenameFrom})
59 func TestWatcherFen(t *testing.T) {
60 w := NewWatcherTest(t, "testdata/vfs.txt", events...)
64 fremove(w, "src/github.com/ppknap/link/include/coost/link", []string{
65 "src/github.com/ppknap/link/include/coost/link/definitions.hpp",
66 "src/github.com/ppknap/link/include/coost/link/detail/bundle.hpp",
67 "src/github.com/ppknap/link/include/coost/link/detail/container_invoker.hpp",
68 "src/github.com/ppknap/link/include/coost/link/detail/container_value_trait.hpp",
69 "src/github.com/ppknap/link/include/coost/link/detail/dummy_type.hpp",
70 "src/github.com/ppknap/link/include/coost/link/detail/function_trait.hpp",
71 "src/github.com/ppknap/link/include/coost/link/detail/immediate_invoker.hpp",
72 "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers/always_same.hpp",
73 "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers/make_unique.hpp",
74 "src/github.com/ppknap/link/include/coost/link/detail/stdhelpers",
75 "src/github.com/ppknap/link/include/coost/link/detail/vertex.hpp",
76 "src/github.com/ppknap/link/include/coost/link/detail/wire.hpp",
77 "src/github.com/ppknap/link/include/coost/link/detail",
78 "src/github.com/ppknap/link/include/coost/link/link.hpp",
81 fwrite(w, "src/github.com/rjeczalik/fs/fs.go", []byte("XD")),
82 fremove(w, "src/github.com/ppknap/link/README.md", nil),
83 frename(w, "src/github.com/rjeczalik/fs/fs.go", nil),
84 frename(w, "src/github.com/rjeczalik/fs/cmd/gotree", []string{
85 "src/github.com/rjeczalik/fs/cmd/gotree/go.go",
86 "src/github.com/rjeczalik/fs/cmd/gotree/main.go",