diff options
Diffstat (limited to 'test')
9 files changed, 115 insertions, 6 deletions
diff --git a/test/command_callback/test_bashate_command_callback.vader b/test/command_callback/test_bashate_command_callback.vader new file mode 100644 index 00000000..714cf690 --- /dev/null +++ b/test/command_callback/test_bashate_command_callback.vader @@ -0,0 +1,15 @@ +Before: + call ale#assert#SetUpLinterTest('sh', 'bashate') + call ale#test#SetFilename('test.sh') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default bashate command should be correct): + AssertLinter 'bashate', ale#Escape('bashate') . ' %t' + +Execute(The bashate command should accept options): + let b:ale_sh_bashate_options = '-i E310 --max-line-length 100' + + AssertLinter 'bashate', + \ ale#Escape('bashate') . ' -i E310 --max-line-length 100 %t' diff --git a/test/command_callback/test_checkstyle_command_callback.vader b/test/command_callback/test_checkstyle_command_callback.vader index 7a9f26b3..5824df87 100644 --- a/test/command_callback/test_checkstyle_command_callback.vader +++ b/test/command_callback/test_checkstyle_command_callback.vader @@ -20,11 +20,11 @@ Execute(The checkstyle executable should be configurable): \ . ' %s' Execute(Custom options should be supported): - let b:ale_java_checkstyle_options = '--foobar' + let b:ale_java_checkstyle_options = '--foobar -cp -classpath /path/to/checkstyle-8.7-all.jar' AssertLinter 'checkstyle', \ ale#Escape('checkstyle') - \ . ' --foobar' + \ . ' --foobar -cp -classpath /path/to/checkstyle-8.7-all.jar' \ . ' -c ' . ale#Escape('/google_checks.xml') \ . ' %s' diff --git a/test/command_callback/test_zig_zls_callbacks.vader b/test/command_callback/test_zig_zls_callbacks.vader new file mode 100644 index 00000000..6e42cc4b --- /dev/null +++ b/test/command_callback/test_zig_zls_callbacks.vader @@ -0,0 +1,15 @@ +Before: + call ale#assert#SetUpLinterTest('zig', 'zls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'zls', ale#Escape('zls') + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('zig-zls-project/main.zig') + + AssertLSPProject ale#path#Simplify(g:dir . '/zig-zls-project') diff --git a/test/command_callback/zig-zls-project/build.zig b/test/command_callback/zig-zls-project/build.zig new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/zig-zls-project/build.zig diff --git a/test/eslint-test-files/react-app/subdir-with-package-json/node_modules/.gitkeep b/test/eslint-test-files/react-app/subdir-with-package-json/node_modules/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/eslint-test-files/react-app/subdir-with-package-json/node_modules/.gitkeep diff --git a/test/fixers/test_ktlint_fixer_callback.vader b/test/fixers/test_ktlint_fixer_callback.vader index 47b37788..ba01a409 100644 --- a/test/fixers/test_ktlint_fixer_callback.vader +++ b/test/fixers/test_ktlint_fixer_callback.vader @@ -21,9 +21,8 @@ Execute(The ktlint callback should return the correct default values): AssertEqual \ { \ 'command': ale#Escape('xxxinvalid') - \ . ' %t' + \ . ' --stdin' \ . ' --format', - \ 'read_temporary_file': 1, \ }, \ ale#fixers#ktlint#Fix(bufnr('')) @@ -37,8 +36,7 @@ Execute(The ktlint callback should include custom ktlint options): \ 'command': ale#Escape('xxxinvalid') \ . ' ' . g:ale_kotlin_ktlint_options \ . ' --ruleset /path/to/custom/ruleset.jar' - \ . ' %t' + \ . ' --stdin' \ . ' --format', - \ 'read_temporary_file': 1, \ }, \ ale#fixers#ktlint#Fix(bufnr('')) diff --git a/test/handler/test_bashate_handler.vader b/test/handler/test_bashate_handler.vader new file mode 100644 index 00000000..b61bb956 --- /dev/null +++ b/test/handler/test_bashate_handler.vader @@ -0,0 +1,36 @@ +Before: + runtime ale_linters/sh/bashate.vim + +After: + call ale#linter#Reset() + +Execute(The bashate handler should handle basic errors): + AssertEqual + \ [ + \ { + \ 'lnum': 777, + \ 'col': 1, + \ 'text': 'E003 Indent not multiple of 4', + \ }, + \ { + \ 'lnum': 783, + \ 'col': 1, + \ 'text': 'E020 Function declaration not in format ^function name {$', + \ }, + \ { + \ 'lnum': 786, + \ 'col': 1, + \ 'text': 'E010 The "do" should be on same line as for', + \ }, + \ { + \ 'lnum': 791, + \ 'col': 1, + \ 'text': 'E006 Line too long', + \ }, + \ ], + \ ale_linters#sh#bashate#Handle(bufnr(''), [ + \ 'run:777:1: E003 Indent not multiple of 4', + \ 'run:783:1: E020 Function declaration not in format ^function name {$', + \ 'run:786:1: E010 The "do" should be on same line as for', + \ 'run:791:1: E006 Line too long', + \ ]) diff --git a/test/handler/test_puppet_handler.vader b/test/handler/test_puppet_handler.vader index e73c9dc7..03adc9f0 100644 --- a/test/handler/test_puppet_handler.vader +++ b/test/handler/test_puppet_handler.vader @@ -49,3 +49,29 @@ Execute(The puppet handler should parse lines and column correctly): \ "Error: Could not parse for environment production: Syntax error at ':' at C:/puppet/modules/nginx/manifests/init.pp:54:9", \ "Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 45, column: 12)", \ ]) + +Execute(The puppet handler should correctly parse errors that are reported before even trying to parse for an environment): + " Line Error + AssertEqual + \ [ + \ { + \ 'lnum': 5, + \ 'col': 11, + \ 'text': "Illegal attempt to assign to 'a Name'. Not an assignable reference" + \ }, + \ ], + \ ale_linters#puppet#puppet#Handle(255, [ + \ "Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11)", + \ ]) +Execute(The puppet handler should parse lines when end of input is the location): + AssertEqual + \ [ + \ { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': "Syntax error at end of input" + \ }, + \ ], + \ ale_linters#puppet#puppet#Handle(255, [ + \ "Error: Could not parse for environment production: Syntax error at end of input (file: /tmp//modules/test/manifests/init.pp)", + \ ]) diff --git a/test/test_eslint_executable_detection.vader b/test/test_eslint_executable_detection.vader index c2071131..3fed63da 100644 --- a/test/test_eslint_executable_detection.vader +++ b/test/test_eslint_executable_detection.vader @@ -70,6 +70,25 @@ Execute(eslint.js executables should be run with node on Windows): \ ale#handlers#eslint#GetCommand(bufnr('')) endif +Execute(eslint.js should be run from containing project with eslint): + call ale#test#SetFilename('eslint-test-files/react-app/subdir-with-package-json/testfile.js') + + " We have to execute the file with node. + if has('win32') + AssertEqual + \ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app')) + \ . ale#Escape('node.exe') . ' ' + \ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' -f json --stdin --stdin-filename %s', + \ ale#handlers#eslint#GetCommand(bufnr('')) + else + AssertEqual + \ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app')) + \ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' -f json --stdin --stdin-filename %s', + \ ale#handlers#eslint#GetCommand(bufnr('')) + endif + Execute(eslint.js executables can be run outside project dir): " Set filename above eslint-test-files (which contains node_modules) call ale#test#SetFilename('testfile.js') |