summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_graphql_gqlint_command_callbacks.vader11
-rw-r--r--test/command_callback/test_tex_lacheck_command_callback.vader13
-rw-r--r--test/command_callback/tex_paths/sample1.tex0
-rw-r--r--test/command_callback/tex_paths/sample2.tex0
-rw-r--r--test/fix/test_ale_fix.vader18
-rw-r--r--test/fixers/test_break_up_long_lines_python_fixer.vader4
-rw-r--r--test/fixers/test_standard_fixer_callback.vader14
-rw-r--r--test/fixers/test_trim_whitespace.vader18
-rw-r--r--test/handler/test_lacheck_handler.vader36
-rw-r--r--test/test_no_linting_on_write_quit.vader2
10 files changed, 95 insertions, 21 deletions
diff --git a/test/command_callback/test_graphql_gqlint_command_callbacks.vader b/test/command_callback/test_graphql_gqlint_command_callbacks.vader
new file mode 100644
index 00000000..0f4e9770
--- /dev/null
+++ b/test/command_callback/test_graphql_gqlint_command_callbacks.vader
@@ -0,0 +1,11 @@
+Before:
+ call ale#assert#SetUpLinterTest('graphql', 'gqlint')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The linter should run from the directory of the file in the buffer):
+ AssertLinter 'gqlint',
+ \ ale#path#CdString(expand('%:p:h'))
+ \ . 'gqlint --reporter=simple'
+ \ . ' %t'
diff --git a/test/command_callback/test_tex_lacheck_command_callback.vader b/test/command_callback/test_tex_lacheck_command_callback.vader
new file mode 100644
index 00000000..b404cc78
--- /dev/null
+++ b/test/command_callback/test_tex_lacheck_command_callback.vader
@@ -0,0 +1,13 @@
+Before:
+ call ale#assert#SetUpLinterTest('tex', 'lacheck')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(Executable should default to lacheck):
+ AssertLinter 'lacheck', ale#Escape('lacheck') . ' %t'
+
+Execute(Should be able to set a custom executable):
+ let g:ale_tex_lacheck_executable = 'bin/foo'
+
+ AssertLinter 'bin/foo' , ale#Escape('bin/foo') . ' %t'
diff --git a/test/command_callback/tex_paths/sample1.tex b/test/command_callback/tex_paths/sample1.tex
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/tex_paths/sample1.tex
diff --git a/test/command_callback/tex_paths/sample2.tex b/test/command_callback/tex_paths/sample2.tex
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/tex_paths/sample2.tex
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader
index 90407681..1b1891ce 100644
--- a/test/fix/test_ale_fix.vader
+++ b/test/fix/test_ale_fix.vader
@@ -33,21 +33,21 @@ Before:
call ale#test#SetFilename('test.txt')
call ale#linter#PreventLoading('testft')
- function AddCarets(buffer, lines) abort
+ function AddCarets(buffer, done, lines) abort
" map() is applied to the original lines here.
" This way, we can ensure that defensive copies are made.
return map(a:lines, '''^'' . v:val')
endfunction
- function AddDollars(buffer, lines) abort
+ function AddDollars(buffer, done, lines) abort
return map(a:lines, '''$'' . v:val')
endfunction
- function DoNothing(buffer, lines) abort
+ function DoNothing(buffer, done, lines) abort
return 0
endfunction
- function CatLine(buffer, lines) abort
+ function CatLine(buffer, done, lines) abort
return {'command': 'cat - <(echo d)'}
endfunction
@@ -55,11 +55,11 @@ Before:
return {'command': 'cat - <(echo d)'}
endfunction
- function ReplaceWithTempFile(buffer, lines) abort
+ function ReplaceWithTempFile(buffer, done, lines) abort
return {'command': 'echo x > %t', 'read_temporary_file': 1}
endfunction
- function RemoveLastLine(buffer, lines) abort
+ function RemoveLastLine(buffer, done, lines) abort
return ['a', 'b']
endfunction
@@ -122,11 +122,11 @@ Before:
endfunction
" echo will output a single blank line, and we should ingore it.
- function! IgnoredEmptyOutput(buffer, output)
+ function! IgnoredEmptyOutput(buffer, done, output)
return {'command': has('win32') ? 'echo(' : 'echo'}
endfunction
- function! EchoLineNoPipe(buffer, output)
+ function! EchoLineNoPipe(buffer, done, output)
return {'command': 'echo new line', 'read_buffer': 0}
endfunction
@@ -399,7 +399,7 @@ Execute(ALEFix should accept lambdas):
" to make the test pass.
call setline(1, ['a', 'b', 'c', 'd'])
else
- let g:ale_fixers.testft = [{buffer, lines -> lines + ['d']}]
+ let g:ale_fixers.testft = [{buffer, done, lines -> lines + ['d']}]
ALEFix
endif
diff --git a/test/fixers/test_break_up_long_lines_python_fixer.vader b/test/fixers/test_break_up_long_lines_python_fixer.vader
index 5fd991f0..847d3358 100644
--- a/test/fixers/test_break_up_long_lines_python_fixer.vader
+++ b/test/fixers/test_break_up_long_lines_python_fixer.vader
@@ -16,7 +16,7 @@ Execute(Long lines with basic function calls should be broken up correctly):
\ ' bar,',
\ '))',
\ ],
- \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
+ \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), v:null, [
\ 'def foo():',
\ ' some_variable = this_is_a_longer_function(first_argument, second_argument, third_with_function_call(foo, bar))',
\ ])
@@ -33,7 +33,7 @@ Execute(Longer lines should be permitted if a configuration file allows it):
\ ' a_third_long_word,',
\ ')'
\ ],
- \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
+ \ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), v:null, [
\ 'x = this_line_is_between_79_and_90_characters(first, second, third, fourth, fifth)',
\ 'y = this_line_is_longer_than_90_characters(much_longer_word, another_longer_word, a_third_long_word)',
\ ])
diff --git a/test/fixers/test_standard_fixer_callback.vader b/test/fixers/test_standard_fixer_callback.vader
index 38f2d54a..db9f20f6 100644
--- a/test/fixers/test_standard_fixer_callback.vader
+++ b/test/fixers/test_standard_fixer_callback.vader
@@ -1,6 +1,9 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
+ unlet! b:ale_javascript_standard_executable
+ unlet! b:ale_javascript_standard_options
+
After:
call ale#test#RestoreDirectory()
@@ -15,3 +18,14 @@ Execute(The executable path should be correct):
\ . ' --fix %t',
\ },
\ ale#fixers#standard#Fix(bufnr(''))
+
+Execute(Custom options should be supported):
+ let b:ale_javascript_standard_use_global = 1
+ let b:ale_javascript_standard_options = '--foo-bar'
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('standard') . ' --foo-bar --fix %t',
+ \ },
+ \ ale#fixers#standard#Fix(bufnr(''))
diff --git a/test/fixers/test_trim_whitespace.vader b/test/fixers/test_trim_whitespace.vader
index 2ffbcb04..10070374 100644
--- a/test/fixers/test_trim_whitespace.vader
+++ b/test/fixers/test_trim_whitespace.vader
@@ -16,13 +16,13 @@ Execute(Should delete all whitespace at the end of different lines):
\ ' bar,',
\ '))',
\ ],
- \ ale#fixers#generic#TrimWhitespace(bufnr(''), [
- \ 'def foo():',
- \ ' some_variable = this_is_a_longer_function(',
- \ 'first_argument,',
- \ ' second_argument,',
- \ ' third_with_function_call(',
- \ 'foo,',
- \ ' bar,',
- \ '))',
+ \ ale#fixers#generic#TrimWhitespace(bufnr(''), v:null, [
+ \ 'def foo():',
+ \ ' some_variable = this_is_a_longer_function(',
+ \ 'first_argument,',
+ \ ' second_argument,',
+ \ ' third_with_function_call(',
+ \ 'foo,',
+ \ ' bar,',
+ \ '))',
\ ])
diff --git a/test/handler/test_lacheck_handler.vader b/test/handler/test_lacheck_handler.vader
new file mode 100644
index 00000000..0bcc3be8
--- /dev/null
+++ b/test/handler/test_lacheck_handler.vader
@@ -0,0 +1,36 @@
+Before:
+ runtime ale_linters/tex/lacheck.vim
+ call ale#test#SetDirectory('/testplugin/test')
+
+After:
+ call ale#linter#Reset()
+ call ale#test#RestoreDirectory()
+
+Execute(The lacheck handler should parse lines correctly):
+
+ call ale#test#SetFilename('command_callback/tex_paths/sample1.tex')
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'type': 'W',
+ \ 'text': 'perhaps you should insert a `~'' before "\ref"'
+ \ }
+ \ ],
+ \ ale_linters#tex#lacheck#Handle(bufnr(''), [
+ \ "** sample1:",
+ \ "\"sample1.tex\", line 1: perhaps you should insert a `~' before \"\\ref\""
+ \ ])
+
+Execute(The lacheck handler should ignore errors from input files):
+
+ call ale#test#SetFilename('ale_test.tex')
+
+ AssertEqual
+ \ [
+ \ ],
+ \ ale_linters#tex#lacheck#Handle(255, [
+ \ "** ale_input:",
+ \ "\"ale_input.tex\", line 1: perhaps you should insert a `~' before \"\\ref\""
+ \ ])
diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader
index 12ef38ed..75de06a4 100644
--- a/test/test_no_linting_on_write_quit.vader
+++ b/test/test_no_linting_on_write_quit.vader
@@ -23,7 +23,7 @@ Before:
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
endfunction
- function AddLine(buffer, lines) abort
+ function AddLine(buffer, done, lines) abort
return a:lines + ['x']
endfunction