From 6fc0b6ff27d6bdc8eaa8fbfbd16d1f06b6f73f60 Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Fri, 17 Dec 2021 11:32:28 -0500 Subject: [PATCH] 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. --- pkg/watch/notify_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/watch/notify_test.go b/pkg/watch/notify_test.go index 357b5e763..5315fd82c 100644 --- a/pkg/watch/notify_test.go +++ b/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) }