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.
This commit is contained in:
Milas Bowman 2021-12-17 11:32:28 -05:00 committed by Nicolas De loof
parent ab84b6ac5b
commit 6fc0b6ff27
1 changed files with 2 additions and 1 deletions

View File

@ -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)
}