瀏覽代碼

build: ensure file handles properly closed (#5298)

I've been running the test suite (`./internal/engine` in particular)
with `-count X` a lot recently to catch timing-related test failures.

After running enough times, the tests start failing due to too many
open files, so I did an audit and found a few places where files or
readers weren't always being closed.
Milas Bowman 3 年之前
父節點
當前提交
6fc0b6ff27
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      pkg/watch/notify_test.go

+ 2 - 1
pkg/watch/notify_test.go

@@ -181,10 +181,11 @@ func TestNewDirectoriesAreRecursivelyWatched(t *testing.T) {
 
 	// change something inside sub directory
 	changeFilePath := filepath.Join(subPath, "change")
-	_, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
+	file, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
 	if err != nil {
 		t.Fatal(err)
 	}
+	_ = file.Close()
 	f.assertEvents(subPath, changeFilePath)
 }