Skip to content

Commit

Permalink
analyzer: close file descriptor in tests (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
peakle committed Jan 1, 2022
1 parent 135dd93 commit 184fad6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions analyzer/analyzer_test.go
Expand Up @@ -14,11 +14,12 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"golang.org/x/tools/go/analysis/analysistest"

"github.com/quasilyte/go-ruleguard/analyzer"
"github.com/quasilyte/go-ruleguard/ruleguard/goutil"
"github.com/quasilyte/go-ruleguard/ruleguard/irconv"
"github.com/quasilyte/go-ruleguard/ruleguard/irprint"
"golang.org/x/tools/go/analysis/analysistest"
)

var tests = []struct {
Expand Down Expand Up @@ -176,7 +177,10 @@ var rulesFile = %s
if err != nil {
t.Fatal(err)
}
defer os.Remove(mainFile.Name())
defer func() {
mainFile.Close()
os.Remove(mainFile.Name())
}()
_, err = mainFile.WriteString(fmt.Sprintf(analyzerTemplate, irfileBuf.String()))
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 184fad6

Please sign in to comment.