forked from grafana/tanka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linter: Recover panics (grafana#899)
* Linter: Recover panics Currently, the linter is useful but panics on a few projects. The panics make it unusable on a large set of projects With this PR, it will fail linting but all projects will still get linted * Make parallelism <= 0 into an error
- Loading branch information
1 parent
8e496b7
commit 7375466
Showing
4 changed files
with
83 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package jsonnet | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLint(t *testing.T) { | ||
t.Run("no error", func(t *testing.T) { | ||
opts := &LintOpts{Parallelism: 4} | ||
err := Lint([]string{"testdata/importTree"}, opts) | ||
assert.NoError(t, err) | ||
}) | ||
|
||
t.Run("error", func(t *testing.T) { | ||
buf := &bytes.Buffer{} | ||
opts := &LintOpts{Out: buf, Parallelism: 4} | ||
err := Lint([]string{"testdata/lintingError"}, opts) | ||
assert.EqualError(t, err, "Linting has failed for at least one file") | ||
assert.Equal(t, absPath(t, "testdata/lintingError/main.jsonnet")+`:1:7-22 Unused variable: unused | ||
local unused = 'test'; | ||
`, buf.String()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
local unused = 'test'; | ||
{} |