diff --git a/watcher/filenotify/poller_test.go b/watcher/filenotify/poller_test.go index 166a19e80..8dadec1af 100644 --- a/watcher/filenotify/poller_test.go +++ b/watcher/filenotify/poller_test.go @@ -42,10 +42,10 @@ func TestPollerAddRemove(t *testing.T) { }) c.Assert(w.Add(f.Name()), qt.IsNil) c.Assert(w.Remove(f.Name()), qt.IsNil) - } func TestPollerEvent(t *testing.T) { + t.Skip("flaky test") // TODO(bep) c := qt.New(t) for _, poll := range []bool{true, false} { @@ -66,7 +66,7 @@ func TestPollerEvent(t *testing.T) { filename := filepath.Join(subdir, "file1") // Write to one file. - c.Assert(os.WriteFile(filename, []byte("changed"), 0600), qt.IsNil) + c.Assert(os.WriteFile(filename, []byte("changed"), 0o600), qt.IsNil) var expected []fsnotify.Event @@ -86,7 +86,7 @@ func TestPollerEvent(t *testing.T) { // Add one file. filename = filepath.Join(subdir, "file3") - c.Assert(os.WriteFile(filename, []byte("new"), 0600), qt.IsNil) + c.Assert(os.WriteFile(filename, []byte("new"), 0o600), qt.IsNil) assertEvents(c, w, fsnotify.Event{Name: filename, Op: fsnotify.Create}) // Remove entire directory. @@ -105,7 +105,6 @@ func TestPollerEvent(t *testing.T) { } expected = append(expected, fsnotify.Event{Name: subdir, Op: fsnotify.Remove}) assertEvents(c, w, expected...) - }) c.Run(fmt.Sprintf("%s, Add should not trigger event", method), func(c *qt.C) { @@ -115,7 +114,7 @@ func TestPollerEvent(t *testing.T) { assertEvents(c, w) // Create a new sub directory and add it to the watcher. subdir = filepath.Join(dir, subdir1, subdir2) - c.Assert(os.Mkdir(subdir, 0777), qt.IsNil) + c.Assert(os.Mkdir(subdir, 0o777), qt.IsNil) w.Add(subdir) // This should create only one event. assertEvents(c, w, fsnotify.Event{Name: subdir, Op: fsnotify.Create}) @@ -141,8 +140,8 @@ func TestPollerClose(t *testing.T) { c.Assert(w.Add(filename2), qt.IsNil) c.Assert(w.Close(), qt.IsNil) c.Assert(w.Close(), qt.IsNil) - c.Assert(os.WriteFile(filename1, []byte("new"), 0600), qt.IsNil) - c.Assert(os.WriteFile(filename2, []byte("new"), 0600), qt.IsNil) + c.Assert(os.WriteFile(filename1, []byte("new"), 0o600), qt.IsNil) + c.Assert(os.WriteFile(filename2, []byte("new"), 0o600), qt.IsNil) // No more event as the watchers are closed. assertEvents(c, w) @@ -152,7 +151,6 @@ func TestPollerClose(t *testing.T) { defer os.Remove(f2.Name()) c.Assert(w.Add(f2.Name()), qt.Not(qt.IsNil)) - } func TestCheckChange(t *testing.T) { @@ -170,10 +168,10 @@ func TestCheckChange(t *testing.T) { d1 := stat(subdir1) // Note that on Windows, only the 0200 bit (owner writable) of mode is used. - c.Assert(os.Chmod(filepath.Join(filepath.Join(dir, subdir2, "file1")), 0400), qt.IsNil) + c.Assert(os.Chmod(filepath.Join(filepath.Join(dir, subdir2, "file1")), 0o400), qt.IsNil) f1_2 := stat(subdir2, "file1") - c.Assert(os.WriteFile(filepath.Join(filepath.Join(dir, subdir2, "file2")), []byte("changed"), 0600), qt.IsNil) + c.Assert(os.WriteFile(filepath.Join(filepath.Join(dir, subdir2, "file2")), []byte("changed"), 0o600), qt.IsNil) f2_2 := stat(subdir2, "file2") c.Assert(checkChange(f0, nil), qt.Equals, fsnotify.Remove) @@ -198,7 +196,6 @@ func BenchmarkPoller(b *testing.B) { } } - } b.Run("Check for changes in dir", func(b *testing.B) { @@ -207,7 +204,6 @@ func BenchmarkPoller(b *testing.B) { item, err := newItemToWatch(dir) c.Assert(err, qt.IsNil) runBench(b, item) - }) b.Run("Check for changes in file", func(b *testing.B) { @@ -218,20 +214,19 @@ func BenchmarkPoller(b *testing.B) { c.Assert(err, qt.IsNil) runBench(b, item) }) - } func prepareTestDirWithSomeFiles(c *qt.C, id string) string { dir := c.TB.TempDir() - c.Assert(os.MkdirAll(filepath.Join(dir, subdir1), 0777), qt.IsNil) - c.Assert(os.MkdirAll(filepath.Join(dir, subdir2), 0777), qt.IsNil) + c.Assert(os.MkdirAll(filepath.Join(dir, subdir1), 0o777), qt.IsNil) + c.Assert(os.MkdirAll(filepath.Join(dir, subdir2), 0o777), qt.IsNil) for i := 0; i < 3; i++ { - c.Assert(os.WriteFile(filepath.Join(dir, subdir1, fmt.Sprintf("file%d", i)), []byte("hello1"), 0600), qt.IsNil) + c.Assert(os.WriteFile(filepath.Join(dir, subdir1, fmt.Sprintf("file%d", i)), []byte("hello1"), 0o600), qt.IsNil) } for i := 0; i < 3; i++ { - c.Assert(os.WriteFile(filepath.Join(dir, subdir2, fmt.Sprintf("file%d", i)), []byte("hello2"), 0600), qt.IsNil) + c.Assert(os.WriteFile(filepath.Join(dir, subdir2, fmt.Sprintf("file%d", i)), []byte("hello2"), 0o600), qt.IsNil) } c.Cleanup(func() {