summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/command_callback/fecs_paths/fecs0
-rwxr-xr-xtest/command_callback/fecs_paths/fecs.exe0
-rw-r--r--test/command_callback/test_cookstyle_command_callback.vader19
-rw-r--r--test/command_callback/test_fecs_command_callback.vader8
-rw-r--r--test/command_callback/test_gopls_command_callback.vader46
-rw-r--r--test/command_callback/test_rust_rls_callbacks.vader2
-rw-r--r--test/fixers/test_fecs_fixer_callback.vader26
-rw-r--r--test/handler/test_clojure_clj_kondo_handler.vader75
-rw-r--r--test/handler/test_cookstyle_handler.vader22
-rw-r--r--test/handler/test_fecs_handler.vader35
-rwxr-xr-xtest/handler/test_powershell_handler.vader62
11 files changed, 294 insertions, 1 deletions
diff --git a/test/command_callback/fecs_paths/fecs b/test/command_callback/fecs_paths/fecs
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/fecs_paths/fecs
diff --git a/test/command_callback/fecs_paths/fecs.exe b/test/command_callback/fecs_paths/fecs.exe
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/fecs_paths/fecs.exe
diff --git a/test/command_callback/test_cookstyle_command_callback.vader b/test/command_callback/test_cookstyle_command_callback.vader
new file mode 100644
index 00000000..ad7391cc
--- /dev/null
+++ b/test/command_callback/test_cookstyle_command_callback.vader
@@ -0,0 +1,19 @@
+Before:
+ call ale#assert#SetUpLinterTest('chef', 'cookstyle')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'cookstyle', ale#Escape('cookstyle') . ' --force-exclusion --format json --stdin %s'
+
+Execute(The executable path should be configurable):
+ let b:ale_chef_cookstyle_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --force-exclusion --format json --stdin %s'
+
+Execute(The linter options should be configurable):
+ let b:ale_chef_cookstyle_options = '--parallel'
+
+ AssertLinter 'cookstyle', ale#Escape('cookstyle') . ' --parallel --force-exclusion --format json --stdin %s'
+
diff --git a/test/command_callback/test_fecs_command_callback.vader b/test/command_callback/test_fecs_command_callback.vader
new file mode 100644
index 00000000..f70ad084
--- /dev/null
+++ b/test/command_callback/test_fecs_command_callback.vader
@@ -0,0 +1,8 @@
+Before:
+ call ale#assert#SetUpLinterTest('javascript', 'fecs')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'fecs', ale#Escape('fecs') . ' check --colors=false --rule=true %t'
diff --git a/test/command_callback/test_gopls_command_callback.vader b/test/command_callback/test_gopls_command_callback.vader
new file mode 100644
index 00000000..0e079a73
--- /dev/null
+++ b/test/command_callback/test_gopls_command_callback.vader
@@ -0,0 +1,46 @@
+Before:
+ call ale#assert#SetUpLinterTest('go', 'gopls')
+
+After:
+ Restore
+
+ if isdirectory(g:dir . '/.git')
+ call delete(g:dir . '/.git', 'd')
+ endif
+
+ unlet! b:ale_completion_enabled
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(should set correct defaults):
+ AssertLinter 'gopls', ale#Escape('gopls') . ' --mode stdio'
+
+Execute(should configure gopls callback executable):
+ let b:ale_go_gopls_executable = 'boo'
+ let b:ale_go_gopls_options = ''
+
+ AssertLinter 'boo', ale#Escape('boo')
+
+Execute(should set gopls options):
+ call ale#test#SetFilename('go_paths/go1/prj1/file.go')
+ " let b:ale_completion_enabled = 1
+ let b:ale_go_gopls_options = ''
+
+ AssertLinter 'gopls',
+ \ ale#Escape('gopls') . ''
+
+ let b:ale_go_gopls_options = '--mode stdio --trace'
+
+ AssertLinter 'gopls',
+ \ ale#Escape('gopls') . ' --mode stdio --trace'
+
+Execute(Should return directory for 'go.mod' if found in parent directory):
+ call ale#test#SetFilename('../go_files/test.go')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/../go_files')
+
+Execute(Should return nearest directory with '.git' if found in parent directory):
+ call ale#test#SetFilename('test.go')
+ call mkdir(g:dir . '/.git')
+
+ AssertLSPProject g:dir
diff --git a/test/command_callback/test_rust_rls_callbacks.vader b/test/command_callback/test_rust_rls_callbacks.vader
index ef4735d2..ec8c8811 100644
--- a/test/command_callback/test_rust_rls_callbacks.vader
+++ b/test/command_callback/test_rust_rls_callbacks.vader
@@ -5,7 +5,7 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default executable path should be correct):
- AssertLinter 'rls', ale#Escape('rls') . ' +' . ale#Escape('nightly')
+ AssertLinter 'rls', ale#Escape('rls')
Execute(The toolchain should be configurable):
let g:ale_rust_rls_toolchain = 'stable'
diff --git a/test/fixers/test_fecs_fixer_callback.vader b/test/fixers/test_fecs_fixer_callback.vader
new file mode 100644
index 00000000..809b4d46
--- /dev/null
+++ b/test/fixers/test_fecs_fixer_callback.vader
@@ -0,0 +1,26 @@
+Before:
+ call ale#assert#SetUpFixerTest('javascript', 'fecs')
+ runtime autoload/ale/handlers/fecs.vim
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The fecs fixer should respect to g:ale_javascript_fecs_executable):
+ let g:ale_javascript_fecs_executable = 'fecs_paths/fecs'
+ let g:ale_javascript_fecs_use_global = 1
+ silent cd ../command_callback
+ let g:dir = getcwd()
+
+ AssertEqual
+ \ {
+ \ 'command': ale#Escape(g:ale_javascript_fecs_executable) . ' format --replace=true %t',
+ \ 'read_temporary_file': 1,
+ \ },
+ \ ale#fixers#fecs#Fix(bufnr(''))
+
+Execute(The fecs fixer should return 0 when executable not found):
+ let g:ale_javascript_fecs_executable = 'fecs-invalid'
+ let g:ale_javascript_fecs_use_global = 1
+ AssertEqual
+ \ 0,
+ \ ale#fixers#fecs#Fix(bufnr(''))
diff --git a/test/handler/test_clojure_clj_kondo_handler.vader b/test/handler/test_clojure_clj_kondo_handler.vader
new file mode 100644
index 00000000..45db9049
--- /dev/null
+++ b/test/handler/test_clojure_clj_kondo_handler.vader
@@ -0,0 +1,75 @@
+Before:
+ runtime ale_linters/clojure/clj_kondo.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(the clojure clj-kondo handler should be able to handle errors):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 123,
+ \ 'col': 44,
+ \ 'type': 'E',
+ \ 'text': 'error: Unexpected )',
+ \ },
+ \ ],
+ \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [
+ \ 'test.clj:123:44: error: Unexpected )',
+ \ ])
+
+Execute(the clojure clj-kondo handler should be able to handle warnings):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 654,
+ \ 'col': 321,
+ \ 'type': 'W',
+ \ 'text': 'warning: inline def',
+ \ }
+ \ ],
+ \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [
+ \ 'test.clj:654:321: warning: inline def'
+ \ ])
+
+Execute(the clojure clj-kondo handler should be able to handle exceptions):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 123,
+ \ 'col': 321,
+ \ 'type': 'E',
+ \ 'text': 'Exception: something horrible happen',
+ \ }
+ \ ],
+ \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [
+ \ 'test.clj:123:321: Exception: something horrible happen'
+ \ ])
+
+Execute(the clojure clj-kondo handler should be able to handle errors from stdin):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 16,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': 'error: Unexpected )',
+ \ },
+ \ ],
+ \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [
+ \ '<stdin>:16:1: error: Unexpected )',
+ \ ])
+
+Execute(the clojure clj-kondo handler should be able to handle windows files):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 123,
+ \ 'col': 44,
+ \ 'type': 'E',
+ \ 'text': 'error: Unexpected )',
+ \ }
+ \ ],
+ \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [
+ \ 'C:\my\operating\system\is\silly\core.clj:123:44: error: Unexpected )',
+ \ ])
diff --git a/test/handler/test_cookstyle_handler.vader b/test/handler/test_cookstyle_handler.vader
new file mode 100644
index 00000000..7d705a19
--- /dev/null
+++ b/test/handler/test_cookstyle_handler.vader
@@ -0,0 +1,22 @@
+Before:
+ runtime ale_linters/chef/cookstyle.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(Basic warnings should be handled):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 58,
+ \ 'col': 24,
+ \ 'code': 'Style/UnneededInterpolation',
+ \ 'type': 'W',
+ \ 'end_col': 40,
+ \ 'text': 'Style/UnneededInterpolation: Prefer `to_s` over string interpolation.',
+ \ }
+ \ ],
+ \ ale_linters#chef#cookstyle#Handle(bufnr(''), [
+ \ '{"metadata":{"rubocop_version":"0.62.0","ruby_engine":"ruby","ruby_version":"2.6.0","ruby_patchlevel":"0","ruby_platform":"x86_64-linux"},"files":[{"path":"recipes/default.rb","offenses":[{"severity":"convention","message":"Style/UnneededInterpolation: Prefer `to_s` over string interpolation.","cop_name":"Style/UnneededInterpolation","corrected":false,"location":{"start_line":58,"start_column":24,"last_line":58,"last_column":40,"length":17,"line":58,"column":24}}]}],"summary":{"offense_count":1,"target_file_count":1,"inspected_file_count":1}}'
+ \ ])
+
diff --git a/test/handler/test_fecs_handler.vader b/test/handler/test_fecs_handler.vader
new file mode 100644
index 00000000..7c216b8d
--- /dev/null
+++ b/test/handler/test_fecs_handler.vader
@@ -0,0 +1,35 @@
+Before:
+ runtime autoload/ale/handlers/fecs.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(fecs should parse lines correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 20,
+ \ 'col': 25,
+ \ 'text': 'Unexpected console statement.',
+ \ 'code': 'no-console',
+ \ 'type': 'W',
+ \ },
+ \ {
+ \ 'lnum': 24,
+ \ 'col': 36,
+ \ 'text': 'Missing radix parameter.',
+ \ 'code': 'radix',
+ \ 'type': 'E',
+ \ },
+ \ {
+ \ 'lnum': 25,
+ \ 'col': 6,
+ \ 'text': 'Missing static property value.',
+ \ 'type': 'E',
+ \ },
+ \ ],
+ \ ale#handlers#fecs#Handle(347, [
+ \ 'fecs WARN → line 20, col 25: Unexpected console statement. (no-console)',
+ \ 'fecs ERROR → line 24, col 36: Missing radix parameter. (radix)',
+ \ 'fecs ERROR → line 25, col 6: Missing static property value.',
+ \ ])
diff --git a/test/handler/test_powershell_handler.vader b/test/handler/test_powershell_handler.vader
new file mode 100755
index 00000000..635bcd20
--- /dev/null
+++ b/test/handler/test_powershell_handler.vader
@@ -0,0 +1,62 @@
+Before:
+ runtime ale_linters/powershell/powershell.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The powershell handler should process syntax errors from parsing a powershell script):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 8,
+ \ 'col': 29,
+ \ 'type': 'E',
+ \ 'text': 'Missing closing ''}'' in statement block or type definition.',
+ \ 'code': 'ParseException',
+ \ },
+ \ ],
+ \ ale_linters#powershell#powershell#Handle(bufnr(''), [
+ \ "At line:8 char:29",
+ \ "+ Invoke-Command -ScriptBlock {",
+ \ "+ ~",
+ \ "Missing closing '}' in statement block or type definition.",
+ \ "At /home/harrisj/tester.ps1:5 char:5",
+ \ "+ [void]$ExecutionContext.InvokeCommand.NewScriptBlock($Contents);",
+ \ "+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
+ \ "+ CategoryInfo : NotSpecified: (:) [], ParseException",
+ \ "+ FullyQualifiedErrorId : ParseException"
+ \ ])
+
+Execute(The powershell handler should process multiple syntax errors from parsing a powershell script):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 11,
+ \ 'col': 31,
+ \ 'type': 'E',
+ \ 'text': 'The string is missing the terminator: ".',
+ \ 'code': 'ParseException'
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 16,
+ \ 'type': 'E',
+ \ 'text': 'Missing closing ''}'' in statement block or type definition.',
+ \ 'code': 'ParseException'
+ \ },
+ \ ],
+ \ ale_linters#powershell#powershell#Handle(bufnr(''), [
+ \ 'At line:11 char:31',
+ \ '+ write-verbose ''deleted''',
+ \ '+ ~',
+ \ 'The string is missing the terminator: ".',
+ \ 'At line:3 char:16',
+ \ '+ invoke-command {',
+ \ '+ ~',
+ \ 'Missing closing ''}'' in statement block or type definition.',
+ \ 'At /var/folders/qv/15ybvt050v9cgwrm7c95x4r4zc4qsg/T/vwhzIc8/1/script.ps1:1 char:150',
+ \ '+ ... ontents); [void]$ExecutionContext.InvokeCommand.NewScriptBlock($Con ...',
+ \ '+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
+ \ '+ CategoryInfo : NotSpecified: (:) [], ParseException',
+ \ '+ FullyQualifiedErrorId : ParseException'
+ \ ])