From 9fe9f115213d7e7bf52d06ebdc69c6df38b1120b Mon Sep 17 00:00:00 2001 From: lucas-str <32294068+lucas-str@users.noreply.github.com> Date: Sat, 6 May 2023 02:02:07 +0200 Subject: Add support for npm-groovy-lint (#4495) * Add support for npm-groovy-lint * Add doc and tests for npm-groovy-lint * Use ale#util#FuzzyJSONDecode instead of json_decode --- .../fixers/test_npmgroovylint_fixer_callback.vader | 23 ++++++++ test/handler/test_npmgroovylint_handler.vader | 63 ++++++++++++++++++++++ test/linter/test_npmgroovylit.vader | 20 +++++++ 3 files changed, 106 insertions(+) create mode 100644 test/fixers/test_npmgroovylint_fixer_callback.vader create mode 100644 test/handler/test_npmgroovylint_handler.vader create mode 100644 test/linter/test_npmgroovylit.vader (limited to 'test') diff --git a/test/fixers/test_npmgroovylint_fixer_callback.vader b/test/fixers/test_npmgroovylint_fixer_callback.vader new file mode 100644 index 00000000..a4b1ee9a --- /dev/null +++ b/test/fixers/test_npmgroovylint_fixer_callback.vader @@ -0,0 +1,23 @@ +Before: + Save b:ale_groovy_npmgroovylint_fix_options + + call ale#assert#SetUpFixerTest('groovy', 'npm-groovy-lint') + +After: + Restore + + call ale#assert#TearDownFixerTest() + +Execute(The callback should return the correct default values): + AssertFixer { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('npm-groovy-lint') . ' --fix %t', + \ } + +Execute(The callback should include custom options): + let b:ale_groovy_npmgroovylint_fix_options = '--format' + + AssertFixer { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('npm-groovy-lint') . ' --format %t', + \ } diff --git a/test/handler/test_npmgroovylint_handler.vader b/test/handler/test_npmgroovylint_handler.vader new file mode 100644 index 00000000..e0dae6d2 --- /dev/null +++ b/test/handler/test_npmgroovylint_handler.vader @@ -0,0 +1,63 @@ +Before: + runtime ale_linters/groovy/npmgroovylint.vim + +After: + call ale#linter#Reset() + +Execute(The npm-groovy-lint handler should parse JSON): + AssertEqual + \ [ + \ { + \ 'col': 0, + \ 'end_col': 1, + \ 'end_lnum': 2, + \ 'filename': 'test2.groovy', + \ 'lnum': 2, + \ 'text': 'Some error message', + \ 'type': 'E', + \ }, + \ { + \ 'filename': 'test.groovy', + \ 'lnum': 1, + \ 'text': 'Some warning message', + \ 'type': 'W', + \ }, + \ ], + \ ale_linters#groovy#npmgroovylint#Handle(bufnr(''), [ + \ '{', + \ ' "files" : {', + \ ' "test.groovy" : {', + \ ' "errors" : [', + \ ' {', + \ ' "id" : 0,', + \ ' "line" : 1,', + \ ' "msg" : "Some warning message",', + \ ' "rule" : "SomeRule",', + \ ' "severity" : "warning"', + \ ' }', + \ ' ]', + \ ' },', + \ ' "test2.groovy": {', + \ ' "errors": [', + \ ' {', + \ ' "id" : 1,', + \ ' "line" : 2,', + \ ' "msg" : "Some error message",', + \ ' "range" : {', + \ ' "end" : {', + \ ' "character" : 1,', + \ ' "line" : 2', + \ ' },', + \ ' "start" : {', + \ ' "character" : 0,', + \ ' "line" : 2', + \ ' }', + \ ' },', + \ ' "rule" : "SomeOtherRule",', + \ ' "severity" : "error"', + \ ' }', + \ ' ]', + \ ' }', + \ ' }', + \ '}', + \ ]) diff --git a/test/linter/test_npmgroovylit.vader b/test/linter/test_npmgroovylit.vader new file mode 100644 index 00000000..25195861 --- /dev/null +++ b/test/linter/test_npmgroovylit.vader @@ -0,0 +1,20 @@ +Before: + Save b:ale_groovy_npmgroovylint_options + + call ale#assert#SetUpLinterTest('groovy', 'npmgroovylint') + call ale#test#SetFilename('test.groovy') + +After: + Restore + + call ale#assert#TearDownLinterTest() + +Execute(The default npm-groovy-lint command should be correct): + AssertLinter 'npm-groovy-lint', + \ ale#Escape('npm-groovy-lint') . ' --failon none --output json --loglevel warning %t' + +Execute(Default options should be configurable): + let b:ale_groovy_npmgroovylint_options = '--loglevel info' + + AssertLinter 'npm-groovy-lint', + \ ale#Escape('npm-groovy-lint') . ' --failon none --output json --loglevel info %t' -- cgit v1.2.3