diff options
Diffstat (limited to 'test')
20 files changed, 388 insertions, 16 deletions
diff --git a/test/command_callback/bib_paths/dummy.bib b/test/command_callback/bib_paths/dummy.bib new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/bib_paths/dummy.bib diff --git a/test/command_callback/sasslint-test-files/with-bin/node_modules/.bin/sass-lint b/test/command_callback/sasslint-test-files/with-bin/node_modules/.bin/sass-lint new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/sasslint-test-files/with-bin/node_modules/.bin/sass-lint diff --git a/test/command_callback/sasslint-test-files/with-source/node_modules/sass-lint/bin/sass-lint.js b/test/command_callback/sasslint-test-files/with-source/node_modules/sass-lint/bin/sass-lint.js new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/sasslint-test-files/with-source/node_modules/sass-lint/bin/sass-lint.js diff --git a/test/command_callback/test_bib_bibclean_command_callback.vader b/test/command_callback/test_bib_bibclean_command_callback.vader new file mode 100644 index 00000000..fa6f7d33 --- /dev/null +++ b/test/command_callback/test_bib_bibclean_command_callback.vader @@ -0,0 +1,24 @@ +Before: + call ale#assert#SetUpLinterTest('bib', 'bibclean') + + let g:ale_ruby_rubocop_executable = 'bibclean' + let g:ale_ruby_rubocop_options = '' + +After: + call ale#assert#TearDownLinterTest() + +Execute(Executable should default to bibclean): + AssertLinter 'bibclean', ale#Escape('bibclean') + \ . ' -file-position ' + +Execute(Should be able to set a custom executable): + let g:ale_bib_bibclean_executable = 'bin/bibclean' + + AssertLinter 'bin/bibclean' , ale#Escape('bin/bibclean') + \ . ' -file-position ' + +Execute(Should not include custom options): + let g:ale_bib_bibclean_options = '-no-prettryprint' + + AssertLinter 'bibclean' , ale#Escape('bibclean') + \ . ' -file-position ' diff --git a/test/command_callback/test_javalsp_command_callback.vader b/test/command_callback/test_javalsp_command_callback.vader index 1fbfddfb..aedb4a4b 100644 --- a/test/command_callback/test_javalsp_command_callback.vader +++ b/test/command_callback/test_javalsp_command_callback.vader @@ -6,5 +6,9 @@ After: call ale#assert#TearDownLinterTest() Execute(The javalsp callback should return the correct default value): - AssertLinter 'java', ale#Escape('java -cp javacs.jar -Xverify:none org.javacs.Main') + AssertLinter 'java', ale#Escape('java') . ' -cp javacs.jar -Xverify:none org.javacs.Main' +Execute(The javalsp java executable should be configurable): + let b:ale_java_javalsp_executable = '/bin/foobar' + + AssertLinter '/bin/foobar', ale#Escape('/bin/foobar') . ' -cp javacs.jar -Xverify:none org.javacs.Main' diff --git a/test/command_callback/test_pydocstyle_command_callback.vader b/test/command_callback/test_pydocstyle_command_callback.vader new file mode 100644 index 00000000..7e0df9ca --- /dev/null +++ b/test/command_callback/test_pydocstyle_command_callback.vader @@ -0,0 +1,39 @@ +Before: + call ale#assert#SetUpLinterTest('python', 'pydocstyle') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The pydocstyle command callback should return default string): + AssertLinter 'pydocstyle', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('pydocstyle') . ' ' . ale#Escape('dummy.txt') + +Execute(The pydocstyle command callback should allow options): + let g:ale_python_pydocstyle_options = '--verbose' + + AssertLinter 'pydocstyle', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('pydocstyle') . ' --verbose ' . ale#Escape('dummy.txt') + +Execute(The pydocstyle executable should be configurable): + let g:ale_python_pydocstyle_executable = '~/.local/bin/pydocstyle' + + AssertLinter '~/.local/bin/pydocstyle', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('~/.local/bin/pydocstyle') . ' ' . ale#Escape('dummy.txt') + +Execute(Setting executable to 'pipenv' appends 'run pydocstyle'): + let g:ale_python_pydocstyle_executable = 'path/to/pipenv' + + AssertLinter 'path/to/pipenv', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('path/to/pipenv') . ' run pydocstyle ' . ale#Escape('dummy.txt') + +Execute(Pipenv is detected when python_pydocstyle_auto_pipenv is set): + let g:ale_python_pydocstyle_auto_pipenv = 1 + call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + + AssertLinter 'pipenv', + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('pipenv') . ' run pydocstyle ' . ale#Escape('whatever.py') diff --git a/test/command_callback/test_sass_sasslint_command_callback.vader b/test/command_callback/test_sass_sasslint_command_callback.vader new file mode 100644 index 00000000..9b9bf906 --- /dev/null +++ b/test/command_callback/test_sass_sasslint_command_callback.vader @@ -0,0 +1,43 @@ +Before: + call ale#assert#SetUpLinterTest('sass', 'sasslint') + call ale#test#SetFilename('test.sass') + unlet! b:executable + +After: + call ale#assert#TearDownLinterTest() + +Execute(should default to source, bin/sass-lint.js): + call ale#test#SetFilename('sasslint-test-files/with-source/test.sass') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/sasslint-test-files/with-source/node_modules/sass-lint/bin/sass-lint.js' + \) + + AssertLinter b:executable, + \ (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(b:executable) + \ . ' -v -q -f compact %t' + +Execute(should fallback to bin, .bin/sass-lint): + call ale#test#SetFilename('sasslint-test-files/with-bin/test.sass') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/sasslint-test-files/with-bin/node_modules/.bin/sass-lint' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' -v -q -f compact %t' + +Execute(should fallback to global bin): + AssertLinter 'sass-lint', ale#Escape('sass-lint') . ' -v -q -f compact %t' + +Execute(The global executable should be configurable): + let b:ale_sass_sasslint_executable = 'foo' + + AssertLinter 'foo', ale#Escape('foo') . ' -v -q -f compact %t' + +Execute(The options should be configurable): + let b:ale_sass_sasslint_options = '--bar' + + AssertLinter 'sass-lint', ale#Escape('sass-lint') . ' --bar -v -q -f compact %t' diff --git a/test/command_callback/test_sasslint_command_callback.vader b/test/command_callback/test_sasslint_command_callback.vader deleted file mode 100644 index 9142c441..00000000 --- a/test/command_callback/test_sasslint_command_callback.vader +++ /dev/null @@ -1,11 +0,0 @@ -Before: - call ale#assert#SetUpLinterTest('sass', 'sasslint') - call ale#test#SetFilename('test.sass') - -After: - call ale#assert#TearDownLinterTest() - -Execute(The default sasslint command should be correct): - AssertLinter 'sass-lint', - \ ale#path#CdString(expand('%:p:h')) - \ . ale#Escape('sass-lint') . ' -v -q -f compact %t' diff --git a/test/command_callback/test_scalac_command_callback.vader b/test/command_callback/test_scalac_command_callback.vader index 5184aa0b..ea5ae109 100644 --- a/test/command_callback/test_scalac_command_callback.vader +++ b/test/command_callback/test_scalac_command_callback.vader @@ -6,7 +6,7 @@ After: Given scala(An empty Scala file): Execute(The default executable and command should be correct): - AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-before:jvm %t' + AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-after:parser %t' Given scala.sbt(An empty SBT file): Execute(scalac should not be run for sbt files): diff --git a/test/command_callback/test_scss_sasslint_command_callback.vader b/test/command_callback/test_scss_sasslint_command_callback.vader new file mode 100644 index 00000000..1695190a --- /dev/null +++ b/test/command_callback/test_scss_sasslint_command_callback.vader @@ -0,0 +1,43 @@ +Before: + call ale#assert#SetUpLinterTest('scss', 'sasslint') + call ale#test#SetFilename('test.scss') + unlet! b:executable + +After: + call ale#assert#TearDownLinterTest() + +Execute(should default to source, bin/sass-lint.js): + call ale#test#SetFilename('sasslint-test-files/with-source/test.scss') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/sasslint-test-files/with-source/node_modules/sass-lint/bin/sass-lint.js' + \) + + AssertLinter b:executable, + \ (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(b:executable) + \ . ' -v -q -f compact %t' + +Execute(should fallback to bin, .bin/sass-lint): + call ale#test#SetFilename('sasslint-test-files/with-bin/test.scss') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/sasslint-test-files/with-bin/node_modules/.bin/sass-lint' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' -v -q -f compact %t' + +Execute(should fallback to global bin): + AssertLinter 'sass-lint', ale#Escape('sass-lint') . ' -v -q -f compact %t' + +Execute(The global executable should be configurable): + let b:ale_scss_sasslint_executable = 'foo' + + AssertLinter 'foo', ale#Escape('foo') . ' -v -q -f compact %t' + +Execute(The options should be configurable): + let b:ale_scss_sasslint_options = '--bar' + + AssertLinter 'sass-lint', ale#Escape('sass-lint') . ' --bar -v -q -f compact %t' diff --git a/test/fixers/test_bibclean_fixer_callback.vader b/test/fixers/test_bibclean_fixer_callback.vader new file mode 100644 index 00000000..8d3081e3 --- /dev/null +++ b/test/fixers/test_bibclean_fixer_callback.vader @@ -0,0 +1,30 @@ +Before: + Save g:ale_bib_bibclean_executable + Save g:ale_bib_bibclean_options + + let g:ale_bib_bibclean_executable = 'xxxinvalid' + let g:ale_bib_bibclean_options = '-align-equals' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + call ale#test#RestoreDirectory() + +Execute(The bibclean callback should return the correct default values): + call ale#test#SetFilename('../command_callback/bib_paths/dummy.bib') + + AssertEqual + \ {'command': ale#Escape(g:ale_bib_bibclean_executable) . ' -align-equals'}, + \ ale#fixers#bibclean#Fix(bufnr('')) + +Execute(The bibclean callback should include custom bibclean options): + let g:ale_bib_bibclean_options = '-author -check-values' + call ale#test#SetFilename('../command_callback/bib_paths/dummy.bib') + + AssertEqual + \ { + \ 'command': ale#Escape(g:ale_bib_bibclean_executable) . ' -author -check-values' + \ }, + \ ale#fixers#bibclean#Fix(bufnr('')) + diff --git a/test/fixers/test_rufo_fixer_callback.vader b/test/fixers/test_rufo_fixer_callback.vader index a0828406..98108efc 100644 --- a/test/fixers/test_rufo_fixer_callback.vader +++ b/test/fixers/test_rufo_fixer_callback.vader @@ -4,9 +4,7 @@ Before: " Use an invalid global executable, so we don't match it. let g:ale_ruby_rufo_executable = 'xxxinvalid' - call ale#test#SetDirectory('/testplugin/test/fixers') - silent cd .. - silent cd command_callback + call ale#test#SetDirectory('/testplugin/test/command_callback') let g:dir = getcwd() After: diff --git a/test/handler/test_bibclean_handler.vader b/test/handler/test_bibclean_handler.vader new file mode 100644 index 00000000..6179d7f5 --- /dev/null +++ b/test/handler/test_bibclean_handler.vader @@ -0,0 +1,35 @@ +Before: + runtime ale_linters/bib/bibclean.vim + +After: + call ale#linter#Reset() + +Execute(The bibclean handler should parse lines correctly): + + AssertEqual + \ [ + \ { + \ 'lnum': '60', + \ 'type': 'W', + \ 'text': 'Unexpected value in ``month = "09"''''.', + \ 'col': '17' + \ }, + \ { + \ 'lnum': '63', + \ 'type': 'E', + \ 'text': 'Expected comma after last field ``keywords''''.', + \ 'col': ' 1' + \ } + \ ], + \ ale_linters#bib#bibclean#Handle(255, [ + \ "%% \"stdin\", line 60: Unexpected value in ``month = \"09\"''.", + \ "%% File positions: input [main.bib] output [stdout]", + \ "%% Entry input byte=1681 line=50 column= 1 output byte=1680 line=50 column= 0", + \ "%% Value input byte=2137 line=60 column=17 output byte=2137 line=60 column=17", + \ "%% Current input byte=2139 line=60 column=19 output byte=2137 line=60 column=17", + \ "?? \"stdin\", line 71: Expected comma after last field ``keywords''.", + \ "?? File positions: input [main.bib] output [stdout]", + \ "?? Entry input byte=2145 line=63 column= 1 output byte=2146 line=63 column= 0", + \ "?? Value input byte=2528 line=71 column= 2 output byte=2527 line=70 column=49", + \ "?? Current input byte=2529 line=71 column= 3 output byte=2528 line=70 column=50" + \ ]) diff --git a/test/handler/test_pydocstyle_handler.vader b/test/handler/test_pydocstyle_handler.vader new file mode 100644 index 00000000..d155dc9a --- /dev/null +++ b/test/handler/test_pydocstyle_handler.vader @@ -0,0 +1,116 @@ +Before: + Save g:ale_warn_about_trailing_whitespace + + let g:ale_warn_about_trailing_whitespace = 1 + + runtime ale_linters/python/pydocstyle.vim + +After: + Restore + + call ale#linter#Reset() + + silent file something_else.py + +" File sample.py +" # sample.py file +" +" def main(): +" """ +" This is a multi-line description that should produce multiple errors to be +" tested by the handler +" """ +" return Fales +" +" +" if __name__ == '__main__': +" main() +" +" The command to generate the handler input is: +" +" $ python -m pydocstyle --verbose --source --explain sample.py +" [...] +" $ + +Execute(Basic pydocstyle warnings should be handled): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 1, + \ 'text': 'Missing docstring in public module', + \ 'code': 'D100', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 4, + \ 'col': 1, + \ 'text': '1 blank line required between summary line and description (found 0)', + \ 'code': 'D205', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 4, + \ 'col': 1, + \ 'text': 'First line should end with a period (not ''e'')', + \ 'code': 'D400', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 4, + \ 'col': 1, + \ 'text': 'First line should be in imperative mood; try rephrasing (found ''This'')', + \ 'code': 'D401', + \ 'type': 'W', + \ }, + \ ], + \ ale_linters#python#pydocstyle#Handle(bufnr(''), [ + \ 'Checking file ' . fnamemodify(bufname(bufnr('')), ':p') . '.', + \ ale#Escape(fnamemodify(bufname(bufnr('')), ':t')) . ':1 at module level:', + \ ' D100: Missing docstring in public module', + \ '', + \ ' All modules should normally have docstrings. [...] all functions and', + \ ' classes exported by a module should also have docstrings. Public', + \ ' methods (including the __init__ constructor) should also have', + \ ' docstrings.', + \ ' Note: Public (exported) definitions are either those with names listed', + \ ' in __all__ variable (if present), or those that do not start', + \ ' with a single underscore.', + \ '', + \ ' 1: # 2: 3: s 4: a 5: m 6: p 7: l ...', + \ '', + \ '', + \ ale#Escape(fnamemodify(bufname(bufnr('')), ':t')) . ':4 in public function `main`:', + \ ' D205: 1 blank line required between summary line and description (found 0)', + \ '', + \ ' Multi-line docstrings consist of a summary line just like a one-line', + \ ' docstring, followed by a blank line, followed by a more elaborate', + \ ' description. The summary line may be used by automatic indexing tools;', + \ ' it is important that it fits on one line and is separated from the', + \ ' rest of the docstring by a blank line.', + \ '', + \ ' 3: d 4: e 5: f 6: 7: m 8: a 9: i ...', + \ '', + \ '', + \ ale#Escape(fnamemodify(bufname(bufnr('')), ':t')) . ':4 in public function `main`:', + \ ' D400: First line should end with a period (not ''e'')', + \ '', + \ ' The [first line of a] docstring is a phrase ending in a period.', + \ '', + \ ' 3: d 4: e 5: f 6: 7: m 8: a 9: i ...', + \ '', + \ '', + \ ale#Escape(fnamemodify(bufname(bufnr('')), ':t')) . ':4 in public function `main`:', + \ ' D401: First line should be in imperative mood; try rephrasing (found ''This'')', + \ '', + \ ' [Docstring] prescribes the function or method''s effect as a command:', + \ ' ("Do this", "Return that"), not as a description; e.g. don''t write', + \ ' "Returns the pathname ...".', + \ '', + \ ' 3: d 4: e 5: f 6: 7: m 8: a 9: i ...', + \ ]) + +Execute(Handler should handle empty output): + AssertEqual + \ [], + \ ale_linters#python#pydocstyle#Handle(bufnr(''), []) diff --git a/test/script/check-toc b/test/script/check-toc index 8e411589..09d794ee 100755 --- a/test/script/check-toc +++ b/test/script/check-toc @@ -36,6 +36,7 @@ doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ' -)" grep -h '\*ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \ | sed 's/^/ /' \ | sed 's/ALE Shell Integration/ALE sh Integration/' \ + | sed 's/ALE BibTeX Integration/ALE bib Integration/' \ | sed 's/ ALE \(.*\) Integration/\1/' \ | sed 's/ *\*\(..*\)\*$/, \1/' \ | tr '[:upper:]' '[:lower:]' \ diff --git a/test/swiftlint-test-files/cocoapods-and-react-native/Pods/SwiftLint/swiftlint b/test/swiftlint-test-files/cocoapods-and-react-native/Pods/SwiftLint/swiftlint new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/swiftlint-test-files/cocoapods-and-react-native/Pods/SwiftLint/swiftlint diff --git a/test/swiftlint-test-files/cocoapods-and-react-native/ios/Pods/SwiftLint/swiftlint b/test/swiftlint-test-files/cocoapods-and-react-native/ios/Pods/SwiftLint/swiftlint new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/swiftlint-test-files/cocoapods-and-react-native/ios/Pods/SwiftLint/swiftlint diff --git a/test/swiftlint-test-files/cocoapods/Pods/SwiftLint/swiftlint b/test/swiftlint-test-files/cocoapods/Pods/SwiftLint/swiftlint new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/swiftlint-test-files/cocoapods/Pods/SwiftLint/swiftlint diff --git a/test/swiftlint-test-files/react-native/ios/Pods/SwiftLint/swiftlint b/test/swiftlint-test-files/react-native/ios/Pods/SwiftLint/swiftlint new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/swiftlint-test-files/react-native/ios/Pods/SwiftLint/swiftlint diff --git a/test/test_swiftlint_executable_detection.vader b/test/test_swiftlint_executable_detection.vader new file mode 100644 index 00000000..a8e14c84 --- /dev/null +++ b/test/test_swiftlint_executable_detection.vader @@ -0,0 +1,50 @@ +Before: + let g:ale_swift_swiftlint_executable = 'swiftlint_d' + + call ale#test#SetDirectory('/testplugin/test') + + runtime ale_linters/swift/swiftlint.vim + +After: + let g:ale_has_override = {} + let g:ale_swift_swiftlint_executable = 'swiftlint' + let g:ale_swift_swiftlint_use_global = 0 + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(Global installation should be the default executable): + call ale#test#SetFilename('swiftlint-test-files/global/testfile.swift') + + AssertEqual + \ 'swiftlint_d', + \ ale_linters#swift#swiftlint#GetExecutable(bufnr('')) + +Execute(React Native apps using CocoaPods should take precedence over the default executable): + call ale#test#SetFilename('swiftlint-test-files/react-native/testfile.swift') + + AssertEqual + \ ale#path#Simplify(g:dir . '/swiftlint-test-files/react-native/ios/Pods/SwiftLint/swiftlint'), + \ ale_linters#swift#swiftlint#GetExecutable(bufnr('')) + +Execute(CocoaPods installation should take precedence over the default executable): + call ale#test#SetFilename('swiftlint-test-files/cocoapods/testfile.swift') + + AssertEqual + \ ale#path#Simplify(g:dir . '/swiftlint-test-files/cocoapods/Pods/SwiftLint/swiftlint'), + \ ale_linters#swift#swiftlint#GetExecutable(bufnr('')) + +Execute(Top level CocoaPods installation should take precedence over React Native installation): + call ale#test#SetFilename('swiftlint-test-files/cocoapods-and-react-native/testfile.swift') + + AssertEqual + \ ale#path#Simplify(g:dir . '/swiftlint-test-files/cocoapods-and-react-native/Pods/SwiftLint/swiftlint'), + \ ale_linters#swift#swiftlint#GetExecutable(bufnr('')) + +Execute(use-global should override other versions): + let g:ale_swift_swiftlint_use_global = 1 + call ale#test#SetFilename('swiftlint-test-files/cocoapods-and-react-native/testfile.swift') + + AssertEqual + \ 'swiftlint_d', + \ ale_linters#swift#swiftlint#GetExecutable(bufnr('')) |