Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(727)

Unified Diff: src/pkg/exp/inotify/inotify_linux_test.go

Issue 6553059: code review 6553059: exp/inotify: cleanup ignored watch
Patch Set: diff -r 3836bcbafa69 https://code.google.com/p/go Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/exp/inotify/inotify_linux.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/exp/inotify/inotify_linux_test.go
===================================================================
--- a/src/pkg/exp/inotify/inotify_linux_test.go
+++ b/src/pkg/exp/inotify/inotify_linux_test.go
@@ -36,7 +36,7 @@
// Receive errors on the error channel on a separate goroutine
go func() {
for err := range watcher.Error {
- t.Fatalf("error received: %s", err)
+ t.Errorf("error received: %s", err)
}
}()
@@ -105,3 +105,46 @@
t.Fatal("expected error on Watch() after Close(), got nil")
}
}
+func TestInotifyIgnored(t *testing.T) {
+ watcher, err := NewWatcher()
+ if err != nil {
+ t.Fatalf("NewWatcher failed: %s", err)
+ }
+ defer watcher.Close()
+
+ dir, err := ioutil.TempDir("", "inotify")
+ if err != nil {
+ t.Fatalf("TempDir failed: %s", err)
+ }
+ err = watcher.Watch(dir)
+ if err != nil {
+ t.Fatalf("Watch failed: %s", err)
+ }
+ done := make(chan bool)
+ go func() {
+ for err := range watcher.Error {
+ t.Errorf("error received: %s", err)
+ }
+ t.Log("error channel closed")
+ done <- true
+ }()
+ go func() {
+ for event := range watcher.Event {
+ t.Logf("event received: %s", event)
+ }
+ t.Log("event channel closed")
+ }()
+ os.Remove(dir)
+ time.Sleep(50 * time.Millisecond)
+ // Check if the watch was removed by attempting to remove it explicitly
+ err = watcher.RemoveWatch(dir)
+ if err == nil || err.Error() != "can't remove non-existent inotify watch for: "+dir {
+ t.Error("expected removed watch")
+ }
+ watcher.Close()
+ select {
+ case <-done:
+ case <-time.After(50 * time.Millisecond):
+ t.Fatal("double Close() test failed: second Close() call didn't return")
+ }
+}
« no previous file with comments | « src/pkg/exp/inotify/inotify_linux.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b