Skip to content

Commit 6fc0b6f

Browse files
milasndeloof
authored andcommitted
build: ensure file handles properly closed (docker#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.
1 parent ab84b6a commit 6fc0b6f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/watch/notify_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ func TestNewDirectoriesAreRecursivelyWatched(t *testing.T) {
181181

182182
// change something inside sub directory
183183
changeFilePath := filepath.Join(subPath, "change")
184-
_, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
184+
file, err := os.OpenFile(changeFilePath, os.O_RDONLY|os.O_CREATE, 0666)
185185
if err != nil {
186186
t.Fatal(err)
187187
}
188+
_ = file.Close()
188189
f.assertEvents(subPath, changeFilePath)
189190
}
190191

0 commit comments

Comments
 (0)