diff options
83 files changed, 967 insertions, 396 deletions
@@ -103,8 +103,9 @@ formatting. | Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) | | JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [flow](https://flowtype.org/), [prettier](https://github.com/prettier/prettier), prettier-eslint >= 4.2.0, prettier-standard, [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo) | JSON | [jsonlint](http://zaa.ch/jsonlint/), [prettier](https://github.com/prettier/prettier) | -| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions +| Kotlin | [kotlinc](https://kotlinlang.org) !!, [ktlint](https://ktlint.github.io) !! see `:help ale-integration-kotlin` for configuration instructions | | LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) | +| LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) | | Lua | [luacheck](https://github.com/mpeterv/luacheck) | | Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale) | | MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) | @@ -113,7 +114,7 @@ formatting. | nroff | [proselint](http://proselint.com/)| | Objective-C | [clang](http://clang.llvm.org/) | | Objective-C++ | [clang](http://clang.llvm.org/) | -| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions +| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions | | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) | | PHP | [hack](http://hacklang.org/), [langserver](https://github.com/felixfbecker/php-language-server), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) | | Pod | [proselint](http://proselint.com/)| @@ -121,7 +122,7 @@ formatting. | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | | Python | [autopep8](https://github.com/hhatto/autopep8), [flake8](http://flake8.pycqa.org/en/latest/), [isort](https://github.com/timothycrosley/isort), [mypy](http://mypy-lang.org/), [pycodestyle](https://github.com/PyCQA/pycodestyle), [pylint](https://www.pylint.org/) !!, [yapf](https://github.com/google/yapf) | | R | [lintr](https://github.com/jimhester/lintr) | -| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions +| ReasonML | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-integration-reason-merlin` for configuration instructions | | reStructuredText | [proselint](http://proselint.com/) | | RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) | | Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) | @@ -129,7 +130,7 @@ formatting. | SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) | | SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) | | Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) | -| Slim | [slim-lint](https://github.com/sds/slim-lint) +| Slim | [slim-lint](https://github.com/sds/slim-lint) | | SML | [smlnj](http://www.smlnj.org/) | | Solidity | [solium](https://github.com/duaraghav8/Solium) | | Stylus | [stylelint](https://github.com/stylelint/stylelint) | @@ -144,7 +145,7 @@ formatting. | Vim | [vint](https://github.com/Kuniwak/vint) | | Vim help^ | [proselint](http://proselint.com/)| | XHTML | [proselint](http://proselint.com/)| -| XML | [xmllint](http://xmlsoft.org/xmllint.html/)| +| XML | [xmllint](http://xmlsoft.org/xmllint.html)| | YAML | [swaglint](https://github.com/byCedric/swaglint), [yamllint](https://yamllint.readthedocs.io/) | <a name="usage"></a> diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim index 4038e3b4..3783b5e3 100644 --- a/ale_linters/elm/make.vim +++ b/ale_linters/elm/make.vim @@ -71,11 +71,11 @@ function! ale_linters#elm#make#GetCommand(buffer) abort " The elm-make compiler, at the time of this writing, uses '/dev/null' as " a sort of flag to tell the compiler not to generate an output file, - " which is why this is hard coded here. + " which is why this is hard coded here. It does not use NUL on Windows. " Source: https://github.com/elm-lang/elm-make/blob/master/src/Flags.hs let l:elm_cmd = ale#Escape(l:elm_exe) \ . ' --report=json' - \ . ' --output=' . ale#Escape(g:ale#util#nul_file) + \ . ' --output=/dev/null' return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t' endfunction diff --git a/ale_linters/llvm/llc.vim b/ale_linters/llvm/llc.vim new file mode 100644 index 00000000..0a4903eb --- /dev/null +++ b/ale_linters/llvm/llc.vim @@ -0,0 +1,35 @@ +" Author: rhysd <https://rhysd.github.io> +" Description: Support for checking LLVM IR with llc + +call ale#Set('llvm_llc_executable', 'llc') + +function! ale_linters#llvm#llc#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'llvm_llc_executable') +endfunction + +function! ale_linters#llvm#llc#GetCommand(buffer) abort + return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer)) + \ . ' -filetype=null -o=' + \ . ale#Escape(g:ale#util#nul_file) +endfunction + +function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort + " Handle '{path}: {file}:{line}:{col}: error: {message}' format + let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$' + let l:matches = ale#util#GetMatches(a:lines, l:pattern) + + return map(l:matches, "{ + \ 'lnum': str2nr(v:val[1]), + \ 'col': str2nr(v:val[2]), + \ 'text': v:val[3], + \ 'type': 'E', + \}") +endfunction + +call ale#linter#Define('llvm', { +\ 'name': 'llc', +\ 'executable_callback': 'ale_linters#llvm#llc#GetExecutable', +\ 'output_stream': 'stderr', +\ 'command_callback': 'ale_linters#llvm#llc#GetCommand', +\ 'callback': 'ale_linters#llvm#llc#HandleErrors', +\}) diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim index b99e4f58..24762086 100644 --- a/ale_linters/php/phpstan.vim +++ b/ale_linters/php/phpstan.vim @@ -4,6 +4,7 @@ " Set to change the ruleset let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan') let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4') +let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') function! ale_linters#php#phpstan#GetExecutable(buffer) abort return ale#Var(a:buffer, 'php_phpstan_executable') @@ -12,10 +13,16 @@ endfunction function! ale_linters#php#phpstan#GetCommand(buffer) abort let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer) + let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration') + let l:configuration_option = !empty(l:configuration) + \ ? ' -c ' . l:configuration + \ : '' + return ale#Escape(l:executable) \ . ' analyze -l' \ . ale#Var(a:buffer, 'php_phpstan_level') \ . ' --errorFormat raw' + \ . l:configuration_option \ . ' %s' endfunction diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim index 004656b5..b47ba19f 100644 --- a/ale_linters/sh/shellcheck.vim +++ b/ale_linters/sh/shellcheck.vim @@ -2,7 +2,7 @@ " Description: This file adds support for using the shellcheck linter with " shell scripts. -" This global variable can be set with a string of comma-seperated error +" This global variable can be set with a string of comma-separated error " codes to exclude from shellcheck. For example: " " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' diff --git a/autoload/ale/command.vim b/autoload/ale/command.vim index f8d04ff2..558fe233 100644 --- a/autoload/ale/command.vim +++ b/autoload/ale/command.vim @@ -28,7 +28,7 @@ function! ale#command#FormatCommand(buffer, command, pipe_file_if_needed) abort " with an ugly string. let l:command = substitute(l:command, '%%', '<<PERCENTS>>', 'g') - " Replace all %s occurences in the string with the name of the current + " Replace all %s occurrences in the string with the name of the current " file. if l:command =~# '%s' let l:filename = fnamemodify(bufname(a:buffer), ':p') diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim index 340432f7..f5394a43 100644 --- a/autoload/ale/cursor.vim +++ b/autoload/ale/cursor.vim @@ -3,15 +3,6 @@ let s:cursor_timer = -1 let s:last_pos = [0, 0, 0] -let s:error_delay_ms = 1000 * 60 * 2 - -if !exists('s:dont_queue_until') - let s:dont_queue_until = -1 -endif - -if !exists('s:dont_echo_until') - let s:dont_echo_until = -1 -endif " Return a formatted message according to g:ale_echo_msg_format variable function! s:GetMessage(linter, type, text) abort @@ -84,12 +75,12 @@ function! ale#cursor#EchoCursorWarning(...) abort endfunction function! s:EchoImpl() abort - if ale#ShouldDoNothing(bufnr('')) + " Only echo the warnings in normal mode, otherwise we will get problems. + if mode() isnot# 'n' return endif - " Only echo the warnings in normal mode, otherwise we will get problems. - if mode() isnot# 'n' + if ale#ShouldDoNothing(bufnr('')) return endif @@ -108,15 +99,8 @@ function! s:EchoImpl() abort endfunction function! ale#cursor#EchoCursorWarningWithDelay() abort - return ale#CallWithCooldown( - \ 'dont_echo_with_delay_until', - \ function('s:EchoWithDelayImpl'), - \ [], - \) -endfunction - -function! s:EchoWithDelayImpl() abort - if ale#ShouldDoNothing(bufnr('')) + " Only echo the warnings in normal mode, otherwise we will get problems. + if mode() isnot# 'n' return endif @@ -135,12 +119,12 @@ function! s:EchoWithDelayImpl() abort endfunction function! ale#cursor#ShowCursorDetail() abort - if ale#ShouldDoNothing(bufnr('')) + " Only echo the warnings in normal mode, otherwise we will get problems. + if mode() isnot# 'n' return endif - " Only echo the warnings in normal mode, otherwise we will get problems. - if mode() isnot# 'n' + if ale#ShouldDoNothing(bufnr('')) return endif diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 839218b4..29cb44f3 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -573,7 +573,7 @@ function! ale#engine#ProcessChain(buffer, linter, chain_index, input) abort if has_key(a:linter, 'command_chain') while l:chain_index < len(a:linter.command_chain) - " Run a chain of commands, one asychronous command after the other, + " Run a chain of commands, one asynchronous command after the other, " so that many programs can be run in a sequence. let l:chain_item = a:linter.command_chain[l:chain_index] diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index e87b02f5..93c0860d 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -57,6 +57,11 @@ let s:default_registry = { \ 'suggested_filetypes': [], \ 'description': 'Remove all blank lines at the end of a file.', \ }, +\ 'trim_whitespace': { +\ 'function': 'ale#fixers#generic#TrimWhitespace', +\ 'suggested_filetypes': [], +\ 'description': 'Remove all trailing whitespace characters at the end of every line.', +\ }, \ 'yapf': { \ 'function': 'ale#fixers#yapf#Fix', \ 'suggested_filetypes': ['python'], @@ -92,6 +97,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['c', 'cpp'], \ 'description': 'Fix C/C++ files with clang-format.', \ }, +\ 'gofmt': { +\ 'function': 'ale#fixers#gofmt#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with go fmt.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/autopep8.vim b/autoload/ale/fixers/autopep8.vim index e2dd7bfe..e0e6205f 100644 --- a/autoload/ale/fixers/autopep8.vim +++ b/autoload/ale/fixers/autopep8.vim @@ -12,7 +12,7 @@ function! ale#fixers#autopep8#Fix(buffer) abort \ ['autopep8'], \) - if !executable(l:executable) + if !ale#python#IsExecutable(l:executable) return 0 endif diff --git a/autoload/ale/fixers/generic.vim b/autoload/ale/fixers/generic.vim index fdc8eab1..cb8865b4 100644 --- a/autoload/ale/fixers/generic.vim +++ b/autoload/ale/fixers/generic.vim @@ -10,3 +10,16 @@ function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort return a:lines[:l:end_index] endfunction + +" Remove all whitespaces at the end of lines +function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort + let l:index = 0 + let l:lines_new = range(len(a:lines)) + + for l:line in a:lines + let l:lines_new[l:index] = substitute(l:line, '\s\+$', '', 'g') + let l:index = l:index + 1 + endfor + + return l:lines_new +endfunction diff --git a/autoload/ale/fixers/gofmt.vim b/autoload/ale/fixers/gofmt.vim new file mode 100644 index 00000000..66b67a9e --- /dev/null +++ b/autoload/ale/fixers/gofmt.vim @@ -0,0 +1,18 @@ +" Author: aliou <code@aliou.me> +" Description: Integration of gofmt with ALE. + +call ale#Set('go_gofmt_executable', 'gofmt') +call ale#Set('go_gofmt_options', '') + +function! ale#fixers#gofmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_gofmt_executable') + let l:options = ale#Var(a:buffer, 'go_gofmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -l -w' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim index 00d968f4..ddd95611 100644 --- a/autoload/ale/fixers/isort.vim +++ b/autoload/ale/fixers/isort.vim @@ -11,7 +11,7 @@ function! ale#fixers#isort#Fix(buffer) abort \ ['isort'], \) - if !executable(l:executable) + if !ale#python#IsExecutable(l:executable) return 0 endif diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim index ca1bf608..4adc3b08 100644 --- a/autoload/ale/fixers/prettier.vim +++ b/autoload/ale/fixers/prettier.vim @@ -10,6 +10,10 @@ call ale#Set('javascript_prettier_options', '') function! s:FindConfig(buffer) abort for l:filename in [ \ '.prettierrc', + \ '.prettierrc.json', + \ '.prettierrc.yaml', + \ '.prettierrc.yml', + \ '.prettierrc.js', \ 'prettier.config.js', \ 'package.json', \ ] diff --git a/autoload/ale/fixers/standard.vim b/autoload/ale/fixers/standard.vim index 443560ed..c998cfd0 100644 --- a/autoload/ale/fixers/standard.vim +++ b/autoload/ale/fixers/standard.vim @@ -1,6 +1,10 @@ " Author: Sumner Evans <sumner.evans98@gmail.com> " Description: Fixing files with Standard. +call ale#Set('javascript_standard_executable', 'standard') +call ale#Set('javascript_standard_use_global', 0) +call ale#Set('javascript_standard_options', '') + function! ale#fixers#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ \ 'node_modules/standard/bin/cmd.js', diff --git a/autoload/ale/fixers/yapf.vim b/autoload/ale/fixers/yapf.vim index ba7453b8..b15e481e 100644 --- a/autoload/ale/fixers/yapf.vim +++ b/autoload/ale/fixers/yapf.vim @@ -11,7 +11,7 @@ function! ale#fixers#yapf#Fix(buffer) abort \ ['yapf'], \) - if !executable(l:executable) + if !ale#python#IsExecutable(l:executable) return 0 endif diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index b08e0ea7..3397ab5e 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -1,6 +1,8 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Functions for working with eslint, for checking or fixing files. +let s:sep = has('win32') ? '\' : '/' + call ale#Set('javascript_eslint_options', '') call ale#Set('javascript_eslint_executable', 'eslint') call ale#Set('javascript_eslint_use_global', 0) @@ -15,7 +17,7 @@ function! ale#handlers#eslint#FindConfig(buffer) abort \ '.eslintrc.json', \ '.eslintrc', \] - let l:config = ale#path#Simplify(l:path . '/' . l:basename) + let l:config = ale#path#Simplify(join([l:path, l:basename], s:sep)) if filereadable(l:config) return l:config diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim index 1d8b6760..254f4eec 100644 --- a/autoload/ale/job.vim +++ b/autoload/ale/job.vim @@ -1,5 +1,5 @@ " Author: w0rp <devw0rp@gmail.com> -" Deciption: APIs for working with Asynchronous jobs, with an API normalised +" Description: APIs for working with Asynchronous jobs, with an API normalised " between Vim 8 and NeoVim. " " Important functions are described below. They are: diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim index 2cd773f1..269b0929 100644 --- a/autoload/ale/linter.vim +++ b/autoload/ale/linter.vim @@ -305,7 +305,7 @@ endfunction function! ale#linter#Get(original_filetypes) abort let l:possibly_duplicated_linters = [] - " Handle dot-seperated filetypes. + " Handle dot-separated filetypes. for l:original_filetype in split(a:original_filetypes, '\.') let l:filetype = ale#linter#ResolveFiletype(l:original_filetype) let l:linter_names = s:GetLinterNames(l:original_filetype) diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim index 0ba174c7..83f6e85d 100644 --- a/autoload/ale/path.vim +++ b/autoload/ale/path.vim @@ -9,14 +9,22 @@ endfunction " This function is mainly used for testing. " Simplify() a path, and change forward slashes to back slashes on Windows. -function! ale#path#Winify(path) abort - let l:simplified_path = ale#path#Simplify(a:path) +" +" If an additional 'add_drive' argument is given, the current drive letter +" will be prefixed to any absolute paths on Windows. +function! ale#path#Winify(path, ...) abort + let l:new_path = ale#path#Simplify(a:path) if has('win32') - return substitute(l:simplified_path, '/', '\\', 'g') + let l:new_path = substitute(l:new_path, '/', '\\', 'g') + + " Add a drive letter to \foo\bar paths, if needed. + if a:0 && a:1 is# 'add_drive' && l:new_path[:0] is# '\' + let l:new_path = fnamemodify('.', ':p')[:1] . l:new_path + endif endif - return l:simplified_path + return l:new_path endfunction " Given a buffer and a filename, find the nearest file by searching upwards diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim index ed5064d5..d788b779 100644 --- a/autoload/ale/python.vim +++ b/autoload/ale/python.vim @@ -1,6 +1,7 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Functions for integrating with Python linters. +let s:sep = has('win32') ? '\' : '/' " bin is used for Unix virtualenv directories, and Scripts is for Windows. let s:bin_dir = has('unix') ? 'bin' : 'Scripts' let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [ @@ -11,7 +12,6 @@ let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [ \ 'virtualenv', \]) - function! ale#python#FindProjectRootIni(buffer) abort for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) if filereadable(l:path . '/MANIFEST.in') @@ -58,15 +58,26 @@ function! ale#python#FindVirtualenv(buffer) abort endif for l:dirname in ale#Var(a:buffer, 'virtualenv_dir_names') - let l:venv_dir = ale#path#Simplify(l:path . '/' . l:dirname) - - if filereadable(ale#path#Simplify(l:venv_dir . '/' . s:bin_dir . '/activate')) + let l:venv_dir = ale#path#Simplify( + \ join([l:path, l:dirname], s:sep) + \) + let l:script_filename = ale#path#Simplify( + \ join([l:venv_dir, s:bin_dir, 'activate'], s:sep) + \) + + if filereadable(l:script_filename) return l:venv_dir endif endfor endfor - return '' + return $VIRTUAL_ENV +endfunction + +" Run an executable check for Python scripts. +" On Windows, 1 will be returned if the file is merely readable. +function! ale#python#IsExecutable(path) abort + return has('win32') ? filereadable(a:path) : executable(a:path) endfunction " Given a buffer number and a command name, find the path to the executable. @@ -81,9 +92,11 @@ function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort if !empty(l:virtualenv) for l:path in a:path_list - let l:ve_executable = ale#path#Simplify(l:virtualenv . '/' . s:bin_dir . '/' . l:path) + let l:ve_executable = ale#path#Simplify( + \ join([l:virtualenv, s:bin_dir, l:path], s:sep) + \) - if executable(l:ve_executable) + if ale#python#IsExecutable(l:ve_executable) return l:ve_executable endif endfor diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim index b8d781dc..dc3c1109 100644 --- a/autoload/ale/sign.vim +++ b/autoload/ale/sign.vim @@ -214,24 +214,32 @@ function! s:BuildSignMap(current_sign_list, grouped_items) abort let l:sign_offset = g:ale_sign_offset for [l:line, l:sign_id, l:name] in a:current_sign_list - let l:sign_map[l:line] = { - \ 'current_id': l:sign_id, - \ 'current_name': l:name, + let l:sign_info = get(l:sign_map, l:line, { + \ 'current_id_list': [], + \ 'current_name_list': [], \ 'new_id': 0, \ 'new_name': '', \ 'items': [], - \} + \}) + " Increment the sign offset for new signs, by the maximum sign ID. if l:sign_id > l:sign_offset let l:sign_offset = l:sign_id endif + + " Remember the sign names and IDs in separate Lists, so they are easy + " to work with. + call add(l:sign_info.current_id_list, l:sign_id) + call add(l:sign_info.current_name_list, l:name) + + let l:sign_map[l:line] = l:sign_info endfor for l:group in a:grouped_items let l:line = l:group[0].lnum let l:sign_info = get(l:sign_map, l:line, { - \ 'current_id': 0, - \ 'current_name': '', + \ 'current_id_list': [], + \ 'current_name_list': [], \ 'new_id': 0, \ 'new_name': '', \ 'items': [], @@ -240,11 +248,18 @@ function! s:BuildSignMap(current_sign_list, grouped_items) abort let l:sign_info.new_name = ale#sign#GetSignName(l:group) let l:sign_info.items = l:group - if l:sign_info.current_name isnot# l:sign_info.new_name + let l:index = index( + \ l:sign_info.current_name_list, + \ l:sign_info.new_name + \) + + if l:index >= 0 + " We have a sign with this name already, so use the same ID. + let l:sign_info.new_id = l:sign_info.current_id_list[l:index] + else + " This sign name replaces the previous name, so use a new ID. let l:sign_info.new_id = l:sign_offset + 1 let l:sign_offset += 1 - else - let l:sign_info.new_id = l:sign_info.current_id endif let l:sign_map[l:line] = l:sign_info @@ -278,7 +293,7 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort let l:item.sign_id = l:info.new_id endfor - if l:info.new_id isnot l:info.current_id + if index(l:info.current_id_list, l:info.new_id) < 0 call add(l:command_list, 'sign place ' \ . (l:info.new_id) \ . ' line=' . l:line_str @@ -291,12 +306,14 @@ function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort " Remove signs without new IDs. for l:info in values(a:sign_map) - if l:info.current_id && l:info.current_id isnot l:info.new_id - call add(l:command_list, 'sign unplace ' - \ . (l:info.current_id) - \ . ' buffer=' . a:buffer - \) - endif + for l:current_id in l:info.current_id_list + if l:current_id isnot l:info.new_id + call add(l:command_list, 'sign unplace ' + \ . l:current_id + \ . ' buffer=' . a:buffer + \) + endif + endfor endfor " Remove the dummy sign to close the sign column if we need to. diff --git a/autoload/ale/test.vim b/autoload/ale/test.vim index 5fe4bed0..8fc4fe43 100644 --- a/autoload/ale/test.vim +++ b/autoload/ale/test.vim @@ -50,5 +50,5 @@ function! ale#test#SetFilename(path) abort \ ? a:path \ : l:dir . '/' . a:path - silent noautocmd execute 'file ' . fnameescape(ale#path#Winify(l:full_path)) + silent! noautocmd execute 'file ' . fnameescape(ale#path#Winify(l:full_path)) endfunction diff --git a/doc/ale-cmake.txt b/doc/ale-cmake.txt index c1356c9d..fb46336f 100644 --- a/doc/ale-cmake.txt +++ b/doc/ale-cmake.txt @@ -5,7 +5,7 @@ ALE CMake Integration *ale-cmake-options* =============================================================================== cmakelint *ale-cmake-cmakelint* -g:ale_cmake_cmakelint_exectuable *g:ale_cmake_cmakelint_executable* +g:ale_cmake_cmakelint_executable *g:ale_cmake_cmakelint_executable* *b:ale_cmake_cmakelint_executable* Type: |String| Default: `'cmakelint'` diff --git a/doc/ale-go.txt b/doc/ale-go.txt index 935f491f..c5a68878 100644 --- a/doc/ale-go.txt +++ b/doc/ale-go.txt @@ -21,6 +21,16 @@ while ensuring it doesn't run any linters known to be slow or resource intensive. =============================================================================== +gofmt *ale-go-gofmt* + +g:ale_go_gofmt_options *g:ale_go_gofmt_options* + *b:ale_go_gofmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the gofmt fixer. + +=============================================================================== gometalinter *ale-go-gometalinter* `gometalinter` is a `lint_file` linter, which only lints files that are diff --git a/doc/ale-llvm.txt b/doc/ale-llvm.txt new file mode 100644 index 00000000..2f4a46bd --- /dev/null +++ b/doc/ale-llvm.txt @@ -0,0 +1,19 @@ +=============================================================================== +ALE LLVM Integration *ale-llvm-options* + + +=============================================================================== +llc *ale-llvm-llc* + +g:ale_llvm_llc_executable *g:ale_llvm_llc_executable* + *b:ale_llvm_llc_executable* + + Type: |String| + Default: "llc" + + The command to use for checking. This variable is useful when llc command + has suffix like "llc-5.0". + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-php.txt b/doc/ale-php.txt index adaca08a..bae6d7d0 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -124,5 +124,13 @@ g:ale_php_phpstan_level *g:ale_php_phpstan_level* strictest. +g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration* + *b:ale_php_phpstan_configuration* + Type: |String| + Default: `''` + + This variable sets path to phpstan configuration file. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-rust.txt b/doc/ale-rust.txt index d03ab073..52dc3d61 100644 --- a/doc/ale-rust.txt +++ b/doc/ale-rust.txt @@ -20,7 +20,7 @@ Integration Information while you type. 3. rls -- If you have `rls` installed, you might prefer using this linter over cargo. rls implements the Language Server Protocol for incremental - compliation of Rust code, and can check Rust files while you type. `rls` + compilation of Rust code, and can check Rust files while you type. `rls` requires Rust files to contained in Cargo projects. Only cargo is enabled by default. To switch to using rustc instead of cargo, diff --git a/doc/ale.txt b/doc/ale.txt index fae91009..d202a264 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -62,6 +62,7 @@ CONTENTS *ale-contents* glsl..................................|ale-glsl-options| glslang.............................|ale-glsl-glslang| go....................................|ale-go-options| + gofmt...............................|ale-go-gofmt| gometalinter........................|ale-go-gometalinter| graphql...............................|ale-graphql-options| gqlint..............................|ale-graphql-gqlint| @@ -94,6 +95,8 @@ CONTENTS *ale-contents* kotlin................................|ale-kotlin-options| kotlinc.............................|ale-kotlin-kotlinc| ktlint..............................|ale-kotlin-ktlint| + llvm..................................|ale-llvm-options| + llc.................................|ale-llvm-llc| lua...................................|ale-lua-options| luacheck............................|ale-lua-luacheck| objc..................................|ale-objc-options| @@ -254,6 +257,7 @@ Notes: * JSON: `jsonlint`, `prettier` * Kotlin: `kotlinc`, `ktlint` * LaTeX (tex): `chktex`, `lacheck`, `proselint` +* LLVM: `llc` * Lua: `luacheck` * Markdown: `mdl`, `proselint`, `vale` * MATLAB: `mlint` @@ -608,7 +612,7 @@ g:ale_fixers *g:ale_fixers* A mapping from filetypes to |List| values for functions for fixing errors. See |ale-fix| for more information. - This variable can be overriden with variables in each buffer. + This variable can be overridden with variables in each buffer. g:ale_fix_on_save *g:ale_fix_on_save* @@ -1508,7 +1512,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* the end of the file will be moved to the end. `col` - The column number is optional and will default to `0`. Any strings will be automatically - coverted to number using `str2nr()`. + converted to number using `str2nr()`. `end_col` - An optional end column number. This key can be set to specify the column problems end on, for improved highlighting. @@ -1659,7 +1663,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* `project_callback` and `language_callback` arguments must also be defined. - LSP linters handle diagonstics automatically, so + LSP linters handle diagnostics automatically, so the `callback` argument must not be defined. `project_callback` A |String| or |Funcref| for a callback function @@ -1748,12 +1752,12 @@ ale#linter#Get(filetype) *ale#linter#Get()* Return all of linters configured for a given filetype as a |List| of |Dictionary| values in the format specified by |ale#linter#Define()|. - Filetypes may be dot-seperated to invoke linters for multiple filetypes: + Filetypes may be dot-separated to invoke linters for multiple filetypes: for instance, the filetype `javascript.jsx` will return linters for both the `javascript` and `jsx` filetype. Aliases may be defined in as described in |g:ale_linter_aliases|. Aliases - are applied after dot-seperated filetypes are broken up into their + are applied after dot-separated filetypes are broken up into their components. diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/activate b/test/command_callback/python_paths/with_virtualenv/env/Scripts/activate new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/activate diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/autopep8 b/test/command_callback/python_paths/with_virtualenv/env/Scripts/autopep8 new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/autopep8 diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/flake8 b/test/command_callback/python_paths/with_virtualenv/env/Scripts/flake8 new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/flake8 diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/isort b/test/command_callback/python_paths/with_virtualenv/env/Scripts/isort new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/isort diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/mypy b/test/command_callback/python_paths/with_virtualenv/env/Scripts/mypy new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/mypy diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/pylint b/test/command_callback/python_paths/with_virtualenv/env/Scripts/pylint new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/pylint diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/yapf b/test/command_callback/python_paths/with_virtualenv/env/Scripts/yapf new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/yapf diff --git a/test/command_callback/test_erlang_syntaxerl_command_callback.vader b/test/command_callback/test_erlang_syntaxerl_command_callback.vader index 1df2be39..a9a1a500 100644 --- a/test/command_callback/test_erlang_syntaxerl_command_callback.vader +++ b/test/command_callback/test_erlang_syntaxerl_command_callback.vader @@ -6,13 +6,11 @@ Before: runtime ale_linters/erlang/syntaxerl.vim - After: Restore call ale#linter#Reset() - Execute (The executable should be correct): AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) @@ -25,22 +23,32 @@ Execute (The executable should be correct): Execute (The executable should be presented in the feature check command): let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl' - AssertEqual "'/some/other/syntaxerl' -h", ale_linters#erlang#syntaxerl#FeatureCheck(bufnr('')) + + AssertEqual + \ ale#Escape('/some/other/syntaxerl') . ' -h', + \ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr('')) let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl' - AssertEqual "'/yet/another/syntaxerl' -h", ale_linters#erlang#syntaxerl#FeatureCheck(bufnr('')) + AssertEqual + \ ale#Escape('/yet/another/syntaxerl') . ' -h', + \ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr('')) Execute (The executable should be presented in the command): let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl' - AssertEqual "'/some/other/syntaxerl' %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), []) + + AssertEqual + \ ale#Escape('/some/other/syntaxerl') . ' %t', + \ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), []) let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl' - AssertEqual "'/yet/another/syntaxerl' %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), []) + AssertEqual + \ ale#Escape('/yet/another/syntaxerl') . ' %t', + \ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), []) Execute (The -b option should be used when available): - AssertEqual "'syntaxerl' %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [ + AssertEqual ale#Escape('syntaxerl') . ' %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [ \ 'Syntax checker for Erlang (0.14.0)', \ 'Usage: syntaxerl [-d | --debug] <FILENAME>', \ ' syntaxerl <-h | --help>', @@ -48,7 +56,7 @@ Execute (The -b option should be used when available): \ ' -h, --help Show this message', \ ]) - AssertEqual "'syntaxerl' -b %s %t", ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [ + AssertEqual ale#Escape('syntaxerl') . ' -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [ \ 'Syntax checker for Erlang (0.14.0)', \ 'Usage: syntaxerl [-b | --base <FILENAME>] [-d | --debug] <FILENAME>', \ ' syntaxerl <-h | --help>', diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader index c564b54f..a510f4c1 100644 --- a/test/command_callback/test_flake8_command_callback.vader +++ b/test/command_callback/test_flake8_command_callback.vader @@ -8,6 +8,8 @@ Before: unlet! g:ale_python_flake8_options unlet! g:ale_python_flake8_use_global + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + runtime ale_linters/python/flake8.vim call ale#test#SetDirectory('/testplugin/test/command_callback') @@ -16,6 +18,9 @@ After: unlet! g:ale_python_flake8_args + unlet! b:bin_dir + unlet! b:executable + call ale#test#RestoreDirectory() call ale#linter#Reset() call ale_linters#python#flake8#ClearVersionCache() @@ -25,26 +30,29 @@ Execute(The flake8 callbacks should return the correct default values): \ 'flake8', \ ale_linters#python#flake8#GetExecutable(bufnr('')) AssertEqual - \ '''flake8'' --version', + \ ale#Escape('flake8') . ' --version', \ ale_linters#python#flake8#VersionCheck(bufnr('')) AssertEqual - \ '''flake8'' --format=default --stdin-display-name %s -', + \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) " Try with older versions. call ale_linters#python#flake8#ClearVersionCache() AssertEqual - \ '''flake8'' --format=default -', + \ ale#Escape('flake8') . ' --format=default -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) Execute(The flake8 command callback should let you set options): let g:ale_python_flake8_options = '--some-option' AssertEqual - \ '''flake8'' --some-option --format=default --stdin-display-name %s -', + \ ale#Escape('flake8') + \ . ' --some-option --format=default' + \ . ' --stdin-display-name %s -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.4']) call ale_linters#python#flake8#ClearVersionCache() AssertEqual - \ '''flake8'' --some-option --format=default -', + \ ale#Escape('flake8') + \ . ' --some-option --format=default -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) Execute(You should be able to set a custom executable and it should be escaped): @@ -54,23 +62,29 @@ Execute(You should be able to set a custom executable and it should be escaped): \ 'executable with spaces', \ ale_linters#python#flake8#GetExecutable(bufnr('')) AssertEqual - \ '''executable with spaces'' --version', + \ ale#Escape('executable with spaces') . ' --version', \ ale_linters#python#flake8#VersionCheck(bufnr('')) AssertEqual - \ '''executable with spaces'' --format=default --stdin-display-name %s -', + \ ale#Escape('executable with spaces') + \ . ' --format=default' + \ . ' --stdin-display-name %s -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) Execute(The flake8 callbacks should detect virtualenv directories): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + let b:executable = ale#path#Winify( + \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/flake8' + \) + AssertEqual - \ g:dir . '/python_paths/with_virtualenv/env/bin/flake8', + \ b:executable, \ ale_linters#python#flake8#GetExecutable(bufnr('')) AssertEqual - \ '''' . g:dir . '/python_paths/with_virtualenv/env/bin/flake8'' --version', + \ ale#Escape(b:executable) . ' --version', \ ale_linters#python#flake8#VersionCheck(bufnr('')) AssertEqual - \ '''' . g:dir . '/python_paths/with_virtualenv/env/bin/flake8''' + \ ale#Escape(b:executable) \ . ' --format=default --stdin-display-name %s -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0']) @@ -78,35 +92,35 @@ Execute(The FindProjectRoot should detect the project root directory for namespa silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_manifest/namespace/foo/bar.py') AssertEqual - \ fnameescape(g:dir . '/python_paths/namespace_package_manifest'), + \ ale#path#Winify(g:dir . '/python_paths/namespace_package_manifest'), \ ale#python#FindProjectRoot(bufnr('')) Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf): silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_setup/namespace/foo/bar.py') AssertEqual - \ fnameescape(g:dir . '/python_paths/namespace_package_setup'), + \ ale#path#Winify(g:dir . '/python_paths/namespace_package_setup'), \ ale#python#FindProjectRoot(bufnr('')) Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini): silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_pytest/namespace/foo/bar.py') AssertEqual - \ fnameescape(g:dir . '/python_paths/namespace_package_pytest'), + \ ale#path#Winify(g:dir . '/python_paths/namespace_package_pytest'), \ ale#python#FindProjectRoot(bufnr('')) Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini): silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_tox/namespace/foo/bar.py') AssertEqual - \ fnameescape(g:dir . '/python_paths/namespace_package_tox'), + \ ale#path#Winify(g:dir . '/python_paths/namespace_package_tox'), \ ale#python#FindProjectRoot(bufnr('')) Execute(The FindProjectRoot should detect the project root directory for non-namespace package): silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py') AssertEqual - \ fnameescape(g:dir . '/python_paths/no_virtualenv/subdir'), + \ ale#path#Winify(g:dir . '/python_paths/no_virtualenv/subdir'), \ ale#python#FindProjectRoot(bufnr('')) " Some users currently run flake8 this way, so we should support it. @@ -120,10 +134,10 @@ Execute(Using `python -m flake8` should be supported for running flake8): \ 'python', \ ale_linters#python#flake8#GetExecutable(bufnr('')) AssertEqual - \ '''python'' -m flake8 --version', + \ ale#Escape('python') . ' -m flake8 --version', \ ale_linters#python#flake8#VersionCheck(bufnr('')) AssertEqual - \ '''python'' -m flake8 --some-option --format=default -', + \ ale#Escape('python') . ' -m flake8 --some-option --format=default -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) call ale_linters#python#flake8#ClearVersionCache() @@ -135,10 +149,10 @@ Execute(Using `python -m flake8` should be supported for running flake8): \ 'python', \ ale_linters#python#flake8#GetExecutable(bufnr('')) AssertEqual - \ '''python'' -m flake8 --version', + \ ale#Escape('python') . ' -m flake8 --version', \ ale_linters#python#flake8#VersionCheck(bufnr('')) AssertEqual - \ '''python'' -m flake8 --some-option --format=default -', + \ ale#Escape('python') . ' -m flake8 --some-option --format=default -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) Execute(Using `python2 -m flake8` should be use with the old args option): @@ -157,8 +171,8 @@ Execute(Using `python2 -m flake8` should be use with the old args option): \ 'python2', \ ale_linters#python#flake8#GetExecutable(bufnr('')) AssertEqual - \ '''python2'' -m flake8 --version', + \ ale#Escape('python2') . ' -m flake8 --version', \ ale_linters#python#flake8#VersionCheck(bufnr('')) AssertEqual - \ '''python2'' -m flake8 --format=default -', + \ ale#Escape('python2') . ' -m flake8 --format=default -', \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9']) diff --git a/test/command_callback/test_fusionlint_command_callback.vader b/test/command_callback/test_fusionlint_command_callback.vader index 5398066c..34a44133 100644 --- a/test/command_callback/test_fusionlint_command_callback.vader +++ b/test/command_callback/test_fusionlint_command_callback.vader @@ -1,24 +1,34 @@ Before: + Save g:ale_fuse_fusionlint_options + Save g:ale_fuse_fusionlint_executable + + unlet! g:ale_fuse_fusionlint_options + unlet! g:ale_fuse_fusionlint_executable + runtime ale_linters/fuse/fusionlint.vim After: + Restore + call ale#linter#Reset() - let g:ale_fuse_fusionlint_options = '' - let g:ale_fuse_fusionlint_executable = 'fusion-lint' Execute(The fuse fusionlint command callback should return the correct default string): - AssertEqual '''fusion-lint'' --filename %s -i', + AssertEqual ale#Escape('fusion-lint') . ' --filename %s -i', \ join(split(ale_linters#fuse#fusionlint#GetCommand(1))) Execute(The fuse fusionlint command callback should let you set options): let g:ale_fuse_fusionlint_options = '--example-option argument' - AssertEqual '''fusion-lint'' --example-option argument --filename %s -i', + AssertEqual + \ ale#Escape('fusion-lint') + \ . ' --example-option argument --filename %s -i', \ join(split(ale_linters#fuse#fusionlint#GetCommand(1))) Execute(The fusionlint executable should be configurable): let g:ale_fuse_fusionlint_executable = 'util/linter.fuse' AssertEqual 'util/linter.fuse', ale_linters#fuse#fusionlint#GetExecutable(1) - AssertEqual '''util/linter.fuse'' --filename %s -i', + AssertEqual + \ ale#Escape('util/linter.fuse') + \ . ' --filename %s -i', \ join(split(ale_linters#fuse#fusionlint#GetCommand(1))) diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader index 706839e4..8033e4f6 100644 --- a/test/command_callback/test_javac_command_callback.vader +++ b/test/command_callback/test_javac_command_callback.vader @@ -1,97 +1,151 @@ Before: + call ale#test#SetDirectory('/testplugin/test/command_callback') + + Save g:ale_java_javac_options + Save g:ale_java_javac_classpath + + unlet! g:ale_java_javac_options + unlet! g:ale_java_javac_classpath + + let g:cp_sep = has('unix') ? ':' : ';' + + function! GetCommand(previous_output) abort + let l:command = ale_linters#java#javac#GetCommand( + \ bufnr(''), + \ a:previous_output + \) + + let l:split_command = split(l:command) + let l:index = index(l:split_command, '-d') + + let l:split_command[l:index + 1] = 'TEMP' + + return join(l:split_command) + endfunction + runtime ale_linters/java/javac.vim call ale#engine#InitBufferInfo(bufnr('')) - silent! cd /testplugin/test/command_callback + call ale#test#SetFilename('dummy.java') After: + call ale#test#RestoreDirectory() + + Restore + + unlet! g:cp_sep + + delfunction GetCommand + call ale#linter#Reset() " We need to clean up the buffer to remove the temporary directories created " for the command. call ale#engine#Cleanup(bufnr('')) - let g:ale_java_javac_options = '' - let g:ale_java_javac_classpath = '' Execute(The javac callback should return the correct default value): - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), []) - - Assert match(b:command, '\v^javac +-Xlint +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual 'javac -Xlint -d TEMP %t', GetCommand([]) Execute(The javac callback should use g:ale_java_javac_classpath correctly): let g:ale_java_javac_classpath = 'foo.jar' - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), []) - - Assert match(b:command, '\v^javac +-Xlint +-cp ''+foo\.jar'' +-d ''+/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual + \ 'javac -Xlint' + \ . ' -cp ' . ale#Escape('foo.jar') + \ . ' -d TEMP %t', + \ GetCommand([]) Execute(The javac callback should include discovered classpaths): - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [ - \ '[DEBUG] Ignore this.', - \ '[INFO] Something we should ignore.', - \ '/foo/bar.jar', - \ '/xyz/abc.jar', - \]) - - Assert match(b:command, '\v^javac +-Xlint +-cp ''+/foo/bar\.jar:/xyz/abc\.jar'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual + \ 'javac -Xlint -cp ' + \ . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep)) + \ . ' -d TEMP %t', + \ GetCommand([ + \ '[DEBUG] Ignore this.', + \ '[INFO] Something we should ignore.', + \ '/foo/bar.jar', + \ '/xyz/abc.jar', + \ ]) Execute(The javac callback should combine discovered classpaths and manual ones): let g:ale_java_javac_classpath = 'configured.jar' - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [ - \ '[DEBUG] Ignore this.', - \ '[INFO] Something we should ignore.', - \ '/foo/bar.jar', - \ '/xyz/abc.jar', - \]) - - Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar:configured\.jar'' +-d ''+/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command - - let g:ale_java_javac_classpath = 'configured.jar:configured2.jar' - - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [ - \ '[DEBUG] Ignore this.', - \ '[INFO] Something we should ignore.', - \ '/foo/bar.jar', - \ '/xyz/abc.jar', - \]) - - Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar:configured\.jar:configured2\.jar'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual + \ 'javac -Xlint -cp ' + \ . ale#Escape(join( + \ [ + \ '/foo/bar.jar', + \ '/xyz/abc.jar', + \ 'configured.jar', + \ ], + \ g:cp_sep + \ )) + \ . ' -d TEMP %t', + \ GetCommand([ + \ '[DEBUG] Ignore this.', + \ '[INFO] Something we should ignore.', + \ '/foo/bar.jar', + \ '/xyz/abc.jar', + \ ]) + + let g:ale_java_javac_classpath = 'configured.jar' . g:cp_sep . 'configured2.jar' + + AssertEqual + \ 'javac -Xlint -cp ' + \ . ale#Escape(join( + \ [ + \ '/foo/bar.jar', + \ '/xyz/abc.jar', + \ 'configured.jar', + \ 'configured2.jar', + \ ], + \ g:cp_sep + \ )) + \ . ' -d TEMP %t', + \ GetCommand([ + \ '[DEBUG] Ignore this.', + \ '[INFO] Something we should ignore.', + \ '/foo/bar.jar', + \ '/xyz/abc.jar', + \ ]) Execute(The javac callback should detect source directories): call ale#engine#Cleanup(bufnr('')) :e! java_paths/src/main/java/com/something/dummy call ale#engine#InitBufferInfo(bufnr('')) - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), []) - - Assert match(b:command, '\v^javac +-Xlint +-sourcepath ''/.*java_paths/src/main/java/'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual + \ 'javac -Xlint' + \ . ' -sourcepath ' . ale#Escape( + \ ale#path#Winify(g:dir . '/java_paths/src/main/java/') + \ ) + \ . ' -d TEMP %t', + \ GetCommand([]) Execute(The javac callback should combine detected source directories and classpaths): call ale#engine#Cleanup(bufnr('')) - :e! java_paths/src/main/java/com/something/dummy + call ale#test#SetFilename('java_paths/src/main/java/com/something/dummy.java') call ale#engine#InitBufferInfo(bufnr('')) - let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [ - \ '[DEBUG] Ignore this.', - \ '[INFO] Something we should ignore.', - \ '/foo/bar.jar', - \ '/xyz/abc.jar', - \]) - - Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar'' +-sourcepath ''/.*java_paths/src/main/java/'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual + \ 'javac -Xlint' + \ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep)) + \ . ' -sourcepath ' . ale#Escape( + \ ale#path#Winify(g:dir . '/java_paths/src/main/java/') + \ ) + \ . ' -d TEMP %t', + \ GetCommand([ + \ '[DEBUG] Ignore this.', + \ '[INFO] Something we should ignore.', + \ '/foo/bar.jar', + \ '/xyz/abc.jar', + \ ]) Execute(The javac callback should use g:ale_java_javac_options correctly): - let g:ale_java_javac_options = '--anything --else' let b:command = ale_linters#java#javac#GetCommand(bufnr(''), []) - Assert match(b:command, '\v^javac +-Xlint +-d +''/tmp/[0-9a-zA-Z/]+'' --anything --else +\%t$') >= 0, - \ 'Invalid command string: ' . b:command + AssertEqual + \ 'javac -Xlint' + \ . ' -d TEMP --anything --else %t', + \ GetCommand([]) diff --git a/test/command_callback/test_jscs_command_callback.vader b/test/command_callback/test_jscs_command_callback.vader index 8245337e..f118c039 100644 --- a/test/command_callback/test_jscs_command_callback.vader +++ b/test/command_callback/test_jscs_command_callback.vader @@ -7,19 +7,19 @@ After: Execute(Should return the correct default values): AssertEqual - \ 'jscs', - \ ale_linters#javascript#jscs#GetExecutable(bufnr('')) + \ 'jscs', + \ ale_linters#javascript#jscs#GetExecutable(bufnr('')) AssertEqual - \ '''jscs'' --reporter inline --no-colors -', - \ ale_linters#javascript#jscs#GetCommand(bufnr('')) + \ ale#Escape('jscs') . ' --reporter inline --no-colors -', + \ ale_linters#javascript#jscs#GetCommand(bufnr('')) Execute(Should allow using a custom executable): let g:ale_javascript_jscs_executable = 'foobar' AssertEqual - \ 'foobar', - \ ale_linters#javascript#jscs#GetExecutable(bufnr('')) + \ 'foobar', + \ ale_linters#javascript#jscs#GetExecutable(bufnr('')) AssertEqual - \ '''foobar'' --reporter inline --no-colors -', - \ ale_linters#javascript#jscs#GetCommand(bufnr('')) + \ ale#Escape('foobar') . ' --reporter inline --no-colors -', + \ ale_linters#javascript#jscs#GetCommand(bufnr('')) diff --git a/test/command_callback/test_llc_command_callback.vader b/test/command_callback/test_llc_command_callback.vader new file mode 100644 index 00000000..296b277a --- /dev/null +++ b/test/command_callback/test_llc_command_callback.vader @@ -0,0 +1,39 @@ +Before: + Save g:ale_llvm_llc_executable + + unlet! g:ale_llvm_llc_executable + unlet! b:ale_llvm_llc_executable + + runtime ale_linters/llvm/llc.vim + + function! AssertHasPrefix(str, prefix) abort + let msg = printf("'%s' is expected to be prefixed with '%s'", a:str, a:prefix) + AssertEqual stridx(a:str, a:prefix), 0, msg + endfunction + +After: + unlet! g:ale_llvm_llc_executable + unlet! b:ale_llvm_llc_executable + delfunction AssertHasPrefix + Restore + +Execute(llc command is customizable): + let cmd = ale_linters#llvm#llc#GetCommand(bufnr('')) + call AssertHasPrefix(cmd, ale#Escape('llc')) + + let g:ale_llvm_llc_executable = 'llc-5.0' + let cmd = ale_linters#llvm#llc#GetCommand(bufnr('')) + call AssertHasPrefix(cmd, ale#Escape('llc-5.0')) + + let b:ale_llvm_llc_executable = 'llc-4.0' + let cmd = ale_linters#llvm#llc#GetCommand(bufnr('')) + call AssertHasPrefix(cmd, ale#Escape('llc-4.0')) + +Execute(GetCommand() escapes the returned path): + let b:ale_llvm_llc_executable = '/path/space contained/llc' + let cmd = ale_linters#llvm#llc#GetCommand(bufnr('')) + call AssertHasPrefix(cmd, ale#Escape('/path/space contained/llc')) + +Execute(GetExecutable() does not escape the returned path): + let b:ale_llvm_llc_executable = '/path/space contained/llc' + AssertEqual ale_linters#llvm#llc#GetExecutable(bufnr('')), '/path/space contained/llc' diff --git a/test/command_callback/test_luacheck_command_callback.vader b/test/command_callback/test_luacheck_command_callback.vader index c4ee98a8..6f7f3a00 100644 --- a/test/command_callback/test_luacheck_command_callback.vader +++ b/test/command_callback/test_luacheck_command_callback.vader @@ -7,18 +7,18 @@ After: let g:ale_lua_luacheck_executable = 'luacheck' Execute(The lua luacheck command callback should return the correct default string): - AssertEqual '''luacheck'' --formatter plain --codes --filename %s -', + AssertEqual ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -', \ join(split(ale_linters#lua#luacheck#GetCommand(1))) Execute(The lua luacheck command callback should let you set options): let g:ale_lua_luacheck_options = '--config filename' - AssertEqual '''luacheck'' --config filename --formatter plain --codes --filename %s -', + AssertEqual ale#Escape('luacheck') . ' --config filename --formatter plain --codes --filename %s -', \ join(split(ale_linters#lua#luacheck#GetCommand(1))) Execute(The luacheck executable should be configurable): let g:ale_lua_luacheck_executable = 'luacheck.sh' AssertEqual 'luacheck.sh', ale_linters#lua#luacheck#GetExecutable(1) - AssertEqual '''luacheck.sh'' --formatter plain --codes --filename %s -', + AssertEqual ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -', \ join(split(ale_linters#lua#luacheck#GetCommand(1))) diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader index 8df7193d..4ccc008e 100644 --- a/test/command_callback/test_mypy_command_callback.vader +++ b/test/command_callback/test_mypy_command_callback.vader @@ -1,20 +1,35 @@ Before: + Save g:ale_python_mypy_executable + Save g:ale_python_mypy_options + Save g:ale_python_mypy_use_global + + unlet! g:ale_python_mypy_executable + unlet! g:ale_python_mypy_options + unlet! g:ale_python_mypy_use_global + + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + runtime ale_linters/python/mypy.vim + call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetFilename('test.py') After: + Restore + + unlet! b:bin_dir + unlet! b:executable + call ale#test#RestoreDirectory() call ale#linter#Reset() - let g:ale_python_mypy_executable = 'mypy' - let g:ale_python_mypy_options = '' - let g:ale_python_mypy_use_global = 0 Execute(The mypy callbacks should return the correct default values): AssertEqual \ 'mypy', \ ale_linters#python#mypy#GetExecutable(bufnr('')) AssertEqual - \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers ' + \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy') + \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s', \ ale_linters#python#mypy#GetCommand(bufnr('')) @@ -25,7 +40,8 @@ Execute(The mypy executable should be configurable, and escaped properly): \ 'executable with spaces', \ ale_linters#python#mypy#GetExecutable(bufnr('')) AssertEqual - \ 'cd ''' . g:dir . ''' && ''executable with spaces'' --show-column-numbers ' + \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('executable with spaces') + \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s', \ ale_linters#python#mypy#GetCommand(bufnr('')) @@ -33,7 +49,8 @@ Execute(The mypy command callback should let you set options): let g:ale_python_mypy_options = '--some-option' AssertEqual - \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers --some-option ' + \ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy') + \ . ' --show-column-numbers --some-option ' \ . '--shadow-file %s %t %s', \ ale_linters#python#mypy#GetCommand(bufnr('')) @@ -44,19 +61,24 @@ Execute(The mypy command should switch directories to the detected project root) \ 'mypy', \ ale_linters#python#mypy#GetExecutable(bufnr('')) AssertEqual - \ 'cd ''' . g:dir . '/python_paths/no_virtualenv/subdir'' && ''mypy'' --show-column-numbers ' + \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/no_virtualenv/subdir')) + \ . ' && ' . ale#Escape('mypy') + \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s', \ ale_linters#python#mypy#GetCommand(bufnr('')) Execute(The mypy callbacks should detect virtualenv directories and switch to the project root): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + let b:executable = ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/mypy') + AssertEqual - \ g:dir . '/python_paths/with_virtualenv/env/bin/mypy', + \ b:executable, \ ale_linters#python#mypy#GetExecutable(bufnr('')) AssertEqual - \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && ''' - \ . g:dir . '/python_paths/with_virtualenv/env/bin/mypy'' --show-column-numbers ' + \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/subdir')) + \ . ' && ' . ale#Escape(b:executable) + \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s', \ ale_linters#python#mypy#GetCommand(bufnr('')) @@ -68,6 +90,8 @@ Execute(You should able able to use the global mypy instead): \ 'mypy', \ ale_linters#python#mypy#GetExecutable(bufnr('')) AssertEqual - \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && ''mypy'' --show-column-numbers ' + \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/subdir')) + \ . ' && ' . ale#Escape('mypy') + \ . ' --show-column-numbers ' \ . '--shadow-file %s %t %s', \ ale_linters#python#mypy#GetCommand(bufnr('')) diff --git a/test/command_callback/test_php_langserver_callbacks.vader b/test/command_callback/test_php_langserver_callbacks.vader index 38630f4b..0c7e69ef 100644 --- a/test/command_callback/test_php_langserver_callbacks.vader +++ b/test/command_callback/test_php_langserver_callbacks.vader @@ -33,13 +33,13 @@ Execute(Vendor executables should be detected): call ale#test#SetFilename('php-langserver-project/test.php') AssertEqual - \ g:dir . '/php-langserver-project/vendor/bin/php-language-server.php', + \ ale#path#Winify(g:dir . '/php-langserver-project/vendor/bin/php-language-server.php'), \ ale_linters#php#langserver#GetExecutable(bufnr('')) AssertEqual - \ 'php ' . ale#Escape( + \ 'php ' . ale#Escape(ale#path#Winify( \ g:dir \ . '/php-langserver-project/vendor/bin/php-language-server.php' - \ ), + \ )), \ ale_linters#php#langserver#GetCommand(bufnr('')) Execute(The language string should be correct): diff --git a/test/command_callback/test_phpstan_command_callbacks.vader b/test/command_callback/test_phpstan_command_callbacks.vader index 7366df8b..169c5bb7 100644 --- a/test/command_callback/test_phpstan_command_callbacks.vader +++ b/test/command_callback/test_phpstan_command_callbacks.vader @@ -1,9 +1,11 @@ Before: Save g:ale_php_phpstan_executable Save g:ale_php_phpstan_level + Save g:ale_php_phpstan_configuration unlet! g:ale_php_phpstan_executable unlet! g:ale_php_phpstan_level + unlet! g:ale_php_phpstan_configuration runtime ale_linters/php/phpstan.vim @@ -27,3 +29,10 @@ Execute(project with level set to 3): AssertEqual \ ale#Escape('phpstan') . ' analyze -l3 --errorFormat raw %s', \ ale_linters#php#phpstan#GetCommand(bufnr('')) + +Execute(Custom phpstan configuration file): + let g:ale_php_phpstan_configuration = 'phpstan_config' + + AssertEqual + \ ale#Escape('phpstan') . ' analyze -l4 --errorFormat raw -c phpstan_config %s', + \ ale_linters#php#phpstan#GetCommand(bufnr('')) diff --git a/test/command_callback/test_puglint_command_callback.vader b/test/command_callback/test_puglint_command_callback.vader index 6d189899..11946582 100644 --- a/test/command_callback/test_puglint_command_callback.vader +++ b/test/command_callback/test_puglint_command_callback.vader @@ -21,11 +21,12 @@ Execute(puglint should detect local executables and package.json): call ale#test#SetFilename('puglint_project/test.pug') AssertEqual - \ g:dir . '/puglint_project/node_modules/.bin/pug-lint', + \ ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'), \ ale_linters#pug#puglint#GetExecutable(bufnr('')) + AssertEqual - \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint') - \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/package.json') + \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/package.json')) \ . ' -r inline %t', \ ale_linters#pug#puglint#GetCommand(bufnr('')) @@ -35,9 +36,10 @@ Execute(puglint should use global executables if configured): call ale#test#SetFilename('puglint_project/test.pug') AssertEqual 'pug-lint', ale_linters#pug#puglint#GetExecutable(bufnr('')) + AssertEqual \ ale#Escape('pug-lint') - \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/package.json') + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/package.json')) \ . ' -r inline %t', \ ale_linters#pug#puglint#GetCommand(bufnr('')) @@ -45,8 +47,8 @@ Execute(puglint should detect .pug-lintrc): call ale#test#SetFilename('puglint_project/puglint_rc_dir/subdir/test.pug') AssertEqual - \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint') - \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/puglint_rc_dir/.pug-lintrc') + \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/puglint_rc_dir/.pug-lintrc')) \ . ' -r inline %t', \ ale_linters#pug#puglint#GetCommand(bufnr('')) @@ -54,8 +56,8 @@ Execute(puglint should detect .pug-lintrc.js): call ale#test#SetFilename('puglint_project/puglint_rc_js_dir/subdir/test.pug') AssertEqual - \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint') - \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/puglint_rc_js_dir/.pug-lintrc.js') + \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/puglint_rc_js_dir/.pug-lintrc.js')) \ . ' -r inline %t', \ ale_linters#pug#puglint#GetCommand(bufnr('')) @@ -63,7 +65,7 @@ Execute(puglint should detect .pug-lintrc.json): call ale#test#SetFilename('puglint_project/puglint_rc_json_dir/subdir/test.pug') AssertEqual - \ ale#Escape(g:dir . '/puglint_project/node_modules/.bin/pug-lint') - \ . ' -c ' . ale#Escape(g:dir . '/puglint_project/puglint_rc_json_dir/.pug-lintrc.json') + \ ale#Escape(ale#path#Winify(g:dir . '/puglint_project/node_modules/.bin/pug-lint')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/puglint_project/puglint_rc_json_dir/.pug-lintrc.json')) \ . ' -r inline %t', \ ale_linters#pug#puglint#GetCommand(bufnr('')) diff --git a/test/command_callback/test_pycodestyle_command_callback.vader b/test/command_callback/test_pycodestyle_command_callback.vader index a5163461..58aefa20 100644 --- a/test/command_callback/test_pycodestyle_command_callback.vader +++ b/test/command_callback/test_pycodestyle_command_callback.vader @@ -9,15 +9,17 @@ After: Restore Execute(The pycodestyle command callback should return default string): - AssertEqual '''pycodestyle'' -', + AssertEqual ale#Escape('pycodestyle') . ' -', \ ale_linters#python#pycodestyle#GetCommand(bufnr('')) Execute(The pycodestyle command callback should allow options): let g:ale_python_pycodestyle_options = '--exclude=test*.py' - AssertEqual '''pycodestyle'' --exclude=test*.py -', + + AssertEqual ale#Escape('pycodestyle') . ' --exclude=test*.py -', \ ale_linters#python#pycodestyle#GetCommand(bufnr('')) Execute(The pycodestyle executable should be configurable): let g:ale_python_pycodestyle_executable = '~/.local/bin/pycodestyle' - AssertEqual '''~/.local/bin/pycodestyle'' -', + + AssertEqual ale#Escape('~/.local/bin/pycodestyle') . ' -', \ ale_linters#python#pycodestyle#GetCommand(bufnr('')) diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader index f8f44ab6..447409b2 100644 --- a/test/command_callback/test_pylint_command_callback.vader +++ b/test/command_callback/test_pylint_command_callback.vader @@ -1,22 +1,34 @@ Before: + Save g:ale_python_pylint_executable + Save g:ale_python_pylint_options + Save g:ale_python_pylint_use_global + + unlet! g:ale_python_pylint_executable + unlet! g:ale_python_pylint_options + unlet! g:ale_python_pylint_use_global + runtime ale_linters/python/pylint.vim call ale#test#SetDirectory('/testplugin/test/command_callback') + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + let b:command_tail = ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' After: + Restore + call ale#test#RestoreDirectory() call ale#linter#Reset() - let g:ale_python_pylint_executable = 'pylint' - let g:ale_python_pylint_options = '' - let g:ale_python_pylint_use_global = 0 + + unlet! b:bin_dir + unlet! b:executable Execute(The pylint callbacks should return the correct default values): AssertEqual \ 'pylint', \ ale_linters#python#pylint#GetExecutable(bufnr('')) AssertEqual - \ '''pylint'' ' . b:command_tail, + \ ale#Escape('pylint') . ' ' . b:command_tail, \ ale_linters#python#pylint#GetCommand(bufnr('')) Execute(The pylint executable should be configurable, and escaped properly): @@ -26,14 +38,14 @@ Execute(The pylint executable should be configurable, and escaped properly): \ 'executable with spaces', \ ale_linters#python#pylint#GetExecutable(bufnr('')) AssertEqual - \ '''executable with spaces'' ' . b:command_tail, + \ ale#Escape('executable with spaces') . ' ' . b:command_tail, \ ale_linters#python#pylint#GetCommand(bufnr('')) Execute(The pylint command callback should let you set options): let g:ale_python_pylint_options = '--some-option' AssertEqual - \ '''pylint'' --some-option' . b:command_tail, + \ ale#Escape('pylint') . ' --some-option' . b:command_tail, \ ale_linters#python#pylint#GetCommand(bufnr('')) Execute(The pylint callbacks shouldn't detect virtualenv directories where they don't exist): @@ -43,17 +55,22 @@ Execute(The pylint callbacks shouldn't detect virtualenv directories where they \ 'pylint', \ ale_linters#python#pylint#GetExecutable(bufnr('')) AssertEqual - \ '''pylint'' ' . b:command_tail, + \ ale#Escape('pylint') . ' ' . b:command_tail, \ ale_linters#python#pylint#GetCommand(bufnr('')) Execute(The pylint callbacks should detect virtualenv directories): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + let b:executable = ale#path#Winify( + \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pylint' + \) + AssertEqual - \ g:dir . '/python_paths/with_virtualenv/env/bin/pylint', + \ b:executable, \ ale_linters#python#pylint#GetExecutable(bufnr('')) + AssertEqual - \ ''''. g:dir . '/python_paths/with_virtualenv/env/bin/pylint'' ' . b:command_tail, + \ ale#Escape(b:executable) . ' ' . b:command_tail, \ ale_linters#python#pylint#GetCommand(bufnr('')) Execute(You should able able to use the global pylint instead): @@ -64,5 +81,5 @@ Execute(You should able able to use the global pylint instead): \ 'pylint', \ ale_linters#python#pylint#GetExecutable(bufnr('')) AssertEqual - \ '''pylint'' ' . b:command_tail, + \ ale#Escape('pylint') . ' ' . b:command_tail, \ ale_linters#python#pylint#GetCommand(bufnr('')) diff --git a/test/command_callback/test_rails_best_practices_command_callback.vader b/test/command_callback/test_rails_best_practices_command_callback.vader index 09436be0..7305f4a6 100644 --- a/test/command_callback/test_rails_best_practices_command_callback.vader +++ b/test/command_callback/test_rails_best_practices_command_callback.vader @@ -7,36 +7,51 @@ Before: call ale#test#SetDirectory('/testplugin/test/command_callback') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb') + let b:args = '--silent -f json' + \ . ' --output-file ' . (has('win32') ? '%t' : '/dev/stdout') + let b:app_path = ale#path#Winify(g:dir . '/../ruby_fixtures/valid_rails_app') + let b:suffix = has('win32') ? '; type %t' : '' + After: Restore + unlet! b:args + unlet! b:app_path + unlet! b:suffix + call ale#test#RestoreDirectory() Execute(Executable should default to rails_best_practices): AssertEqual - \ '''rails_best_practices'' --silent -f json --output-file /dev/stdout ' - \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')), + \ ale#Escape('rails_best_practices') + \ . ' ' . b:args + \ . ' ' . ale#Escape(b:app_path) + \ . b:suffix, \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) Execute(Should be able to set a custom executable): let g:ale_ruby_rails_best_practices_executable = 'bin/rails_best_practices' AssertEqual - \ '''bin/rails_best_practices'' --silent -f json --output-file /dev/stdout ' - \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')), + \ ale#Escape('bin/rails_best_practices') + \ . ' ' . b:args + \ . ' ' . ale#Escape(b:app_path) + \ . b:suffix, \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) Execute(Setting bundle appends 'exec rails_best_practices'): let g:ale_ruby_rails_best_practices_executable = 'path to/bundle' AssertEqual - \ '''path to/bundle'' exec rails_best_practices --silent -f json --output-file /dev/stdout ' - \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')), + \ ale#Escape('path to/bundle') . ' exec rails_best_practices' + \ . ' ' . b:args + \ . ' ' . ale#Escape(b:app_path) + \ . b:suffix, \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) Execute(Command callback should be empty when not in a valid Rails app): call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/test.rb') AssertEqual - \ '', - \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) + \ '', + \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) diff --git a/test/command_callback/test_rubocop_command_callback.vader b/test/command_callback/test_rubocop_command_callback.vader index a88d453c..fddf7145 100644 --- a/test/command_callback/test_rubocop_command_callback.vader +++ b/test/command_callback/test_rubocop_command_callback.vader @@ -10,24 +10,30 @@ Before: After: Restore + call ale#linter#Reset() call ale#test#RestoreDirectory() Execute(Executable should default to rubocop): AssertEqual - \ '''rubocop'' --format json --force-exclusion --stdin ' - \ . ale#Escape(g:dir . '/dummy.rb'), + \ ale#Escape('rubocop') + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Winify(g:dir . '/dummy.rb')), \ ale_linters#ruby#rubocop#GetCommand(bufnr('')) Execute(Should be able to set a custom executable): let g:ale_ruby_rubocop_executable = 'bin/rubocop' + AssertEqual - \ '''bin/rubocop'' --format json --force-exclusion --stdin ' - \ . ale#Escape(g:dir . '/dummy.rb'), + \ ale#Escape('bin/rubocop') + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Winify(g:dir . '/dummy.rb')), \ ale_linters#ruby#rubocop#GetCommand(bufnr('')) Execute(Setting bundle appends 'exec rubocop'): let g:ale_ruby_rubocop_executable = 'path to/bundle' + AssertEqual - \ '''path to/bundle'' exec rubocop --format json --force-exclusion --stdin ' - \ . ale#Escape(g:dir . '/dummy.rb'), + \ ale#Escape('path to/bundle') . ' exec rubocop' + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Winify(g:dir . '/dummy.rb')), \ ale_linters#ruby#rubocop#GetCommand(bufnr('')) diff --git a/test/command_callback/test_rust_rls_callbacks.vader b/test/command_callback/test_rust_rls_callbacks.vader index 76e69927..b01f8f06 100644 --- a/test/command_callback/test_rust_rls_callbacks.vader +++ b/test/command_callback/test_rust_rls_callbacks.vader @@ -28,5 +28,5 @@ Execute(The project root should be detected correctly): call ale#test#SetFilename('rust-rls-project/test.rs') AssertEqual - \ g:dir . '/rust-rls-project', + \ ale#path#Winify(g:dir . '/rust-rls-project'), \ ale_linters#rust#rls#GetProjectRoot(bufnr('')) diff --git a/test/command_callback/test_scalastyle_command_callback.vader b/test/command_callback/test_scalastyle_command_callback.vader index f051b025..953d57b3 100644 --- a/test/command_callback/test_scalastyle_command_callback.vader +++ b/test/command_callback/test_scalastyle_command_callback.vader @@ -1,10 +1,16 @@ Before: + Save g:ale_scala_scalastyle_options + Save g:ale_scalastyle_config_loc + + unlet! g:ale_scala_scalastyle_options + unlet! g:ale_scalastyle_config_loc + runtime ale_linters/scala/scalastyle.vim After: + Restore + call ale#linter#Reset() - let g:ale_scala_scalastyle_options = '' - let g:ale_scalastyle_conf_loc = '' Execute(Should return the correct default command): AssertEqual @@ -15,13 +21,16 @@ Execute(Should allow using a custom config file): let g:ale_scalastyle_config_loc = '/dooper/config.xml' AssertEqual - \ 'scalastyle --config ''/dooper/config.xml'' %t', + \ 'scalastyle' + \ . ' --config ' . ale#Escape('/dooper/config.xml') + \ . ' %t', \ ale_linters#scala#scalastyle#GetCommand(bufnr('')) Execute(Should allow using custom options): let g:ale_scala_scalastyle_options = '--warnings false --quiet true' AssertEqual - \ 'scalastyle --config ''/dooper/config.xml'' --warnings false --quiet true %t', + \ 'scalastyle' + \ . ' --warnings false --quiet true' + \ . ' %t', \ ale_linters#scala#scalastyle#GetCommand(bufnr('')) - diff --git a/test/command_callback/test_slimlint_command_callback.vader b/test/command_callback/test_slimlint_command_callback.vader index 98fd9a83..d4dad4c4 100644 --- a/test/command_callback/test_slimlint_command_callback.vader +++ b/test/command_callback/test_slimlint_command_callback.vader @@ -9,8 +9,7 @@ After: Restore unlet! g:default_command - - let g:ale_has_override = {} + unlet! b:conf call ale#linter#Reset() call ale#test#RestoreDirectory() @@ -21,15 +20,20 @@ Execute(The default command should be correct): Execute(The command should have the .rubocop.yml prepended as an env var if one exists): call ale#test#SetFilename('../slimlint-test-files/subdir/file.slim') - AssertEqual - \ 'SLIM_LINT_RUBOCOP_CONF=''/testplugin/test/slimlint-test-files/.rubocop.yml'' ' . g:default_command, - \ ale_linters#slim#slimlint#GetCommand(bufnr('')) - -Execute(The command should have the .rubocop.yml prepended as an env var if one exists on win32): - call ale#test#SetFilename('../slimlint-test-files/subdir/file.slim') - - let g:ale_has_override['win32'] = 1 - - AssertEqual - \ 'set SLIM_LINT_RUBOCOP_CONF=''/testplugin/test/slimlint-test-files/.rubocop.yml'' && ' . g:default_command, - \ ale_linters#slim#slimlint#GetCommand(bufnr('')) + let b:conf = ale#path#Winify(g:dir . '/../slimlint-test-files/.rubocop.yml') + + if has('win32') + " Windows uses 'set var=... && command' + AssertEqual + \ 'set SLIM_LINT_RUBOCOP_CONF=' + \ . ale#Escape(b:conf) + \ . ' && ' . g:default_command, + \ ale_linters#slim#slimlint#GetCommand(bufnr('')) + else + " Unix uses 'var=... command' + AssertEqual + \ 'SLIM_LINT_RUBOCOP_CONF=' + \ . ale#Escape(b:conf) + \ . ' ' . g:default_command, + \ ale_linters#slim#slimlint#GetCommand(bufnr('')) + endif diff --git a/test/command_callback/test_standard_command_callback.vader b/test/command_callback/test_standard_command_callback.vader index 193ead83..279109e0 100644 --- a/test/command_callback/test_standard_command_callback.vader +++ b/test/command_callback/test_standard_command_callback.vader @@ -19,8 +19,6 @@ After: unlet! b:executable - let g:ale_has_override = {} - call ale#test#SetFilename('test.txt') call ale#test#RestoreDirectory() @@ -29,45 +27,36 @@ After: Execute(bin/cmd.js paths should be preferred): call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') - let b:executable = g:dir - \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + let b:executable = ale#path#Winify( + \ g:dir + \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + \) AssertEqual \ b:executable, \ ale_linters#javascript#standard#GetExecutable(bufnr('')) AssertEqual - \ ale#Escape(b:executable) . ' --stdin %s', + \ (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(b:executable) + \ . ' --stdin %s', \ ale_linters#javascript#standard#GetCommand(bufnr('')) Execute(.bin directories should be used too): call ale#test#SetFilename('standard-test-files/with-bin/testfile.js') - let b:executable = g:dir - \ . '/standard-test-files/with-bin/node_modules/.bin/standard' - - AssertEqual - \ b:executable, - \ ale_linters#javascript#standard#GetExecutable(bufnr('')) - - AssertEqual - \ ale#Escape(b:executable) . ' --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) - -Execute(.js files should be executed with node on Windows): - let g:ale_has_override['win32'] = 1 - - call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') - - let b:executable = g:dir - \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + let b:executable = ale#path#Winify( + \ g:dir + \ . '/standard-test-files/with-bin/node_modules/.bin/standard' + \) AssertEqual \ b:executable, \ ale_linters#javascript#standard#GetExecutable(bufnr('')) AssertEqual - \ ale#Escape('node.exe') . ' ' . ale#Escape(b:executable) . ' --stdin %s', + \ ale#Escape(b:executable) + \ . ' --stdin %s', \ ale_linters#javascript#standard#GetCommand(bufnr('')) Execute(The global executable should be used otherwise): diff --git a/test/command_callback/test_swaglint_command_callback.vader b/test/command_callback/test_swaglint_command_callback.vader index 5d04e923..379aa0cc 100644 --- a/test/command_callback/test_swaglint_command_callback.vader +++ b/test/command_callback/test_swaglint_command_callback.vader @@ -30,7 +30,12 @@ Execute(The yaml swaglint command callback should allow a global installation to Execute(The yaml swaglint command callback should allow a local installation to be used): call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml') - AssertEqual g:dir . '/swaglint_paths/node_modules/.bin/swaglint', + + AssertEqual + \ ale#path#Winify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'), \ ale_linters#yaml#swaglint#GetExecutable(bufnr('')) - AssertEqual g:dir . '/swaglint_paths/node_modules/.bin/swaglint -r compact --stdin', + + AssertEqual + \ ale#path#Winify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint') + \ . ' -r compact --stdin', \ ale_linters#yaml#swaglint#GetCommand(bufnr('')) diff --git a/test/command_callback/test_thrift_command_callback.vader b/test/command_callback/test_thrift_command_callback.vader index 43487f42..67008919 100644 --- a/test/command_callback/test_thrift_command_callback.vader +++ b/test/command_callback/test_thrift_command_callback.vader @@ -11,9 +11,17 @@ Before: function! GetCommand(buffer) abort call ale#engine#InitBufferInfo(a:buffer) - let l:result = ale_linters#thrift#thrift#GetCommand(a:buffer) + let l:command = ale_linters#thrift#thrift#GetCommand(a:buffer) call ale#engine#Cleanup(a:buffer) - return l:result + + let l:split_command = split(l:command) + let l:index = index(l:split_command, '-out') + + if l:index >= 0 + let l:split_command[l:index + 1] = 'TEMP' + endif + + return join(l:split_command) endfunction runtime ale_linters/thrift/thrift.vim @@ -34,28 +42,43 @@ Execute(The executable should be configurable): AssertEqual 'foobar', ale_linters#thrift#thrift#GetExecutable(bufnr('')) Execute(The executable should be used in the command): - Assert GetCommand(bufnr('%')) =~# "^'thrift'" + AssertEqual + \ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t', + \ GetCommand(bufnr('%')) let b:ale_thrift_thrift_executable = 'foobar' - Assert GetCommand(bufnr('%')) =~# "^'foobar'" + AssertEqual + \ ale#Escape('foobar') . ' --gen cpp -strict -out TEMP %t', + \ GetCommand(bufnr('%')) Execute(The list of generators should be configurable): - Assert GetCommand(bufnr('%')) =~# '--gen cpp' - let b:ale_thrift_thrift_generators = ['java', 'py:dynamic'] - Assert GetCommand(bufnr('%')) =~# '--gen java --gen py:dynamic' + + AssertEqual + \ ale#Escape('thrift') . ' --gen java --gen py:dynamic -strict -out TEMP %t', + \ GetCommand(bufnr('%')) let b:ale_thrift_thrift_generators = [] - Assert GetCommand(bufnr('%')) =~# '--gen cpp' -Execute(The list of include paths should be configurable): - Assert GetCommand(bufnr('%')) !~# '-I' + AssertEqual + \ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t', + \ GetCommand(bufnr('%')) +Execute(The list of include paths should be configurable): let b:ale_thrift_thrift_includes = ['included/path'] - Assert GetCommand(bufnr('%')) =~# '-I included/path' -Execute(The string of compiler options should be configurable): - Assert GetCommand(bufnr('%')) =~# '-strict' + AssertEqual + \ ale#Escape('thrift') + \ . ' --gen cpp' + \ . ' -I included/path' + \ . ' -strict -out TEMP %t', + \ GetCommand(bufnr('%')) +Execute(The string of compiler options should be configurable): let b:ale_thrift_thrift_options = '-strict --allow-64bit-consts' - Assert GetCommand(bufnr('%')) =~# '-strict --allow-64bit-consts' + + AssertEqual + \ ale#Escape('thrift') + \ . ' --gen cpp -strict --allow-64bit-consts' + \ . ' -out TEMP %t', + \ GetCommand(bufnr('%')) diff --git a/test/command_callback/test_tslint_command_callback.vader b/test/command_callback/test_tslint_command_callback.vader index 51567951..4ad42fa5 100644 --- a/test/command_callback/test_tslint_command_callback.vader +++ b/test/command_callback/test_tslint_command_callback.vader @@ -12,6 +12,7 @@ Before: runtime ale_linters/typescript/tslint.vim call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetFilename('test.ts') After: Restore @@ -23,7 +24,7 @@ After: Execute(The default tslint command should be correct): AssertEqual - \ 'cd ''' . expand('%:p:h') . ''' && ' + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'tslint --format json %t', \ ale_linters#typescript#tslint#GetCommand(bufnr('')) @@ -31,7 +32,7 @@ Execute(The rules directory option should be included if set): let b:ale_typescript_tslint_rules_dir = '/foo/bar' AssertEqual - \ 'cd ''' . expand('%:p:h') . ''' && ' + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'tslint --format json' \ . ' -r ' . ale#Escape('/foo/bar') \ . ' %t', diff --git a/test/command_callback/test_xmllint_command_callback.vader b/test/command_callback/test_xmllint_command_callback.vader index 7c0b1963..3cffde88 100644 --- a/test/command_callback/test_xmllint_command_callback.vader +++ b/test/command_callback/test_xmllint_command_callback.vader @@ -7,19 +7,19 @@ After: let g:ale_xml_xmllint_executable = 'xmllint' Execute(The xml xmllint command callback should return the correct default string): - AssertEqual '''xmllint'' --noout -', + AssertEqual ale#Escape('xmllint') . ' --noout -', \ join(split(ale_linters#xml#xmllint#GetCommand(1))) Execute(The xml xmllint command callback should let you set options): let g:ale_xml_xmllint_options = '--xinclude --postvalid' - AssertEqual '''xmllint'' --xinclude --postvalid --noout -', + AssertEqual ale#Escape('xmllint') . ' --xinclude --postvalid --noout -', \ join(split(ale_linters#xml#xmllint#GetCommand(1))) Execute(The xmllint executable should be configurable): let g:ale_xml_xmllint_executable = '~/.local/bin/xmllint' AssertEqual '~/.local/bin/xmllint', ale_linters#xml#xmllint#GetExecutable(1) - AssertEqual '''~/.local/bin/xmllint'' --noout -', + AssertEqual ale#Escape('~/.local/bin/xmllint') . ' --noout -', \ join(split(ale_linters#xml#xmllint#GetCommand(1))) diff --git a/test/fixers/test_autopep8_fixer_callback.vader b/test/fixers/test_autopep8_fixer_callback.vader index c8c0bd46..600fb194 100644 --- a/test/fixers/test_autopep8_fixer_callback.vader +++ b/test/fixers/test_autopep8_fixer_callback.vader @@ -11,9 +11,13 @@ Before: silent cd command_callback let g:dir = getcwd() + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + After: Restore + unlet! b:bin_dir + call ale#test#RestoreDirectory() Execute(The autopep8 callback should return the correct default values): @@ -23,7 +27,7 @@ Execute(The autopep8 callback should return the correct default values): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') AssertEqual - \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' -" }, + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' -'}, \ ale#fixers#autopep8#Fix(bufnr('')) Execute(The autopep8 callback should include options): @@ -31,5 +35,5 @@ Execute(The autopep8 callback should include options): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') AssertEqual - \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' --some-option -" }, + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' --some-option -' }, \ ale#fixers#autopep8#Fix(bufnr('')) diff --git a/test/fixers/test_elm_format_fixer_callback.vader b/test/fixers/test_elm_format_fixer_callback.vader index b8b9ed00..8552c5d5 100644 --- a/test/fixers/test_elm_format_fixer_callback.vader +++ b/test/fixers/test_elm_format_fixer_callback.vader @@ -15,7 +15,7 @@ Execute(The elm-format command should have default params): \ { \ 'read_temporary_file': 1, \ 'command': - \ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format')) + \ ale#Escape(ale#path#Winify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format')) \ . ' %t --yes', \ }, \ ale#fixers#format#Fix(bufnr('')) @@ -55,7 +55,7 @@ Execute(The elm-format command should manage empty options): \ { \ 'read_temporary_file': 1, \ 'command': - \ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format')) + \ ale#Escape(ale#path#Winify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format')) \ . ' %t', \ }, \ ale#fixers#format#Fix(bufnr('')) @@ -68,8 +68,7 @@ Execute(The elm-format command should manage custom options): \ { \ 'read_temporary_file': 1, \ 'command': - \ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format')) + \ ale#Escape(ale#path#Winify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format')) \ . ' %t --param1 --param2', \ }, \ ale#fixers#format#Fix(bufnr('')) - diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader index 21eb450d..d4783fc7 100644 --- a/test/fixers/test_eslint_fixer_callback.vader +++ b/test/fixers/test_eslint_fixer_callback.vader @@ -2,18 +2,17 @@ Before: call ale#test#SetDirectory('/testplugin/test/fixers') After: - let g:ale_has_override = {} call ale#test#RestoreDirectory() -Execute(The path to eslint.js should be run on Unix): +Execute(The executable path should be correct): call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js') AssertEqual \ { \ 'read_temporary_file': 1, - \ 'command': - \ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) - \ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js')) + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js')) \ . ' --fix %t', \ }, \ ale#fixers#eslint#Fix(bufnr('')) @@ -24,9 +23,9 @@ Execute(The lower priority configuration file in a nested directory should be pr AssertEqual \ { \ 'read_temporary_file': 1, - \ 'command': - \ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) - \ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/subdir-with-config/.eslintrc')) + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/subdir-with-config/.eslintrc')) \ . ' --fix %t', \ }, \ ale#fixers#eslint#Fix(bufnr('')) @@ -37,9 +36,9 @@ Execute(package.json should be used as a last resort): AssertEqual \ { \ 'read_temporary_file': 1, - \ 'command': - \ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) - \ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js')) + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js')) \ . ' --fix %t', \ }, \ ale#fixers#eslint#Fix(bufnr('')) @@ -50,8 +49,8 @@ Execute(package.json should be used as a last resort): \ { \ 'read_temporary_file': 1, \ 'command': - \ ale#Escape(simplify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint')) - \ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/package.json')) + \ ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint')) + \ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/package.json')) \ . ' --fix %t', \ }, \ ale#fixers#eslint#Fix(bufnr('')) diff --git a/test/fixers/test_gofmt_fixer_callback.vader b/test/fixers/test_gofmt_fixer_callback.vader new file mode 100644 index 00000000..14e6e063 --- /dev/null +++ b/test/fixers/test_gofmt_fixer_callback.vader @@ -0,0 +1,40 @@ +Before: + Save g:ale_go_gofmt_executable + Save g:ale_go_gofmt_options + + " Use an invalid global executable, so we don't match it. + let g:ale_go_gofmt_executable = 'xxxinvalid' + let g:ale_go_gofmt_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The gofmt callback should return the correct default values): + call ale#test#SetFilename('../go_files/testfile.go') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' -l -w' + \ . ' %t', + \ }, + \ ale#fixers#gofmt#Fix(bufnr('')) + +Execute(The gofmt callback should include custom gofmt options): + let g:ale_go_gofmt_options = "-r '(a) -> a'" + call ale#test#SetFilename('../go_files/testfile.go') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' -l -w' + \ . ' ' . g:ale_go_gofmt_options + \ . ' %t', + \ }, + \ ale#fixers#gofmt#Fix(bufnr('')) diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader index 437e2764..ea4426d1 100644 --- a/test/fixers/test_isort_fixer_callback.vader +++ b/test/fixers/test_isort_fixer_callback.vader @@ -9,9 +9,13 @@ Before: silent cd command_callback let g:dir = getcwd() + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + After: Restore + unlet! b:bin_dir + call ale#test#RestoreDirectory() Execute(The isort callback should return the correct default values): @@ -21,5 +25,5 @@ Execute(The isort callback should return the correct default values): silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') AssertEqual - \ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/isort' -" }, + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -' }, \ ale#fixers#isort#Fix(bufnr('')) diff --git a/test/fixers/test_phpcbf_fixer_callback.vader b/test/fixers/test_phpcbf_fixer_callback.vader index c2fe3a66..cf02a0b5 100644 --- a/test/fixers/test_phpcbf_fixer_callback.vader +++ b/test/fixers/test_phpcbf_fixer_callback.vader @@ -21,7 +21,7 @@ Execute(project with phpcbf should use local by default): call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') AssertEqual - \ g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf', + \ ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf'), \ ale#fixers#phpcbf#GetExecutable(bufnr('')) Execute(use-global should override local detection): @@ -43,7 +43,7 @@ Execute(The phpcbf callback should return the correct default values): call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') AssertEqual - \ {'command': ale#Escape(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf') . ' --stdin-path=%s ' }, + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' }, \ ale#fixers#phpcbf#Fix(bufnr('')) Execute(The phpcbf callback should include the phpcbf_standard option): @@ -51,6 +51,62 @@ Execute(The phpcbf callback should include the phpcbf_standard option): call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') AssertEqual - \ {'command': ale#Escape(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf') . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'}, + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'}, + \ ale#fixers#phpcbf#Fix(bufnr('')) + +Before: + Save g:ale_php_phpcbf_executable + Save g:ale_php_phpcbf_standard + Save g:ale_php_phpcbf_use_global + + let g:ale_php_phpcbf_executable = 'phpcbf_test' + let g:ale_php_phpcbf_standard = '' + let g:ale_php_phpcbf_use_global = 0 + + call ale#test#SetDirectory('/testplugin/test/fixers') + silent cd .. + silent cd command_callback + let g:dir = getcwd() + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(project with phpcbf should use local by default): + call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') + + AssertEqual + \ ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf'), + \ ale#fixers#phpcbf#GetExecutable(bufnr('')) + +Execute(use-global should override local detection): + let g:ale_php_phpcbf_use_global = 1 + call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') + + AssertEqual + \ 'phpcbf_test', + \ ale#fixers#phpcbf#GetExecutable(bufnr('')) + +Execute(project without phpcbf should use global): + call ale#test#SetFilename('php_paths/project-without-phpcbf/foo/test.php') + + AssertEqual + \ 'phpcbf_test', + \ ale#fixers#phpcbf#GetExecutable(bufnr('')) + +Execute(The phpcbf callback should return the correct default values): + call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') + + AssertEqual + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' }, + \ ale#fixers#phpcbf#Fix(bufnr('')) + +Execute(The phpcbf callback should include the phpcbf_standard option): + let g:ale_php_phpcbf_standard = 'phpcbf_ruleset.xml' + call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php') + + AssertEqual + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'}, \ ale#fixers#phpcbf#Fix(bufnr('')) diff --git a/test/fixers/test_prettier_eslint_fixer.callback.vader b/test/fixers/test_prettier_eslint_fixer.callback.vader index 56daf93f..b48a7085 100644 --- a/test/fixers/test_prettier_eslint_fixer.callback.vader +++ b/test/fixers/test_prettier_eslint_fixer.callback.vader @@ -56,7 +56,7 @@ Execute(Configuration files should be detected): \ 'command': \ ale#Escape('prettier-eslint') \ . ' %t' - \ . ' --eslint-config-path ' . ale#Escape(g:dir . '/eslint-test-files/react-app/.eslintrc.js') + \ . ' --eslint-config-path ' . ale#Escape(ale#path#Winify(g:dir . '/eslint-test-files/react-app/.eslintrc.js')) \ . ' --write' \ }, \ ale#fixers#prettier_eslint#Fix(bufnr('')) diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader index a684ad02..cc7d34d0 100644 --- a/test/fixers/test_prettier_fixer_callback.vader +++ b/test/fixers/test_prettier_fixer_callback.vader @@ -39,7 +39,7 @@ Execute(The prettier callback should include configuration files when the option \ 'command': ale#Escape(g:ale_javascript_prettier_executable) \ . ' %t' \ . ' --parser babylon' - \ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc')) + \ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/../prettier-test-files/with_config/.prettierrc')) \ . ' --write', \ }, \ ale#fixers#prettier#Fix(bufnr('')) @@ -54,7 +54,7 @@ Execute(The prettier callback should include custom prettier options): \ 'command': ale#Escape(g:ale_javascript_prettier_executable) \ . ' %t' \ . ' --no-semi --parser babylon' - \ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc')) + \ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/../prettier-test-files/with_config/.prettierrc')) \ . ' --write', \ }, \ ale#fixers#prettier#Fix(bufnr('')) diff --git a/test/fixers/test_puppetlint_fixer_callback.vader b/test/fixers/test_puppetlint_fixer_callback.vader index 04a85e56..224d72ab 100644 --- a/test/fixers/test_puppetlint_fixer_callback.vader +++ b/test/fixers/test_puppetlint_fixer_callback.vader @@ -21,7 +21,7 @@ Execute(The puppetlint callback should return the correct default values): AssertEqual \ {'read_temporary_file': 1, - \ 'command': "'" . g:ale_puppet_puppetlint_executable . "'" + \ 'command': ale#Escape(g:ale_puppet_puppetlint_executable) \ . ' ' . g:ale_puppet_puppetlint_options \ . ' --fix %t' }, \ ale#fixers#puppetlint#Fix(bufnr('')) diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader index 87d56d07..ff2ca965 100644 --- a/test/fixers/test_rubocop_fixer_callback.vader +++ b/test/fixers/test_rubocop_fixer_callback.vader @@ -34,7 +34,7 @@ Execute(The rubocop callback should include configuration files): \ { \ 'read_temporary_file': 1, \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) - \ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml') + \ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) \ . ' --auto-correct %t', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -47,7 +47,7 @@ Execute(The rubocop callback should include custom rubocop options): \ { \ 'read_temporary_file': 1, \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) - \ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml') + \ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) \ . ' --except Lint/Debugger' \ . ' --auto-correct %t', \ }, diff --git a/test/fixers/test_standard_fixer_callback.vader b/test/fixers/test_standard_fixer_callback.vader index 88169bbb..34c752db 100644 --- a/test/fixers/test_standard_fixer_callback.vader +++ b/test/fixers/test_standard_fixer_callback.vader @@ -2,31 +2,16 @@ Before: call ale#test#SetDirectory('/testplugin/test/fixers') After: - let g:ale_has_override = {} call ale#test#RestoreDirectory() -Execute(The path to standard.js should be run on Unix): +Execute(The executable path should be correct): call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js') AssertEqual \ { \ 'read_temporary_file': 1, - \ 'command': - \ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js')) - \ . ' --fix %t', - \ }, - \ ale#fixers#standard#Fix(bufnr('')) - -Execute(The standard fixer with standard.js should be run with node on Windows): - call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js') - let g:ale_has_override['win32'] = 1 - - " We have to execute the file with node. - AssertEqual - \ { - \ 'read_temporary_file': 1, - \ 'command': ale#Escape('node.exe') . ' ' - \ . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js')) + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js')) \ . ' --fix %t', \ }, \ ale#fixers#standard#Fix(bufnr('')) diff --git a/test/fixers/test_stylelint_fixer_callback.vader b/test/fixers/test_stylelint_fixer_callback.vader index 482704d4..a0fc6ff4 100644 --- a/test/fixers/test_stylelint_fixer_callback.vader +++ b/test/fixers/test_stylelint_fixer_callback.vader @@ -2,31 +2,16 @@ Before: call ale#test#SetDirectory('/testplugin/test/fixers') After: - let g:ale_has_override = {} call ale#test#RestoreDirectory() -Execute(The path to stylelint.js should be run on Unix): +Execute(The executable path should be correct): call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css') AssertEqual \ { \ 'read_temporary_file': 1, - \ 'command': - \ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) - \ . ' --fix %t', - \ }, - \ ale#fixers#stylelint#Fix(bufnr('')) - -Execute(The stylelint fixer with stylelint.js should be run with node on Windows): - call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css') - let g:ale_has_override['win32'] = 1 - - " We have to execute the file with node. - AssertEqual - \ { - \ 'read_temporary_file': 1, - \ 'command': ale#Escape('node.exe') . ' ' - \ . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) \ . ' --fix %t', \ }, \ ale#fixers#stylelint#Fix(bufnr('')) diff --git a/test/fixers/test_trim_whitespace.vader b/test/fixers/test_trim_whitespace.vader new file mode 100644 index 00000000..2ffbcb04 --- /dev/null +++ b/test/fixers/test_trim_whitespace.vader @@ -0,0 +1,28 @@ +Before: + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + call ale#test#RestoreDirectory() + +Execute(Should delete all whitespace at the end of different lines): + AssertEqual + \ [ + \ 'def foo():', + \ ' some_variable = this_is_a_longer_function(', + \ 'first_argument,', + \ ' second_argument,', + \ ' third_with_function_call(', + \ 'foo,', + \ ' 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,', + \ '))', + \ ]) diff --git a/test/fixers/test_yapf_fixer_callback.vader b/test/fixers/test_yapf_fixer_callback.vader index 6edc2678..e6075568 100644 --- a/test/fixers/test_yapf_fixer_callback.vader +++ b/test/fixers/test_yapf_fixer_callback.vader @@ -9,9 +9,13 @@ Before: silent cd command_callback let g:dir = getcwd() + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + After: Restore + unlet! b:bin_dir + call ale#test#RestoreDirectory() Execute(The yapf callback should return the correct default values): @@ -22,7 +26,7 @@ Execute(The yapf callback should return the correct default values): call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py') AssertEqual - \ {'command': ale#Escape(g:dir . '/python_paths/with_virtualenv/env/bin/yapf')}, + \ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yapf'))}, \ ale#fixers#yapf#Fix(bufnr('')) \ Execute(The yapf should include the .style.yapf file if present): @@ -31,8 +35,8 @@ Execute(The yapf should include the .style.yapf file if present): AssertEqual \ { \ 'command': - \ ale#Escape(g:dir . '/python_paths/with_virtualenv/env/bin/yapf') + \ ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yapf')) \ . ' --no-local-style' - \ . ' --style ' . ale#Escape(g:dir . '/python_paths/with_virtualenv/dir_with_yapf_config/.style.yapf'), + \ . ' --style ' . ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/dir_with_yapf_config/.style.yapf')), \ }, \ ale#fixers#yapf#Fix(bufnr('')) diff --git a/test/go_files/testfile.go b/test/go_files/testfile.go new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/go_files/testfile.go diff --git a/test/handler/test_flow_handler.vader b/test/handler/test_flow_handler.vader index 5037fcb1..47efc30d 100644 --- a/test/handler/test_flow_handler.vader +++ b/test/handler/test_flow_handler.vader @@ -260,7 +260,7 @@ Execute(The flow handler should handle relative paths): \ "descr": "React element `Foo`", \ "type": "Blame", \ "loc": { - \ "source": "vim-ale-flow/index.js", + \ "source": expand('%:p'), \ "type": "SourceFile", \ "start": { \ "line": 6, @@ -273,7 +273,7 @@ Execute(The flow handler should handle relative paths): \ "offset": 108 \ } \ }, - \ "path": "vim-ale-flow/index.js", + \ "path": expand('%:p'), \ "line": 6, \ "endline": 6, \ "start": 3, @@ -318,7 +318,7 @@ Execute(The flow handler should handle relative paths): \ "descr": "props of React element `Foo`", \ "type": "Blame", \ "loc": { - \ "source": "vim-ale-flow/index.js", + \ "source": expand('%:p'), \ "type": "SourceFile", \ "start": { \ "line": 6, @@ -331,7 +331,7 @@ Execute(The flow handler should handle relative paths): \ "offset": 108 \ } \ }, - \ "path": "vim-ale-flow/index.js", + \ "path": expand('%:p'), \ "line": 6, \ "endline": 6, \ "start": 3, diff --git a/test/handler/test_idris_handler.vader b/test/handler/test_idris_handler.vader index b1fb2a01..6a032ea6 100644 --- a/test/handler/test_idris_handler.vader +++ b/test/handler/test_idris_handler.vader @@ -12,7 +12,11 @@ After: call ale#linter#Reset() Execute(The idris handler should parse messages that reference a single column): - call ale#test#SetFilename('/tmp/foo.idr') + if has('win32') + call ale#test#SetFilename($TEMP . '\foo.idr') + else + call ale#test#SetFilename('/tmp/foo.idr') + endif AssertEqual \ [ @@ -24,21 +28,21 @@ Execute(The idris handler should parse messages that reference a single column): \ } \ ], \ ale_linters#idris#idris#Handle(bufnr(''), [ - \ '/tmp/foo.idr:4:5:', - \ 'When checking right hand side of main with expected type', - \ ' IO ()', - \ '', - \ 'When checking an application of function Prelude.Monad.>>=:', - \ ' Type mismatch between', - \ ' IO () (Type of putStrLn _)', - \ ' and', - \ ' _ -> _ (Is putStrLn _ applied to too many arguments?)', - \ '', - \ ' Specifically:', - \ ' Type mismatch between', - \ ' IO', - \ ' and', - \ ' \uv => _ -> uv', + \ expand('%:p') . ':4:5:', + \ 'When checking right hand side of main with expected type', + \ ' IO ()', + \ '', + \ 'When checking an application of function Prelude.Monad.>>=:', + \ ' Type mismatch between', + \ ' IO () (Type of putStrLn _)', + \ ' and', + \ ' _ -> _ (Is putStrLn _ applied to too many arguments?)', + \ '', + \ ' Specifically:', + \ ' Type mismatch between', + \ ' IO', + \ ' and', + \ ' \uv => _ -> uv', \ ]) Execute(The idris handler should parse messages that reference a column range): @@ -54,9 +58,9 @@ Execute(The idris handler should parse messages that reference a column range): \ } \ ], \ ale_linters#idris#idris#Handle(bufnr(''), [ - \ '/tmp/foo.idr:11:11-13:', - \ 'When checking right hand side of Main.case block in main at /tmp/foo.idr:10:10 with expected type', - \ ' IO ()', - \ '', - \ 'Last statement in do block must be an expression', + \ expand('%:p') . ':11:11-13:', + \ 'When checking right hand side of Main.case block in main at /tmp/foo.idr:10:10 with expected type', + \ ' IO ()', + \ '', + \ 'Last statement in do block must be an expression', \ ]) diff --git a/test/handler/test_llc_handler.vader b/test/handler/test_llc_handler.vader new file mode 100644 index 00000000..edea2337 --- /dev/null +++ b/test/handler/test_llc_handler.vader @@ -0,0 +1,56 @@ +Before: + runtime! ale_linters/llvm/llc.vim + +Execute(llc handler should parse errors output for STDIN): + AssertEqual + \ [ + \ { + \ 'lnum': 10, + \ 'col': 7, + \ 'text': "error: value doesn't match function result type 'i32'", + \ 'type': 'E', + \ }, + \ { + \ 'lnum': 10, + \ 'col': 13, + \ 'text': "error: use of undefined value '@foo'", + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#llvm#llc#HandleErrors(bufnr(''), [ + \ "llc: <stdin>:10:7: error: value doesn't match function result type 'i32'", + \ 'ret i64 0', + \ ' ^', + \ '', + \ "llc: <stdin>:10:13: error: use of undefined value '@foo'", + \ 'call void @foo(i64 %0)', + \ ' ^', + \ ]) + +Execute(llc handler should parse errors output for some file): + call ale#test#SetFilename('test.ll') + AssertEqual + \ [ + \ { + \ 'lnum': 10, + \ 'col': 7, + \ 'text': "error: value doesn't match function result type 'i32'", + \ 'type': 'E', + \ }, + \ { + \ 'lnum': 10, + \ 'col': 13, + \ 'text': "error: use of undefined value '@foo'", + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#llvm#llc#HandleErrors(bufnr(''), [ + \ "llc: /path/to/test.ll:10:7: error: value doesn't match function result type 'i32'", + \ 'ret i64 0', + \ ' ^', + \ '', + \ "llc: /path/to/test.ll:10:13: error: use of undefined value '@foo'", + \ 'call void @foo(i64 %0)', + \ ' ^', + \ ]) + diff --git a/test/handler/test_mcsc_handler.vader b/test/handler/test_mcsc_handler.vader index a65185ca..5f4c133c 100644 --- a/test/handler/test_mcsc_handler.vader +++ b/test/handler/test_mcsc_handler.vader @@ -19,21 +19,21 @@ Execute(The mcs handler should handle cannot find symbol errors): \ 'col' : 29, \ 'text': 'error CS1001: ; expected', \ 'type': 'E', - \ 'filename': '/home/foo/project/bar/Test.cs' + \ 'filename': ale#path#Winify('/home/foo/project/bar/Test.cs', 'add_drive'), \ }, \ { \ 'lnum': 101, \ 'col': 0, \ 'text': 'error CS1028: Unexpected processor directive (no #if for this #endif)', \ 'type': 'E', - \ 'filename': '/home/foo/project/bar/Test.cs' + \ 'filename': ale#path#Winify('/home/foo/project/bar/Test.cs', 'add_drive'), \ }, \ { \ 'lnum': 10, \ 'col': 12, \ 'text': 'warning CS0123: some warning', \ 'type': 'W', - \ 'filename': '/home/foo/project/bar/Test.cs' + \ 'filename': ale#path#Winify('/home/foo/project/bar/Test.cs', 'add_drive'), \ }, \ ], \ ale_linters#cs#mcsc#Handle(347, [ diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader index 69ae91ce..36f34e16 100644 --- a/test/sign/test_sign_placement.vader +++ b/test/sign/test_sign_placement.vader @@ -269,3 +269,14 @@ Execute(It should be possible to clear signs with empty lists): Execute(No exceptions should be thrown when setting signs for invalid buffers): call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}]) + +Execute(Signs should be removed when lines have multiple sign IDs on them): + " We can fail to remove signs if there are multiple signs on one line, + " say after deleting lines in Vim, etc. + exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('') + exec 'sign place 1000348 line=3 name=ALEWarningSign buffer=' . bufnr('') + exec 'sign place 1000349 line=10 name=ALEErrorSign buffer=' . bufnr('') + exec 'sign place 1000350 line=10 name=ALEWarningSign buffer=' . bufnr('') + + call ale#sign#SetSigns(bufnr(''), []) + AssertEqual [], ParseSigns() diff --git a/test/test_lint_error_delay.vader b/test/test_lint_error_delay.vader index 4c7f0947..7f081794 100644 --- a/test/test_lint_error_delay.vader +++ b/test/test_lint_error_delay.vader @@ -17,10 +17,6 @@ Execute(ALE should stop linting for a while after exceptions are thrown): AssertThrows call ale#Lint() call ale#Lint() -Execute(ALE should stop queuing echo messages for a while after exceptions are thrown): - AssertThrows call ale#cursor#EchoCursorWarningWithDelay() - call ale#cursor#EchoCursorWarningWithDelay() - Execute(ALE should stop echoing messages for a while after exceptions are thrown): AssertThrows call ale#cursor#EchoCursorWarning() call ale#cursor#EchoCursorWarning() diff --git a/test/test_linter_retrieval.vader b/test/test_linter_retrieval.vader index afb540d6..1a1e2580 100644 --- a/test/test_linter_retrieval.vader +++ b/test/test_linter_retrieval.vader @@ -97,7 +97,7 @@ Execute (The local alias option shouldn't completely replace the global one): call ale#linter#Define('testft1', g:testlinter1) call ale#linter#Define('testft2', g:testlinter2) let g:ale_linter_aliases = {'testft1': ['testft1', 'testft2']} - " This is a key set for a differnt filetype. + " This is a key set for a different filetype. " We should look for a key in this Dictionary first, and then check the " global Dictionary. let b:ale_linter_aliases = {'testft3': ['testft1']} diff --git a/test/test_python_virtualenv.vader b/test/test_python_virtualenv.vader new file mode 100644 index 00000000..b44c5fa2 --- /dev/null +++ b/test/test_python_virtualenv.vader @@ -0,0 +1,12 @@ +Before: + Save $VIRTUAL_ENV + let $VIRTUAL_ENV = "/opt/example/" + +After: + Restore + +Execute(ale#python#FindVirtualenv falls back to $VIRTUAL_ENV when no directories match): + AssertEqual + \ ale#python#FindVirtualenv(bufnr('%')), + \ '/opt/example/', + \ 'Expected VIRTUAL_ENV environment variable to be used, but it was not' diff --git a/test/test_statusline.vader b/test/test_statusline.vader index 7978a509..0ce1d36f 100644 --- a/test/test_statusline.vader +++ b/test/test_statusline.vader @@ -88,7 +88,7 @@ Execute (Count should be match the loclist): \ 'total': 15, \}, ale#statusline#Count(bufnr('')) -Execute (Output should be empty for non-existant buffer): +Execute (Output should be empty for non-existent buffer): AssertEqual Counts({}), ale#statusline#Count(9001) Execute (Status() should return just errors for the old format): |