summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_cargo_command_callbacks.vader39
-rw-r--r--test/command_callback/test_cs_csc_command_callbacks.vader47
-rw-r--r--test/command_callback/test_sorbet_command_callback.vader27
-rw-r--r--test/completion/test_public_completion_api.vader4
-rw-r--r--test/fixers/test_clangtidy_fixer_callback.vader51
-rw-r--r--test/fixers/test_sorbet_fixer_callback.vader42
-rw-r--r--test/handler/test_csc_handler.vader98
-rw-r--r--test/handler/test_mcsc_handler.vader19
-rw-r--r--test/python/test_deoplete_source.py15
9 files changed, 337 insertions, 5 deletions
diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader
index 438c97db..e56551ae 100644
--- a/test/command_callback/test_cargo_command_callbacks.vader
+++ b/test/command_callback/test_cargo_command_callbacks.vader
@@ -139,23 +139,60 @@ Execute(When a crate belongs to a workspace we chdir into the crate, unless we d
Execute(When ale_rust_cargo_use_clippy is set, cargo-clippy is used as linter):
let b:ale_rust_cargo_use_clippy = 1
+
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
- \ 'cargo clippy --frozen --message-format=json -q ',
+ \ 'cargo clippy --frozen --message-format=json -q',
\]
Execute(When ale_rust_cargo_clippy_options is set, cargo-clippy appends it to commandline):
let b:ale_rust_cargo_use_clippy = 1
let b:ale_rust_cargo_clippy_options = '-- -D warnings'
+
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
\ 'cargo clippy --frozen --message-format=json -q -- -D warnings',
\]
+Execute(Clippy options work without prepending --):
+ let b:ale_rust_cargo_use_clippy = 1
+ let b:ale_rust_cargo_clippy_options = '-D warnings'
+
+ AssertLinter 'cargo', [
+ \ ale#Escape('cargo') . ' --version',
+ \ 'cargo clippy --frozen --message-format=json -q -- -D warnings',
+ \]
+
+Execute(Build supports all cargo flags):
+ let g:ale_rust_cargo_use_check = 0
+ let g:ale_rust_cargo_check_all_targets = 1
+ let g:ale_rust_cargo_check_tests = 1
+ let g:ale_rust_cargo_check_examples = 1
+ let b:ale_rust_cargo_default_feature_behavior = 'all'
+
+ AssertLinter 'cargo', [
+ \ ale#Escape('cargo') . ' --version',
+ \ 'cargo build --all-targets --examples --tests --frozen --message-format=json -q --all-features',
+ \]
+
+Execute(Clippy supports all cargo flags):
+ let b:ale_rust_cargo_use_clippy = 1
+ let g:ale_rust_cargo_check_all_targets = 1
+ let g:ale_rust_cargo_check_tests = 1
+ let g:ale_rust_cargo_check_examples = 1
+ let b:ale_rust_cargo_default_feature_behavior = 'all'
+ let b:ale_rust_cargo_clippy_options = '-D warnings'
+
+ AssertLinter 'cargo', [
+ \ ale#Escape('cargo') . ' --version',
+ \ 'cargo clippy --all-targets --examples --tests --frozen --message-format=json -q --all-features -- -D warnings',
+ \]
+
Execute(cargo-check does not refer ale_rust_cargo_clippy_options):
let b:ale_rust_cargo_use_clippy = 0
let b:ale_rust_cargo_use_check = 1
let b:ale_rust_cargo_clippy_options = '-- -D warnings'
+
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
\ 'cargo check --frozen --message-format=json -q',
diff --git a/test/command_callback/test_cs_csc_command_callbacks.vader b/test/command_callback/test_cs_csc_command_callbacks.vader
new file mode 100644
index 00000000..c21ce209
--- /dev/null
+++ b/test/command_callback/test_cs_csc_command_callbacks.vader
@@ -0,0 +1,47 @@
+Before:
+ call ale#assert#SetUpLinterTest('cs', 'csc')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The csc linter should return the correct default command):
+ AssertLinter 'csc', ale#path#CdString(g:dir)
+ \ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
+
+Execute(The options should be be used in the command):
+ let g:ale_cs_csc_options = ''
+
+ AssertLinter 'csc', ale#path#CdString(g:dir)
+ \ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
+
+Execute(The souce path should be be used in the command):
+ let g:ale_cs_csc_source = '../foo/bar'
+
+ AssertLinter 'csc', ale#path#CdString('../foo/bar')
+ \ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
+
+Execute(The list of search pathes for assemblies should be be used in the command if not empty):
+ let g:ale_cs_csc_assembly_path = ['/usr/lib/mono', '../foo/bar']
+
+ AssertLinter 'csc', ale#path#CdString(g:dir)
+ \ . 'csc /unsafe'
+ \ . ' /lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar')
+ \ . ' /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
+
+ let g:ale_cs_csc_assembly_path = []
+
+ AssertLinter 'csc', ale#path#CdString(g:dir)
+ \ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
+
+Execute(The list of assemblies should be be used in the command if not empty):
+ let g:ale_cs_csc_assemblies = ['foo.dll', 'bar.dll']
+
+ AssertLinter 'csc', ale#path#CdString(g:dir)
+ \ . 'csc /unsafe'
+ \ . ' /r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll')
+ \ . ' /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
+
+ let g:ale_cs_csc_assemblies = []
+
+ AssertLinter 'csc', ale#path#CdString(g:dir)
+ \ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
diff --git a/test/command_callback/test_sorbet_command_callback.vader b/test/command_callback/test_sorbet_command_callback.vader
new file mode 100644
index 00000000..b46e90a4
--- /dev/null
+++ b/test/command_callback/test_sorbet_command_callback.vader
@@ -0,0 +1,27 @@
+
+Before:
+ call ale#assert#SetUpLinterTest('ruby', 'sorbet')
+ call ale#test#SetFilename('dummy.rb')
+
+ let g:ale_ruby_sorbet_executable = 'srb'
+ let g:ale_ruby_sorbet_options = ''
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Executable should default to srb):
+ AssertLinter 'srb', ale#Escape('srb')
+ \ . ' tc --lsp --disable-watchman'
+
+Execute(Should be able to set a custom executable):
+ let g:ale_ruby_sorbet_executable = 'bin/srb'
+
+ AssertLinter 'bin/srb' , ale#Escape('bin/srb')
+ \ . ' tc --lsp --disable-watchman'
+
+Execute(Setting bundle appends 'exec srb tc'):
+ let g:ale_ruby_sorbet_executable = 'path to/bundle'
+
+ AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
+ \ . ' exec srb'
+ \ . ' tc --lsp --disable-watchman'
diff --git a/test/completion/test_public_completion_api.vader b/test/completion/test_public_completion_api.vader
index befbb436..c3cd42b8 100644
--- a/test/completion/test_public_completion_api.vader
+++ b/test/completion/test_public_completion_api.vader
@@ -32,6 +32,10 @@ Execute(ale#completion#GetCompletionPosition() should return the position in the
" This is the first character of 'bar'
AssertEqual 4, ale#completion#GetCompletionPosition()
+Execute(ale#completion#GetCompletionPositionForDeoplete() should return the position on the given input string):
+ " This is the first character of 'bar'
+ AssertEqual 4, ale#completion#GetCompletionPositionForDeoplete('foo bar')
+
Execute(ale#completion#CanProvideCompletions should return 0 when no completion sources are available):
AssertEqual 0, ale#completion#CanProvideCompletions()
diff --git a/test/fixers/test_clangtidy_fixer_callback.vader b/test/fixers/test_clangtidy_fixer_callback.vader
new file mode 100644
index 00000000..68416b36
--- /dev/null
+++ b/test/fixers/test_clangtidy_fixer_callback.vader
@@ -0,0 +1,51 @@
+Before:
+ Save g:ale_c_clangtidy_executable
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_c_clangtidy_executable = 'xxxinvalid'
+ let g:ale_c_build_dir = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ../command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The clangtidy callback should return the correct default values):
+ call ale#test#SetFilename('c_paths/dummy.c')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_c_clangtidy_executable)
+ \ . ' -fix -fix-errors %t'
+ \ },
+ \ ale#fixers#clangtidy#Fix(bufnr(''))
+
+Execute(The clangtidy callback should include any additional options):
+ call ale#test#SetFilename('c_paths/dummy.c')
+ let g:ale_c_clangtidy_extra_options = '--some-option'
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_c_clangtidy_executable)
+ \ . ' -fix -fix-errors --some-option %t',
+ \ },
+ \ ale#fixers#clangtidy#Fix(bufnr(''))
+
+Execute(The clangtidy callback should support cpp files):
+ call ale#test#SetFilename('c_paths/dummy.cpp')
+ let g:ale_cpp_clangtidy_executable = 'invalidpp'
+ set filetype=cpp " The test fails without this
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_cpp_clangtidy_executable)
+ \ . ' -fix -fix-errors %t',
+ \ },
+ \ ale#fixers#clangtidy#Fix(bufnr(''))
diff --git a/test/fixers/test_sorbet_fixer_callback.vader b/test/fixers/test_sorbet_fixer_callback.vader
new file mode 100644
index 00000000..71870e4c
--- /dev/null
+++ b/test/fixers/test_sorbet_fixer_callback.vader
@@ -0,0 +1,42 @@
+
+Before:
+ Save g:ale_ruby_sorbet_executable
+ Save g:ale_ruby_sorbet_options
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_ruby_sorbet_executable = 'xxxinvalid'
+ let g:ale_ruby_sorbet_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The sorbet callback should return the correct default values):
+ call ale#test#SetFilename('ruby_paths/dummy.rb')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_ruby_sorbet_executable)
+ \ . ' tc --autocorrect --file %t',
+ \ },
+ \ ale#fixers#sorbet#Fix(bufnr(''))
+
+Execute(The sorbet callback should include custom sorbet options):
+ let g:ale_ruby_sorbet_options = '--enable-experimental-lsp-hover'
+ call ale#test#SetFilename('ruby_paths/with_config/dummy.rb')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_ruby_sorbet_executable)
+ \ . ' tc --enable-experimental-lsp-hover'
+ \ . ' --autocorrect --file %t',
+ \ },
+ \ ale#fixers#sorbet#Fix(bufnr(''))
diff --git a/test/handler/test_csc_handler.vader b/test/handler/test_csc_handler.vader
new file mode 100644
index 00000000..3db5b6fd
--- /dev/null
+++ b/test/handler/test_csc_handler.vader
@@ -0,0 +1,98 @@
+Before:
+ Save g:ale_cs_csc_source
+
+ unlet! g:ale_cs_csc_source
+
+ call ale#test#SetDirectory('/testplugin/test/handler')
+ call ale#test#SetFilename('Test.cs')
+
+ runtime ale_linters/cs/csc.vim
+
+After:
+ unlet! g:ale_cs_csc_source
+
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(The csc handler should work with the default of the buffer's directory):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 12,
+ \ 'col' : 29,
+ \ 'text': '; expected',
+ \ 'code': 'CS1001',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify(g:dir . '/Test.cs'),
+ \ },
+ \ ],
+ \ ale_linters#cs#csc#Handle(bufnr(''), [
+ \ 'Test.cs(12,29): error CS1001: ; expected',
+ \ 'Compilation failed: 2 error(s), 1 warnings',
+ \ ])
+
+Execute(The csc handler should handle cannot find symbol errors):
+ let g:ale_cs_csc_source = '/home/foo/project/bar'
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 12,
+ \ 'col' : 29,
+ \ 'text': '; expected',
+ \ 'code': 'CS1001',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify('/home/foo/project/bar/Test.cs'),
+ \ },
+ \ {
+ \ 'lnum': 101,
+ \ 'col': 0,
+ \ 'text': 'Unexpected processor directive (no #if for this #endif)',
+ \ 'code': 'CS1028',
+ \ 'type': 'E',
+ \ 'filename': ale#path#Simplify('/home/foo/project/bar/Test.cs'),
+ \ },
+ \ {
+ \ 'lnum': 10,
+ \ 'col': 12,
+ \ 'text': 'some warning',
+ \ 'code': 'CS0123',
+ \ 'type': 'W',
+ \ 'filename': ale#path#Simplify('/home/foo/project/bar/Test.cs'),
+ \ },
+ \ ],
+ \ ale_linters#cs#csc#Handle(bufnr(''), [
+ \ 'Test.cs(12,29): error CS1001: ; expected',
+ \ 'Test.cs(101,0): error CS1028: Unexpected processor directive (no #if for this #endif)',
+ \ 'Test.cs(10,12): warning CS0123: some warning',
+ \ 'Compilation failed: 2 error(s), 1 warnings',
+ \ ])
+
+Execute(The csc handler should handle non file specific compiler errors without reporting overal status report as error):
+ let g:ale_cs_csc_source = '/home/foo/project/bar'
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': -1,
+ \ 'col' : -1,
+ \ 'text': 'No source files specified.',
+ \ 'code': 'CS2008',
+ \ 'type': 'W',
+ \ 'filename': '<csc>',
+ \ },
+ \ {
+ \ 'lnum': -1,
+ \ 'col': -1,
+ \ 'text': 'Outputs without source must have the /out option specified',
+ \ 'code': 'CS1562',
+ \ 'type': 'E',
+ \ 'filename': '<csc>',
+ \ },
+ \ ],
+ \ ale_linters#cs#csc#Handle(bufnr(''), [
+ \ 'Microsoft (R) Visual C# Compiler version 2.8.2.62916 (2ad4aabc)',
+ \ 'Copyright (C) Microsoft Corporation. All rights reserved.',
+ \ 'warning CS2008: No source files specified.',
+ \ 'error CS1562: Outputs without source must have the /out option specified',
+ \ ])
diff --git a/test/handler/test_mcsc_handler.vader b/test/handler/test_mcsc_handler.vader
index 8ae47357..c04f7d27 100644
--- a/test/handler/test_mcsc_handler.vader
+++ b/test/handler/test_mcsc_handler.vader
@@ -67,3 +67,22 @@ Execute(The mcs handler should handle cannot find symbol errors):
\ 'Test.cs(10,12): warning CS0123: some warning',
\ 'Compilation failed: 2 error(s), 1 warnings',
\ ])
+
+Execute(The mcsc handler should handle non file specific compiler errors without reporting overal status report as error):
+ let g:ale_cs_mcsc_source = '/home/foo/project/bar'
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': -1,
+ \ 'col' : -1,
+ \ 'text': 'No files to compile were specified',
+ \ 'code': 'CS2008',
+ \ 'type': 'E',
+ \ 'filename': '<mcs>',
+ \ },
+ \ ],
+ \ ale_linters#cs#mcsc#Handle(bufnr(''), [
+ \ 'error CS2008: No files to compile were specified',
+ \ 'Compilation failed: 1 error(s), 0 warnings',
+ \ ])
diff --git a/test/python/test_deoplete_source.py b/test/python/test_deoplete_source.py
index 1462f77d..9e56a10d 100644
--- a/test/python/test_deoplete_source.py
+++ b/test/python/test_deoplete_source.py
@@ -41,6 +41,12 @@ class DeopleteSourceTest(unittest.TestCase):
)
self.assertEqual(attributes, {
+ 'input_patterns': {
+ '_': r'\.\w*$',
+ 'rust': r'(\.|::)\w*$',
+ 'typescript': r'(\.|\'|")\w*$',
+ 'cpp': r'(\.|::|->)\w*$',
+ },
'is_bytepos': True,
'mark': '[L]',
'min_pattern_length': 1,
@@ -48,12 +54,13 @@ class DeopleteSourceTest(unittest.TestCase):
'rank': 1000,
})
- def test_completion_position(self):
- self.call_results['ale#completion#GetCompletionPosition'] = 2
+ def test_complete_position(self):
+ self.call_results['ale#completion#GetCompletionPositionForDeoplete'] = 2
+ context = {'input': 'foo'}
- self.assertEqual(self.source.get_completion_position(), 2)
+ self.assertEqual(self.source.get_complete_position(context), 2)
self.assertEqual(self.call_list, [
- ('ale#completion#GetCompletionPosition', ()),
+ ('ale#completion#GetCompletionPositionForDeoplete', ('foo',)),
])
def test_request_completion_results(self):