summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_cargo_command_callbacks.vader14
-rw-r--r--test/command_callback/test_glslang_command_callback.vader2
-rw-r--r--test/command_callback/test_glslls_command_callback.vader37
-rw-r--r--test/command_callback/test_gometalinter_command_callback.vader32
-rw-r--r--test/command_callback/test_perl_command_callback.vader37
-rw-r--r--test/fixers/test_eslint_fixer_callback.vader20
-rw-r--r--test/fixers/test_importjs_fixer_callback.vader35
-rw-r--r--test/fixers/test_phpcbf_fixer_callback.vader8
-rw-r--r--test/handler/test_gometalinter_handler.vader12
-rw-r--r--test/handler/test_prospector_handler.vader158
-rw-r--r--test/handler/test_puppet_handler.vader45
-rw-r--r--test/handler/test_solhint_handler.vader60
-rw-r--r--test/javascript_files/test.js0
-rwxr-xr-xtest/script/custom-checks137
-rwxr-xr-xtest/script/custom-linting-rules95
-rwxr-xr-xtest/script/run-vader-tests123
-rwxr-xr-xtest/script/run-vint18
-rw-r--r--test/test_ale_info.vader29
-rw-r--r--test/test_ale_toggle.vader4
19 files changed, 757 insertions, 109 deletions
diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader
index 10535516..65ea5a80 100644
--- a/test/command_callback/test_cargo_command_callbacks.vader
+++ b/test/command_callback/test_cargo_command_callbacks.vader
@@ -85,32 +85,32 @@ Execute(`cargo build` should be used when g:ale_rust_cargo_use_check is set to 0
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
-Execute(`cargo check --all-targets` should be used when the version is new enough):
+Execute(`cargo check` should be used when the version is new enough):
AssertEqual
- \ 'cargo check --all-targets' . g:suffix,
+ \ 'cargo check' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check
AssertEqual
- \ 'cargo check --all-targets' . g:suffix,
+ \ 'cargo check' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
-Execute(--all-targets should not be used when g:ale_rust_cargo_check_all_targets is set to 0):
- let g:ale_rust_cargo_check_all_targets = 0
+Execute(--all-targets should be used when g:ale_rust_cargo_check_all_targets is set to 1):
+ let g:ale_rust_cargo_check_all_targets = 1
AssertEqual
- \ 'cargo check' . g:suffix,
+ \ 'cargo check --all-targets' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [
\ 'cargo 0.22.0 (3423351a5 2017-10-06)',
\ ])
" We should cache the version check
AssertEqual
- \ 'cargo check' . g:suffix,
+ \ 'cargo check --all-targets' . g:suffix,
\ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
diff --git a/test/command_callback/test_glslang_command_callback.vader b/test/command_callback/test_glslang_command_callback.vader
index 9d406834..1b1722a4 100644
--- a/test/command_callback/test_glslang_command_callback.vader
+++ b/test/command_callback/test_glslang_command_callback.vader
@@ -10,8 +10,6 @@ Before:
After:
Restore
- unlet! g:ale_cuda_nvcc_executable
- unlet! g:ale_cuda_nvcc_options
call ale#linter#Reset()
Execute(Executable should default to glslangValidator):
diff --git a/test/command_callback/test_glslls_command_callback.vader b/test/command_callback/test_glslls_command_callback.vader
new file mode 100644
index 00000000..e64c2352
--- /dev/null
+++ b/test/command_callback/test_glslls_command_callback.vader
@@ -0,0 +1,37 @@
+Before:
+ Save g:ale_glsl_glslls_executable
+ Save g:ale_glsl_glslls_logfile
+
+ unlet! g:ale_glsl_glslls_executable
+ unlet! g:ale_glsl_glslls_logfile
+
+ runtime ale_linters/glsl/glslls.vim
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+
+After:
+ Restore
+ call ale#linter#Reset()
+
+Execute(Executable should default to 'glslls'):
+ AssertEqual
+ \ 'glslls',
+ \ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
+
+Execute(Executable should be configurable):
+ let g:ale_glsl_glslls_executable = 'foobar'
+ AssertEqual
+ \ 'foobar',
+ \ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
+
+Execute(Command should use executable):
+ let command1 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
+ AssertEqual command1, ale#Escape('glslls') . ' --stdin'
+
+ let g:ale_glsl_glslls_executable = 'foobar'
+ let command2 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
+ AssertEqual command2, ale#Escape('foobar') . ' --stdin'
+
+Execute(Setting logfile should work):
+ let g:ale_glsl_glslls_logfile = '/tmp/test.log'
+ let command = ale_linters#glsl#glslls#GetCommand(bufnr(''))
+ AssertEqual command, ale#Escape('glslls') . ' --verbose -l /tmp/test.log --stdin'
diff --git a/test/command_callback/test_gometalinter_command_callback.vader b/test/command_callback/test_gometalinter_command_callback.vader
index 912396cb..93a541c8 100644
--- a/test/command_callback/test_gometalinter_command_callback.vader
+++ b/test/command_callback/test_gometalinter_command_callback.vader
@@ -1,9 +1,11 @@
Before:
Save b:ale_go_gometalinter_executable
Save b:ale_go_gometalinter_options
+ Save b:ale_go_gometalinter_lint_package
let b:ale_go_gometalinter_executable = 'gometalinter'
let b:ale_go_gometalinter_options = ''
+ let b:ale_go_gometalinter_lint_package = 0
runtime ale_linters/go/gometalinter.vim
@@ -21,9 +23,10 @@ Execute(The gometalinter callback should return the right defaults):
\ 'gometalinter',
\ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
AssertEqual
- \ ale#Escape('gometalinter')
- \ . ' --include=' . ale#Escape('^' . ale#util#EscapePCRE(expand('%')))
- \ . ' ' . ale#Escape(getcwd()),
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('gometalinter')
+ \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
+ \ . ' .',
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))
Execute(The gometalinter callback should use a configured executable):
@@ -33,17 +36,26 @@ Execute(The gometalinter callback should use a configured executable):
\ 'something else',
\ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
AssertEqual
- \ ale#Escape('something else')
- \ . ' --include=' . ale#Escape('^' . ale#util#EscapePCRE(expand('%')))
- \ . ' ' . ale#Escape(getcwd()),
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('something else')
+ \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
+ \ . ' .',
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))
Execute(The gometalinter callback should use configured options):
let b:ale_go_gometalinter_options = '--foobar'
AssertEqual
- \ ale#Escape('gometalinter')
- \ . ' --include=' . ale#Escape('^' . ale#util#EscapePCRE(expand('%')))
- \ . ' --foobar'
- \ . ' ' . ale#Escape(getcwd()),
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('gometalinter')
+ \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
+ \ . ' --foobar' . ' .',
+ \ ale_linters#go#gometalinter#GetCommand(bufnr(''))
+
+Execute(The gometalinter `lint_package` option should use the correct command):
+ let b:ale_go_gometalinter_lint_package = 1
+
+ AssertEqual
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('gometalinter') . ' .',
\ ale_linters#go#gometalinter#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_perl_command_callback.vader b/test/command_callback/test_perl_command_callback.vader
new file mode 100644
index 00000000..ba85e53b
--- /dev/null
+++ b/test/command_callback/test_perl_command_callback.vader
@@ -0,0 +1,37 @@
+Before:
+ Save g:ale_perl_perl_executable
+ Save g:ale_perl_perl_options
+
+ unlet! g:ale_perl_perl_executable
+ unlet! g:ale_perl_perl_options
+
+ runtime ale_linters/perl/perl.vim
+
+After:
+ Restore
+
+ unlet! b:ale_perl_perl_executable
+ unlet! b:ale_perl_perl_options
+
+ call ale#linter#Reset()
+
+Execute(The default Perl command callback should be correct):
+ AssertEqual
+ \ 'perl',
+ \ ale_linters#perl#perl#GetExecutable(bufnr(''))
+
+ AssertEqual
+ \ ale#Escape('perl') . ' -c -Mwarnings -Ilib %t',
+ \ ale_linters#perl#perl#GetCommand(bufnr(''))
+
+Execute(Overriding the executable and command should work):
+ let b:ale_perl_perl_executable = 'foobar'
+ let b:ale_perl_perl_options = '-w'
+
+ AssertEqual
+ \ 'foobar',
+ \ ale_linters#perl#perl#GetExecutable(bufnr(''))
+
+ AssertEqual
+ \ ale#Escape('foobar') . ' -w %t',
+ \ ale_linters#perl#perl#GetCommand(bufnr(''))
diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader
index afb267a2..aafc4e71 100644
--- a/test/fixers/test_eslint_fixer_callback.vader
+++ b/test/fixers/test_eslint_fixer_callback.vader
@@ -101,6 +101,7 @@ Execute(--fix-to-stdout should be used for eslint_d):
\ 'command':
\ ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
+ \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ },
\ ale#fixers#eslint#ApplyFixForVersion(bufnr(''), ['v3.19.0 (eslint_d v4.2.0)'])
@@ -110,6 +111,7 @@ Execute(--fix-to-stdout should be used for eslint_d):
\ 'command':
\ ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
+ \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ },
\ ale#fixers#eslint#ApplyFixForVersion(bufnr(''), ['4.9.0'])
@@ -150,3 +152,21 @@ Execute(The --fix-dry-run post-processor should handle JSON output correctly):
AssertEqual
\ ['foo', 'bar'],
\ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{"output": "foo\nbar"}]'])
+
+Execute(The eslint_d post-processor should permit regular JavaScript content):
+ AssertEqual
+ \ [
+ \ 'const x = ''Error: foo''',
+ \ 'const y = 3',
+ \ ],
+ \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
+ \ 'const x = ''Error: foo''',
+ \ 'const y = 3',
+ \ ])
+
+Execute(The eslint_d post-processor should handle error messages correctly):
+ AssertEqual
+ \ [],
+ \ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
+ \ 'Error: No ESLint configuration found.',
+ \ ])
diff --git a/test/fixers/test_importjs_fixer_callback.vader b/test/fixers/test_importjs_fixer_callback.vader
new file mode 100644
index 00000000..c3e57f8b
--- /dev/null
+++ b/test/fixers/test_importjs_fixer_callback.vader
@@ -0,0 +1,35 @@
+Before:
+ Save g:ale_js_importjs_executable
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_js_importjs_executable = 'xxxinvalid'
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ call ale#test#SetFilename('../javascript_files/test.js')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The importjs callback should return 0 when the executable isn't executable):
+ AssertEqual
+ \ 0,
+ \ ale#fixers#importjs#Fix(bufnr(''))
+
+Execute(The importjs callback should run the command when the executable test passes):
+ let g:ale_js_importjs_executable = has('win32') ? 'cmd' : 'echo'
+
+ AssertEqual
+ \ {
+ \ 'process_with': 'ale#fixers#importjs#ProcessOutput',
+ \ 'command': ale#Escape(g:ale_js_importjs_executable) . ' fix %s'
+ \ },
+ \ ale#fixers#importjs#Fix(bufnr(''))
+
+Execute(The ProcessOutput callback should return the expected output):
+ let g:testOutput = '{"messages":[],"fileContent":"one\ntwo","unresolvedImports":{}}'
+
+ AssertEqual
+ \ ['one', 'two'],
+ \ ale#fixers#importjs#ProcessOutput(bufnr(''), g:testOutput)
diff --git a/test/fixers/test_phpcbf_fixer_callback.vader b/test/fixers/test_phpcbf_fixer_callback.vader
index cf02a0b5..b5c72f21 100644
--- a/test/fixers/test_phpcbf_fixer_callback.vader
+++ b/test/fixers/test_phpcbf_fixer_callback.vader
@@ -43,7 +43,7 @@ Execute(The phpcbf callback should return the correct default values):
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
AssertEqual
- \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' },
+ \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s -' },
\ ale#fixers#phpcbf#Fix(bufnr(''))
Execute(The phpcbf callback should include the phpcbf_standard option):
@@ -51,7 +51,7 @@ Execute(The phpcbf callback should include the phpcbf_standard option):
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
AssertEqual
- \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'},
+ \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml' . ' -'},
\ ale#fixers#phpcbf#Fix(bufnr(''))
Before:
@@ -99,7 +99,7 @@ Execute(The phpcbf callback should return the correct default values):
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
AssertEqual
- \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' },
+ \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s -' },
\ ale#fixers#phpcbf#Fix(bufnr(''))
Execute(The phpcbf callback should include the phpcbf_standard option):
@@ -107,6 +107,6 @@ Execute(The phpcbf callback should include the phpcbf_standard option):
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
AssertEqual
- \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'},
+ \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml' . ' -'},
\ ale#fixers#phpcbf#Fix(bufnr(''))
diff --git a/test/handler/test_gometalinter_handler.vader b/test/handler/test_gometalinter_handler.vader
index 603ba22d..703040e2 100644
--- a/test/handler/test_gometalinter_handler.vader
+++ b/test/handler/test_gometalinter_handler.vader
@@ -29,8 +29,10 @@ Execute (The gometalinter handler should handle names with spaces):
\ 'C:\something\file with spaces.go:37:5:error: expected ''package'', found ''IDENT'' gibberish (golint)',
\ ]), 'v:val[1:5]')
-Execute (The gometalinter handler should handle relative paths correctly):
- silent file /foo/bar/baz.go
+Execute (The gometalinter handler should handle paths correctly):
+ call ale#test#SetFilename('app/test.go')
+
+ let file = ale#path#GetAbsPath(expand('%:p:h'), 'test.go')
AssertEqual
\ [
@@ -39,15 +41,17 @@ Execute (The gometalinter handler should handle relative paths correctly):
\ 'col': 3,
\ 'text': 'expected ''package'', found ''IDENT'' gibberish (staticcheck)',
\ 'type': 'W',
+ \ 'filename': ale#path#Winify(expand('%:p:h') . '/test.go'),
\ },
\ {
\ 'lnum': 37,
\ 'col': 5,
\ 'text': 'expected ''package'', found ''IDENT'' gibberish (golint)',
\ 'type': 'E',
+ \ 'filename': ale#path#Winify(expand('%:p:h') . '/test.go'),
\ },
\ ],
\ ale_linters#go#gometalinter#Handler(bufnr(''), [
- \ 'baz.go:12:3:warning: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
- \ 'baz.go:37:5:error: expected ''package'', found ''IDENT'' gibberish (golint)',
+ \ file . ':12:3:warning: expected ''package'', found ''IDENT'' gibberish (staticcheck)',
+ \ file . ':37:5:error: expected ''package'', found ''IDENT'' gibberish (golint)',
\ ])
diff --git a/test/handler/test_prospector_handler.vader b/test/handler/test_prospector_handler.vader
new file mode 100644
index 00000000..7962f6cd
--- /dev/null
+++ b/test/handler/test_prospector_handler.vader
@@ -0,0 +1,158 @@
+Before:
+ Save g:ale_warn_about_trailing_whitespace
+
+ let g:ale_warn_about_trailing_whitespace = 1
+
+ runtime ale_linters/python/prospector.vim
+
+After:
+ Restore
+
+ call ale#linter#Reset()
+
+ silent file something_else.py
+
+Execute(Basic prospector errors should be handle):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 20,
+ \ 'col': 1,
+ \ 'text': 'Trailing whitespace',
+ \ 'code': '(pylint) trailing-whitespace',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'text': 'Missing module docstring',
+ \ 'code': '(pylint) missing-docstring',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'text': 'Missing function docstring',
+ \ 'code': '(pylint) missing-docstring',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 5,
+ \ 'text': '''break'' not properly in loop',
+ \ 'code': '(pylint) not-in-loop',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 4,
+ \ 'col': 5,
+ \ 'text': 'Unreachable code',
+ \ 'code': '(pylint) unreachable',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 7,
+ \ 'col': 33,
+ \ 'text': 'No exception type(s) specified',
+ \ 'code': '(pylint) bare-except',
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale_linters#python#prospector#Handle(bufnr(''), [
+ \ '{',
+ \ ' "messages": [',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "trailing-whitespace",',
+ \ ' "message": "Trailing whitespace",',
+ \ ' "location": {',
+ \ ' "character": 0,',
+ \ ' "line": 20',
+ \ ' }',
+ \ ' },',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "missing-docstring",',
+ \ ' "message": "Missing module docstring",',
+ \ ' "location": {',
+ \ ' "character": 0,',
+ \ ' "line": 1',
+ \ ' }',
+ \ ' },',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "missing-docstring",',
+ \ ' "message": "Missing function docstring",',
+ \ ' "location": {',
+ \ ' "character": 0,',
+ \ ' "line": 2',
+ \ ' }',
+ \ ' },',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "not-in-loop",',
+ \ ' "message": "''break'' not properly in loop",',
+ \ ' "location": {',
+ \ ' "character": 4,',
+ \ ' "line": 3',
+ \ ' }',
+ \ ' },',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "unreachable",',
+ \ ' "message": "Unreachable code",',
+ \ ' "location": {',
+ \ ' "character": 4,',
+ \ ' "line": 4',
+ \ ' }',
+ \ ' },',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "bare-except",',
+ \ ' "message": "No exception type(s) specified",',
+ \ ' "location": {',
+ \ ' "character": 32,',
+ \ ' "line": 7',
+ \ ' }',
+ \ ' }',
+ \ ' ]',
+ \ '}',
+ \ ])
+
+Execute(Ignoring trailing whitespace messages should work):
+ let g:ale_warn_about_trailing_whitespace = 0
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'text': 'Missing module docstring',
+ \ 'code': '(pylint) missing-docstring',
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale_linters#python#prospector#Handle(bufnr(''), [
+ \ '{',
+ \ ' "messages": [',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "trailing-whitespace",',
+ \ ' "message": "Trailing whitespace",',
+ \ ' "location": {',
+ \ ' "character": 0,',
+ \ ' "line": 4',
+ \ ' }',
+ \ ' },',
+ \ ' {',
+ \ ' "source": "pylint",',
+ \ ' "code": "missing-docstring",',
+ \ ' "message": "Missing module docstring",',
+ \ ' "location": {',
+ \ ' "character": 0,',
+ \ ' "line": 1',
+ \ ' }',
+ \ ' }',
+ \ ' ]',
+ \ '}',
+ \ ])
diff --git a/test/handler/test_puppet_handler.vader b/test/handler/test_puppet_handler.vader
new file mode 100644
index 00000000..0d274fd2
--- /dev/null
+++ b/test/handler/test_puppet_handler.vader
@@ -0,0 +1,45 @@
+Before:
+ runtime ale_linters/puppet/puppet.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The puppet handler should parse lines correctly when no column is supplied):
+ " Line Error
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 5,
+ \ 'col': 0,
+ \ 'text': "Syntax error at '='; expected '}'"
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 0,
+ \ 'text': "Syntax error at '='; expected '}'"
+ \ },
+ \ ],
+ \ ale_linters#puppet#puppet#Handle(255, [
+ \ "Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5",
+ \ "Error: Could not parse for environment production: Syntax error at '='; expected '}' at C:/puppet/modules/pancakes/manifests/init.pp:3",
+ \ ])
+
+Execute(The puppet handler should parse lines and column correctly):
+ " Line Error
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 43,
+ \ 'col': 12,
+ \ 'text': "Syntax error at ':'"
+ \ },
+ \ {
+ \ 'lnum': 54,
+ \ 'col': 9,
+ \ 'text': "Syntax error at ':'"
+ \ }
+ \ ],
+ \ ale_linters#puppet#puppet#Handle(255, [
+ \ "Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12",
+ \ "Error: Could not parse for environment production: Syntax error at ':' at C:/puppet/modules/nginx/manifests/init.pp:54:9",
+ \ ])
diff --git a/test/handler/test_solhint_handler.vader b/test/handler/test_solhint_handler.vader
new file mode 100644
index 00000000..a3ed5d57
--- /dev/null
+++ b/test/handler/test_solhint_handler.vader
@@ -0,0 +1,60 @@
+Before:
+ runtime ale_linters/solidity/solhint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The vint handler should parse error messages correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 17,
+ \ 'text': 'Compiler version must be fixed',
+ \ 'code': 'compiler-fixed',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 4,
+ \ 'col': 8,
+ \ 'text': 'Use double quotes for string literals',
+ \ 'code': 'quotes',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 5,
+ \ 'col': 8,
+ \ 'text': 'Use double quotes for string literals',
+ \ 'code': 'quotes',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 13,
+ \ 'col': 3,
+ \ 'text': 'Expected indentation of 4 spaces but found 2',
+ \ 'code': 'indent',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 14,
+ \ 'col': 3,
+ \ 'text': 'Expected indentation of 4 spaces but found 2',
+ \ 'code': 'indent',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 47,
+ \ 'col': 3,
+ \ 'text': 'Function order is incorrect, public function can not go after internal function.',
+ \ 'code': 'func-order',
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale_linters#solidity#solhint#Handle(bufnr(''), [
+ \ 'contracts/Bounty.sol: line 1, col 17, Warning - Compiler version must be fixed (compiler-fixed)',
+ \ 'contracts/Bounty.sol: line 4, col 8, Error - Use double quotes for string literals (quotes)',
+ \ 'contracts/Bounty.sol: line 5, col 8, Error - Use double quotes for string literals (quotes)',
+ \ 'contracts/Bounty.sol: line 13, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
+ \ 'contracts/Bounty.sol: line 14, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
+ \ 'contracts/Bounty.sol: line 47, col 3, Error - Function order is incorrect, public function can not go after internal function. (func-order)',
+ \ ])
diff --git a/test/javascript_files/test.js b/test/javascript_files/test.js
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/javascript_files/test.js
diff --git a/test/script/custom-checks b/test/script/custom-checks
index e2c906b3..791053d4 100755
--- a/test/script/custom-checks
+++ b/test/script/custom-checks
@@ -1,95 +1,68 @@
#!/bin/bash -eu
-# This Bash script implements custom sanity checks for scripts beyond what
-# Vint covers, which are easy to check with regex.
+exit_code=0
+image=w0rp/ale
+docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
-# A flag for automatically fixing some errors.
-FIX_ERRORS=0
-RETURN_CODE=0
+echo '========================================'
+echo 'Running custom linting rules'
+echo '========================================'
+echo 'Custom warnings/errors follow:'
+echo
-function print_help() {
- echo "Usage: ./custom-checks [--fix] [DIRECTORY]" 1>&2
- echo 1>&2
- echo " -h, --help Print this help text" 1>&2
- echo " --fix Automatically fix some errors" 1>&2
- exit 1
-}
+set -o pipefail
+docker run -a stdout "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
+set +o pipefail
+echo
-while [ $# -ne 0 ]; do
- case $1 in
- -h) ;& --help)
- print_help
- ;;
- --fix)
- FIX_ERRORS=1
- shift
- ;;
- --)
- shift
- break
- ;;
- -?*)
- echo "Invalid argument: $1" 1>&2
- exit 1
- ;;
- *)
- break
- ;;
- esac
-done
+echo '========================================'
+echo 'Checking for duplicate tags'
+echo '========================================'
+echo 'Duplicate tags follow:'
+echo
-if [ $# -eq 0 ] || [ -z "$1" ]; then
- print_help
-fi
+grep --exclude=tags -roh '\*.*\*$' doc | sort | uniq -d || exit_code=$?
-shopt -s globstar
+echo '========================================'
+echo 'Checking for invalid tag references'
+echo '========================================'
+echo 'Invalid tag references tags follow:'
+echo
-directories=("$@")
+tag_regex='[gb]\?:\?\(ale\|ALE\)[a-zA-Z_\-]\+'
-check_errors() {
- regex="$1"
- message="$2"
+# Grep for tags and references, and complain if we find a reference without
+# a tag for the reference. Only our tags will be included.
+diff -u \
+ <(grep --exclude=tags -roh "\*$tag_regex\*" doc | sort -u | sed 's/*//g') \
+ <(grep --exclude=tags -roh "|$tag_regex|" doc | sort -u | sed 's/|//g') \
+ | grep '^+[^+]' && exit_code=1
- for directory in "${directories[@]}"; do
- while IFS= read -r match; do
- RETURN_CODE=1
- echo "$match $message"
- done < <(grep -n "$regex" "$directory"/**/*.vim \
- | grep -v 'no-custom-checks' \
- | grep -o '^[^:]\+:[0-9]\+' \
- | sed 's:^\./::')
- done
-}
+echo '========================================'
+echo 'diff README.md and doc/ale.txt tables'
+echo '========================================'
+echo 'Differences follow:'
+echo
-if (( FIX_ERRORS )); then
- for directory in "${directories[@]}"; do
- sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
- sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim
- sed -i 's/==#/is#/g' "$directory"/**/*.vim
- sed -i 's/==?/is?/g' "$directory"/**/*.vim
- sed -i 's/!=#/isnot#/g' "$directory"/**/*.vim
- sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim
- done
-fi
+test/script/check-supported-tools-tables || exit_code=$?
-check_errors \
- '^function.*) *$' \
- 'Function without abort keyword (See :help except-compat)'
-check_errors '^function[^!]' 'function without !'
-check_errors ' \+$' 'Trailing whitespace'
-check_errors '^ * end\?i\? *$' 'Write endif, not en, end, or endi'
-check_errors '^ [^ ]' 'Use four spaces, not two spaces'
-check_errors $'\t' 'Use four spaces, not tabs'
-# This check should prevent people from using a particular inconsistent name.
-check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<lintername>_options instead'
-check_errors 'shellescape(' 'Use ale#Escape instead of shellescape'
-check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify'
-check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer."
-check_errors 'getcwd()' "Do not use getcwd(), as it could run from the wrong buffer. Use expand('#' . a:buffer . ':p:h') instead."
-check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"
-check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
-check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
-check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
-check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
+echo '========================================'
+echo 'Look for badly aligned doc tags'
+echo '========================================'
+echo 'Badly aligned tags follow:'
+echo
-exit $RETURN_CODE
+# Documentation tags need to be aligned to the right margin, so look for
+# tags which aren't at the right margin.
+grep ' \*[^*]\+\*$' doc/ -r \
+ | awk '{ sep = index($0, ":"); if (length(substr($0, sep + 1 )) < 79) { print } }' \
+ | grep . && exit_code=1
+
+echo '========================================'
+echo 'Look for table of contents issues'
+echo '========================================'
+echo
+
+test/script/check-toc || exit_code=$?
+
+exit $exit_code
diff --git a/test/script/custom-linting-rules b/test/script/custom-linting-rules
new file mode 100755
index 00000000..ef6d792f
--- /dev/null
+++ b/test/script/custom-linting-rules
@@ -0,0 +1,95 @@
+#!/bin/bash -eu
+
+# This Bash script implements custom sanity checks for scripts beyond what
+# Vint covers, which are easy to check with regex.
+
+# A flag for automatically fixing some errors.
+FIX_ERRORS=0
+RETURN_CODE=0
+
+function print_help() {
+ echo "Usage: test/script/custom-linting-rules [--fix] [DIRECTORY]" 1>&2
+ echo 1>&2
+ echo " -h, --help Print this help text" 1>&2
+ echo " --fix Automatically fix some errors" 1>&2
+ exit 1
+}
+
+while [ $# -ne 0 ]; do
+ case $1 in
+ -h) ;& --help)
+ print_help
+ ;;
+ --fix)
+ FIX_ERRORS=1
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -?*)
+ echo "Invalid argument: $1" 1>&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+if [ $# -eq 0 ] || [ -z "$1" ]; then
+ print_help
+fi
+
+shopt -s globstar
+
+directories=("$@")
+
+check_errors() {
+ regex="$1"
+ message="$2"
+
+ for directory in "${directories[@]}"; do
+ while IFS= read -r match; do
+ RETURN_CODE=1
+ echo "$match $message"
+ done < <(grep -n "$regex" "$directory"/**/*.vim \
+ | grep -v 'no-custom-checks' \
+ | grep -o '^[^:]\+:[0-9]\+' \
+ | sed 's:^\./::')
+ done
+}
+
+if (( FIX_ERRORS )); then
+ for directory in "${directories[@]}"; do
+ sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
+ sed -i "s/shellescape(/ale#Escape(/" "$directory"/**/*.vim
+ sed -i 's/==#/is#/g' "$directory"/**/*.vim
+ sed -i 's/==?/is?/g' "$directory"/**/*.vim
+ sed -i 's/!=#/isnot#/g' "$directory"/**/*.vim
+ sed -i 's/!=?/isnot?/g' "$directory"/**/*.vim
+ done
+fi
+
+check_errors \
+ '^function.*) *$' \
+ 'Function without abort keyword (See :help except-compat)'
+check_errors '^function[^!]' 'function without !'
+check_errors ' \+$' 'Trailing whitespace'
+check_errors '^ * end\?i\? *$' 'Write endif, not en, end, or endi'
+check_errors '^ [^ ]' 'Use four spaces, not two spaces'
+check_errors $'\t' 'Use four spaces, not tabs'
+# This check should prevent people from using a particular inconsistent name.
+check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<lintername>_options instead'
+check_errors 'shellescape(' 'Use ale#Escape instead of shellescape'
+check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify'
+check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer."
+check_errors 'getcwd()' "Do not use getcwd(), as it could run from the wrong buffer. Use expand('#' . a:buffer . ':p:h') instead."
+check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"
+check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
+check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
+check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
+check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
+
+exit $RETURN_CODE
diff --git a/test/script/run-vader-tests b/test/script/run-vader-tests
new file mode 100755
index 00000000..d5daec29
--- /dev/null
+++ b/test/script/run-vader-tests
@@ -0,0 +1,123 @@
+#!/bin/bash -eu
+
+image=w0rp/ale
+docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
+red='\033[0;31m'
+green='\033[0;32m'
+nc='\033[0m'
+verbose=0
+quiet=0
+exit_code=0
+
+while [ $# -ne 0 ]; do
+ case $1 in
+ -v)
+ verbose=1
+ shift
+ ;;
+ -q)
+ quiet=1
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -?*)
+ echo "Invalid argument: $1" 1>&2
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+vim="$1"
+tests="$2"
+
+function filter-vader-output() {
+ # When verbose mode is off, suppress output until Vader starts.
+ local start_output="$verbose"
+ local filtered_data=''
+
+ while read -r; do
+ if ((!start_output)); then
+ if [[ "$REPLY" = *'Starting Vader:'* ]]; then
+ start_output=1
+ else
+ continue
+ fi
+ fi
+
+ if ((quiet)); then
+ if [[ "$REPLY" = *'Starting Vader:'* ]]; then
+ filtered_data="$REPLY"
+ elif [[ "$REPLY" = *'Success/Total'* ]]; then
+ success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
+ total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
+
+ if [ "$success" -lt "$total" ]; then
+ echo "$filtered_data"
+ echo "$REPLY"
+ fi
+
+ filtered_data=''
+ else
+ filtered_data="$filtered_data"$'\n'"$REPLY"
+ fi
+ else
+ echo "$REPLY"
+ fi
+ done
+}
+
+function color-vader-output() {
+ while read -r; do
+ if [[ "$REPLY" = *'[EXECUTE] (X)'* ]]; then
+ echo -en "$red"
+ elif [[ "$REPLY" = *'[EXECUTE]'* ]] || [[ "$REPLY" = *'[ GIVEN]'* ]]; then
+ echo -en "$nc"
+ fi
+
+ if [[ "$REPLY" = *'Success/Total'* ]]; then
+ success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
+ total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
+
+ if [ "$success" -lt "$total" ]; then
+ echo -en "$red"
+ else
+ echo -en "$green"
+ fi
+
+ echo "$REPLY"
+ echo -en "$nc"
+ else
+ echo "$REPLY"
+ fi
+ done
+
+ echo -en "$nc"
+}
+
+echo
+echo '========================================'
+echo "Running tests for $vim"
+echo '========================================'
+echo
+
+if [[ $vim =~ ^neovim ]]; then
+ set -o pipefail
+ docker run -it -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
+ "/vim-build/bin/$vim" -u test/vimrc \
+ --headless "+Vader! $tests" | filter-vader-output | color-vader-output || exit_code=$?
+ set +o pipefail
+else
+ set -o pipefail
+ docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
+ "/vim-build/bin/$vim" -u test/vimrc \
+ "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$?
+ set +o pipefail
+fi
+
+exit "$exit_code"
diff --git a/test/script/run-vint b/test/script/run-vint
new file mode 100755
index 00000000..e1140307
--- /dev/null
+++ b/test/script/run-vint
@@ -0,0 +1,18 @@
+#!/bin/bash -eu
+
+exit_code=0
+image=w0rp/ale
+docker_flags=(--rm -v "$PWD:/testplugin" -v "$PWD/test:/home" -w /testplugin "$image")
+
+echo '========================================'
+echo 'Running Vint to lint our code'
+echo '========================================'
+echo 'Vint warnings/errors follow:'
+echo
+
+set -o pipefail
+docker run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
+set +o pipefail
+echo
+
+exit $exit_code
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 30237a3c..2ca18341 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -2,9 +2,13 @@ Before:
Save g:ale_warn_about_trailing_whitespace
Save g:ale_linters
Save g:ale_fixers
+ Save g:ale_lint_on_text_changed
+ Save g:ale_cache_executable_check_failures
unlet! b:ale_history
+ let g:ale_lint_on_text_changed = 'always'
+ let g:ale_cache_executable_check_failures = 0
let g:ale_warn_about_trailing_whitespace = 1
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout'}
@@ -355,6 +359,31 @@ Execute (ALEInfo command history should print command output if logging is on):
Execute (ALEInfo should include executable checks in the history):
call ale#linter#Define('testft', g:testlinter1)
call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
+ call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
+ call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
+ call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
+
+ call CheckInfo([
+ \ ' Current Filetype: testft.testft2',
+ \ 'Available Linters: [''testlinter1'']',
+ \ ' Enabled Linters: [''testlinter1'']',
+ \ ' Linter Variables:',
+ \ '',
+ \] + g:globals_lines + g:command_header + [
+ \ '',
+ \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
+ \ '(executable check - failure) TheresNoWayThisIsExecutable',
+ \ '(executable check - failure) TheresNoWayThisIsExecutable',
+ \])
+
+Execute (The option for caching failing executable checks should work):
+ let g:ale_cache_executable_check_failures = 1
+
+ call ale#linter#Define('testft', g:testlinter1)
+
+ call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
+ call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
+ call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call CheckInfo([
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index a57546fc..d56f8c2b 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -3,10 +3,14 @@ Before:
Save g:ale_set_signs
Save g:ale_set_lists_synchronously
Save g:ale_run_synchronously
+ Save g:ale_pattern_options
+ Save g:ale_pattern_options_enabled
let g:ale_set_signs = 1
let g:ale_set_lists_synchronously = 1
let g:ale_run_synchronously = 1
+ let g:ale_pattern_options = {}
+ let g:ale_pattern_options_enabled = 1
unlet! b:ale_enabled