mirror of https://github.com/golang/go.git
exp/inotify: remove use of _test
Fixes #2573. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/5676063
This commit is contained in:
parent
cc34f4b565
commit
7e8a369426
|
|
@ -7,6 +7,7 @@
|
||||||
package inotify
|
package inotify
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -16,16 +17,19 @@ func TestInotifyEvents(t *testing.T) {
|
||||||
// Create an inotify watcher instance and initialize it
|
// Create an inotify watcher instance and initialize it
|
||||||
watcher, err := NewWatcher()
|
watcher, err := NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewWatcher() failed: %s", err)
|
t.Fatalf("NewWatcher failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("NEEDS TO BE CONVERTED TO NEW GO TOOL") // TODO
|
dir, err := ioutil.TempDir("", "inotify")
|
||||||
return
|
if err != nil {
|
||||||
|
t.Fatalf("TempDir failed: %s", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
// Add a watch for "_test"
|
// Add a watch for "_test"
|
||||||
err = watcher.Watch("_test")
|
err = watcher.Watch(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Watcher.Watch() failed: %s", err)
|
t.Fatalf("Watch failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive errors on the error channel on a separate goroutine
|
// Receive errors on the error channel on a separate goroutine
|
||||||
|
|
@ -35,7 +39,7 @@ func TestInotifyEvents(t *testing.T) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
const testFile string = "_test/TestInotifyEvents.testfile"
|
testFile := dir + "/TestInotifyEvents.testfile"
|
||||||
|
|
||||||
// Receive events on the event channel on a separate goroutine
|
// Receive events on the event channel on a separate goroutine
|
||||||
eventstream := watcher.Event
|
eventstream := watcher.Event
|
||||||
|
|
@ -58,7 +62,7 @@ func TestInotifyEvents(t *testing.T) {
|
||||||
// This should add at least one event to the inotify event queue
|
// This should add at least one event to the inotify event queue
|
||||||
_, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
|
_, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("creating test file failed: %s", err)
|
t.Fatalf("creating test file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We expect this event to be received almost immediately, but let's wait 1 s to be sure
|
// We expect this event to be received almost immediately, but let's wait 1 s to be sure
|
||||||
|
|
@ -95,7 +99,7 @@ func TestInotifyClose(t *testing.T) {
|
||||||
t.Fatal("double Close() test failed: second Close() call didn't return")
|
t.Fatal("double Close() test failed: second Close() call didn't return")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := watcher.Watch("_test")
|
err := watcher.Watch(os.TempDir())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error on Watch() after Close(), got nil")
|
t.Fatal("expected error on Watch() after Close(), got nil")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue