aboutsummaryrefslogtreecommitdiffhomepage
path: root/main_test.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-12-21 20:09:34 +0100
committerRon Evans <[email protected]>2019-12-21 23:12:13 +0100
commitd41f01f0031821f17667479cb89aacc47c88ca59 (patch)
treed5abecf0a60eb6740af116f37a851318a1917b0c /main_test.go
parent5a70c8848324c17683892507d622afd6a989eb45 (diff)
downloadtinygo-d41f01f0031821f17667479cb89aacc47c88ca59.tar.gz
tinygo-d41f01f0031821f17667479cb89aacc47c88ca59.zip
main: avoid leaving files open
Eventually, open files should be closed when the GC runs and the finalizer is called. However we shouldn't rely on that. Using `ioutil.ReadFile` as it's a simpler pattern anyway.
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go6
1 files changed, 1 insertions, 5 deletions
diff --git a/main_test.go b/main_test.go
index 3568f4c9e..bb04c3946 100644
--- a/main_test.go
+++ b/main_test.go
@@ -114,11 +114,7 @@ func runTest(path, target string, t *testing.T) {
if path[len(path)-1] == os.PathSeparator {
txtpath = path + "out.txt"
}
- f, err := os.Open(txtpath)
- if err != nil {
- t.Fatal("could not open expected output file:", err)
- }
- expected, err := ioutil.ReadAll(f)
+ expected, err := ioutil.ReadFile(txtpath)
if err != nil {
t.Fatal("could not read expected output file:", err)
}