summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/spectral_paths/node_modules/.bin/spectral0
-rw-r--r--test/command_callback/spectral_paths/openapi.yaml0
-rw-r--r--test/command_callback/test_adals_command_callbacks.vader17
-rw-r--r--test/command_callback/test_clang_tidy_command_callback.vader1
-rw-r--r--test/command_callback/test_dart_analysis_server_command_callback.vader15
-rw-r--r--test/command_callback/test_spectral_command_callback.vader31
-rw-r--r--test/command_callback/test_typescript_deno_lsp.vader60
-rw-r--r--test/fixers/test_standardrb_fixer_callback.vader12
-rw-r--r--test/handler/test_atools_handler.vader85
-rw-r--r--test/handler/test_spectral_handler.vader52
-rw-r--r--test/test_deno_executable_detection.vader19
-rw-r--r--test/test_filetype_linter_defaults.vader7
-rw-r--r--test/typescript/test.ts0
-rw-r--r--test/typescript/tsconfig.json0
14 files changed, 292 insertions, 7 deletions
diff --git a/test/command_callback/spectral_paths/node_modules/.bin/spectral b/test/command_callback/spectral_paths/node_modules/.bin/spectral
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/spectral_paths/node_modules/.bin/spectral
diff --git a/test/command_callback/spectral_paths/openapi.yaml b/test/command_callback/spectral_paths/openapi.yaml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/spectral_paths/openapi.yaml
diff --git a/test/command_callback/test_adals_command_callbacks.vader b/test/command_callback/test_adals_command_callbacks.vader
new file mode 100644
index 00000000..5a04594e
--- /dev/null
+++ b/test/command_callback/test_adals_command_callbacks.vader
@@ -0,0 +1,17 @@
+Before:
+ call ale#assert#SetUpLinterTest('ada', 'adals')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Sets adals executable):
+ let g:ale_ada_adals_executable = '/path/to /Ada'
+ AssertLinter '/path/to /Ada', ale#Escape('/path/to /Ada')
+
+Execute(Sets adals encoding):
+ let b:ale_ada_adals_encoding = 'iso-8859-1'
+ AssertLSPConfig {'ada.defaultCharset': 'iso-8859-1', 'ada.projectFile': 'default.gpr'}
+
+Execute(Sets adals project):
+ let g:ale_ada_adals_project = 'myproject.gpr'
+ AssertLSPConfig {'ada.defaultCharset': 'utf-8', 'ada.projectFile': 'myproject.gpr'}
diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader
index f0a07e8c..eb1220be 100644
--- a/test/command_callback/test_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_clang_tidy_command_callback.vader
@@ -68,7 +68,6 @@ Execute(The build directory should be used for header files):
\ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s'
\ . ' -p ' . ale#Escape('/foo/bar')
- \ . ' -- -x c++'
call ale#test#SetFilename('test.hpp')
diff --git a/test/command_callback/test_dart_analysis_server_command_callback.vader b/test/command_callback/test_dart_analysis_server_command_callback.vader
new file mode 100644
index 00000000..1754109a
--- /dev/null
+++ b/test/command_callback/test_dart_analysis_server_command_callback.vader
@@ -0,0 +1,15 @@
+Before:
+ call ale#assert#SetUpLinterTest('dart', 'analysis_server')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'dart', ale#Escape('dart')
+ \ . ' ./snapshots/analysis_server.dart.snapshot --lsp'
+
+Execute(The executable should be configurable):
+ let g:ale_dart_analysis_server_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar')
+ \ . ' ./snapshots/analysis_server.dart.snapshot --lsp'
diff --git a/test/command_callback/test_spectral_command_callback.vader b/test/command_callback/test_spectral_command_callback.vader
new file mode 100644
index 00000000..ed3795b9
--- /dev/null
+++ b/test/command_callback/test_spectral_command_callback.vader
@@ -0,0 +1,31 @@
+Before:
+ call ale#assert#SetUpLinterTest('yaml', 'spectral')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The yaml spectral command callback should return the correct default string):
+ AssertLinter 'spectral', ale#Escape('spectral') . ' lint --ignore-unknown-format -q -f text %t'
+
+Execute(The yaml spectral command callback should be configurable):
+ let g:ale_yaml_spectral_executable = '~/.local/bin/spectral'
+
+ AssertLinter '~/.local/bin/spectral',
+ \ ale#Escape('~/.local/bin/spectral')
+ \ . ' lint --ignore-unknown-format -q -f text %t'
+
+Execute(The yaml spectral command callback should allow a global installation to be used):
+ let g:ale_yaml_spectral_executable = '/usr/local/bin/spectral'
+ let g:ale_yaml_spectral_use_global = 1
+
+ AssertLinter '/usr/local/bin/spectral',
+ \ ale#Escape('/usr/local/bin/spectral')
+ \ . ' lint --ignore-unknown-format -q -f text %t'
+
+Execute(The yaml spectral command callback should allow a local installation to be used):
+ call ale#test#SetFilename('spectral_paths/openapi.yaml')
+
+ AssertLinter
+ \ ale#path#Simplify(g:dir . '/spectral_paths/node_modules/.bin/spectral'),
+ \ ale#Escape(ale#path#Simplify(g:dir . '/spectral_paths/node_modules/.bin/spectral'))
+ \ . ' lint --ignore-unknown-format -q -f text %t'
diff --git a/test/command_callback/test_typescript_deno_lsp.vader b/test/command_callback/test_typescript_deno_lsp.vader
new file mode 100644
index 00000000..01cbc851
--- /dev/null
+++ b/test/command_callback/test_typescript_deno_lsp.vader
@@ -0,0 +1,60 @@
+Before:
+ let g:ale_deno_unstable = 0
+ let g:ale_deno_executable = 'deno'
+ let g:ale_deno_project_root = ''
+
+ runtime autoload/ale/handlers/deno.vim
+ call ale#assert#SetUpLinterTest('typescript', 'deno')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Should set deno lsp for TypeScript projects using stable Deno API):
+ AssertLSPLanguage 'typescript'
+ AssertLSPConfig {}
+ AssertLSPProject ale#path#Simplify(g:dir . '/../..')
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:false
+ \}
+
+Execute(Should set deno lsp using unstable Deno API if enabled by user):
+ let g:ale_deno_unstable = 1
+ AssertLSPLanguage 'typescript'
+ AssertLSPConfig {}
+ AssertLSPProject ale#path#Simplify(g:dir . '/../..')
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:true
+ \}
+
+Execute(Should find project root containing tsconfig.json):
+ call ale#test#SetFilename('../typescript/test.ts')
+ AssertLSPLanguage 'typescript'
+ AssertLSPConfig {}
+ AssertLSPProject ale#path#Simplify(g:dir . '/../typescript')
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:false
+ \}
+
+Execute(Should use user-specified project root):
+ let g:ale_deno_lsp_project_root = '/'
+
+ call ale#test#SetFilename('../typescript/test.ts')
+ AssertLSPLanguage 'typescript'
+ AssertLSPConfig {}
+ AssertLSPProject '/'
+ AssertLSPOptions {
+ \ 'enable': v:true,
+ \ 'lint': v:true,
+ \ 'unstable': v:false
+ \}
+
+Execute(Check Deno LSP command):
+ AssertLinter 'deno', [
+ \ ale#Escape('deno') . ' lsp',
+ \]
diff --git a/test/fixers/test_standardrb_fixer_callback.vader b/test/fixers/test_standardrb_fixer_callback.vader
index 99234b79..d315651f 100644
--- a/test/fixers/test_standardrb_fixer_callback.vader
+++ b/test/fixers/test_standardrb_fixer_callback.vader
@@ -21,9 +21,9 @@ Execute(The standardrb callback should return the correct default values):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
- \ . ' --fix --force-exclusion %t',
+ \ . ' --fix --force-exclusion --stdin %s',
\ },
\ ale#fixers#standardrb#Fix(bufnr(''))
@@ -32,10 +32,10 @@ Execute(The standardrb callback should include configuration files):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.standard.yml'))
- \ . ' --fix --force-exclusion %t',
+ \ . ' --fix --force-exclusion --stdin %s',
\ },
\ ale#fixers#standardrb#Fix(bufnr(''))
@@ -45,10 +45,10 @@ Execute(The standardrb callback should include custom rubocop options):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.standard.yml'))
\ . ' --except Lint/Debugger'
- \ . ' --fix --force-exclusion %t',
+ \ . ' --fix --force-exclusion --stdin %s',
\ },
\ ale#fixers#standardrb#Fix(bufnr(''))
diff --git a/test/handler/test_atools_handler.vader b/test/handler/test_atools_handler.vader
new file mode 100644
index 00000000..1bb9ca00
--- /dev/null
+++ b/test/handler/test_atools_handler.vader
@@ -0,0 +1,85 @@
+Before:
+ runtime autoload/ale/handlers/atools.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The atools handler should handle basic errors or warings):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'text': 'trailing whitespace',
+ \ 'type': 'E',
+ \ 'code': 'AL8',
+ \ },
+ \ {
+ \ 'lnum': 15,
+ \ 'text': '$pkgname should not be used in the source url',
+ \ 'type': 'W',
+ \ 'code': 'AL29',
+ \ },
+ \ ],
+ \ ale#handlers#atools#Handle(bufnr(''), [
+ \ 'IC:[AL8]:APKBUILD:2:trailing whitespace',
+ \ 'MC:[AL29]:APKBUILD:15:$pkgname should not be used in the source url',
+ \ ])
+
+" Regardless of the severity, if the certainty is [P]ossible and not [C]ertain
+" or if regardless of the Certainity the Severity is not [I]mportant or [S]erious
+" then it must be a [W]arning
+Execute(If we are not Certain or Importantly Serious, be a Warning):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'text': 'This violation is Serious but Possible false positive, I am a Warning!',
+ \ 'type': 'W',
+ \ 'code': 'AL',
+ \ },
+ \ {
+ \ 'lnum': 4,
+ \ 'text': 'This violation is Important but Possible false positive, I am a Warning!',
+ \ 'type': 'W',
+ \ 'code': 'AL',
+ \ },
+ \ {
+ \ 'lnum': 5,
+ \ 'text': 'This violation is Minor, I am a Warning!',
+ \ 'type': 'W',
+ \ 'code': 'AL',
+ \ },
+ \ {
+ \ 'lnum': 6,
+ \ 'text': 'This violation is Style, I am a Warning!',
+ \ 'type': 'W',
+ \ 'code': 'AL',
+ \ },
+ \ ],
+ \ ale#handlers#atools#Handle(bufnr(''), [
+ \ 'SP:[AL]:APKBUILD:3:This violation is Serious but Possible false positive, I am a Warning!',
+ \ 'IP:[AL]:APKBUILD:4:This violation is Important but Possible false positive, I am a Warning!',
+ \ 'MC:[AL]:APKBUILD:5:This violation is Minor, I am a Warning!',
+ \ 'TC:[AL]:APKBUILD:6:This violation is Style, I am a Warning!',
+ \ ])
+
+Execute(We should be error if we are Certain it is Serious or Important):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 7,
+ \ 'text': 'This is Certainly Serious, I am an Error!',
+ \ 'type': 'E',
+ \ 'code': 'AL',
+ \ },
+ \ {
+ \ 'lnum': 8,
+ \ 'text': 'This is Certainly Important, I am an Error!',
+ \ 'type': 'E',
+ \ 'code': 'AL',
+ \ },
+ \ ],
+ \ ale#handlers#atools#Handle(bufnr(''), [
+ \ 'SC:[AL]:APKBUILD:7:This is Certainly Serious, I am an Error!',
+ \ 'IC:[AL]:APKBUILD:8:This is Certainly Important, I am an Error!',
+ \ ])
diff --git a/test/handler/test_spectral_handler.vader b/test/handler/test_spectral_handler.vader
new file mode 100644
index 00000000..89a3ff1b
--- /dev/null
+++ b/test/handler/test_spectral_handler.vader
@@ -0,0 +1,52 @@
+Before:
+ runtime ale_linters/yaml/spectral.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(spectral handler should parse lines correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'code': 'oas3-api-servers',
+ \ 'text': 'OpenAPI `servers` must be present and non-empty array.',
+ \ 'type': 'W'
+ \ },
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'code': 'oas3-schema',
+ \ 'text': 'Object should have required property `paths`.',
+ \ 'type': 'E'
+ \ },
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'code': 'openapi-tags',
+ \ 'text': 'OpenAPI object should have non-empty `tags` array.',
+ \ 'type': 'W'
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 6,
+ \ 'code': 'info-contact',
+ \ 'text': 'Info object should contain `contact` object.',
+ \ 'type': 'W'
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 6,
+ \ 'code': 'oas3-schema',
+ \ 'text': '`info` property should have required property `version`.',
+ \ 'type': 'E'
+ \ },
+ \ ],
+ \ ale#handlers#spectral#HandleSpectralOutput(bufnr(''), [
+ \ 'openapi.yml:1:1 warning oas3-api-servers "OpenAPI `servers` must be present and non-empty array."',
+ \ 'openapi.yml:1:1 error oas3-schema "Object should have required property `paths`."',
+ \ 'openapi.yml:1:1 warning openapi-tags "OpenAPI object should have non-empty `tags` array."',
+ \ 'openapi.yml:3:6 warning info-contact "Info object should contain `contact` object."',
+ \ 'openapi.yml:3:6 error oas3-schema "`info` property should have required property `version`."',
+ \ ])
diff --git a/test/test_deno_executable_detection.vader b/test/test_deno_executable_detection.vader
new file mode 100644
index 00000000..edd408b1
--- /dev/null
+++ b/test/test_deno_executable_detection.vader
@@ -0,0 +1,19 @@
+Before:
+ runtime autoload/ale/handlers/deno.vim
+
+After:
+ unlet! g:ale_deno_executable
+
+ call ale#linter#Reset()
+
+Execute(Default executable should be detected correctly):
+ AssertEqual
+ \ 'deno',
+ \ ale#handlers#deno#GetExecutable(bufnr(''))
+
+Execute(User specified executable should override default):
+ let g:ale_deno_executable = '/path/to/deno-bin'
+ AssertEqual
+ \ '/path/to/deno-bin',
+ \ ale#handlers#deno#GetExecutable(bufnr(''))
+
diff --git a/test/test_filetype_linter_defaults.vader b/test/test_filetype_linter_defaults.vader
index e9980536..d4e708ec 100644
--- a/test/test_filetype_linter_defaults.vader
+++ b/test/test_filetype_linter_defaults.vader
@@ -70,3 +70,10 @@ Execute(The defaults for the verilog filetype should be correct):
Execute(Default aliases for React should be defined):
AssertEqual ['javascript', 'jsx'], ale#linter#ResolveFiletype('javascriptreact')
AssertEqual ['typescript', 'tsx'], ale#linter#ResolveFiletype('typescriptreact')
+
+Execute(The defaults for the apkbuild filetype should be correct):
+ AssertEqual ['apkbuild_lint', 'secfixes_check'], GetLinterNames('apkbuild')
+
+ let g:ale_linters_explicit = 1
+
+ AssertEqual [], GetLinterNames('apkbuild')
diff --git a/test/typescript/test.ts b/test/typescript/test.ts
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/typescript/test.ts
diff --git a/test/typescript/tsconfig.json b/test/typescript/tsconfig.json
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/typescript/tsconfig.json