summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.appveyor.yml3
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--README.md9
-rw-r--r--ale_linters/php/phpmd.vim2
-rw-r--r--autoload/ale/engine.vim4
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/mix_format.vim16
-rw-r--r--autoload/ale/gradle.vim15
-rw-r--r--doc/ale-elixir.txt17
-rw-r--r--doc/ale-python.txt2
-rw-r--r--doc/ale.txt2
-rw-r--r--test/command_callback/test_dartanalyzer_command_callback.vader2
-rw-r--r--test/elixir-test-files/testfile.ex0
-rw-r--r--test/fixers/test_mix_format_fixer_callback.vader20
-rw-r--r--test/handler/test_php_phpmd_handler.vader24
-rw-r--r--test/test_ale_fix.vader140
-rw-r--r--test/test_ale_info.vader4
-rw-r--r--test/test_ale_lint_command.vader10
-rw-r--r--test/test_ale_toggle.vader2
-rw-r--r--test/test_c_import_paths.vader72
-rw-r--r--test/test_command_chain.vader10
-rw-r--r--test/test_csslint_config_detection.vader2
-rw-r--r--test/test_elm_executable_detection.vader2
-rw-r--r--test/test_errors_removed_after_filetype_changed.vader7
-rw-r--r--test/test_eslint_executable_detection.vader8
-rw-r--r--test/test_find_nearest_directory.vader2
-rw-r--r--test/test_flow_command.vader8
-rw-r--r--test/test_format_command.vader45
-rw-r--r--test/test_format_temporary_file_creation.vader4
-rw-r--r--test/test_get_abspath.vader4
-rw-r--r--test/test_gradle_build_classpath_command.vader39
-rw-r--r--test/test_gradle_find_executable.vader24
-rw-r--r--test/test_gradle_find_project_root.vader6
-rw-r--r--test/test_highlight_placement.vader2
-rw-r--r--test/test_history_saving.vader5
-rw-r--r--test/test_lint_on_enter_when_file_changed.vader7
36 files changed, 365 insertions, 161 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index f6e7d5d3..54113953 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -36,4 +36,5 @@ install:
test_script:
- cd C:\testplugin
- - 'C:\vim\vim\vim80\vim.exe -u test\vimrc "+Vader! test/test_path_uri.vader"'
+ - 'C:\vim\vim\vim80\vim.exe -u test\vimrc "+Vader!
+ test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader"'
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8df52844..26129564 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -129,7 +129,7 @@ giving some unfair preference to any particular tool or language.
The "online documentation" file used for this project lives in `doc/ale.txt`.
This is the file used for generating `:help` text inside Vim itself. There are
-some guidlines to follow for this file.
+some guidelines to follow for this file.
1. Keep all text within a column size of 79 characters, inclusive.
2. Open a section with 79 `=` or `-` characters, for headings and subheadings.
diff --git a/README.md b/README.md
index df5ba225..813b429f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
-# Asynchronous Lint Engine [![Build Status](https://travis-ci.org/w0rp/ale.svg?branch=master)](https://travis-ci.org/w0rp/ale)
+# Asynchronous Lint Engine [![Travis CI Build Status](https://travis-ci.org/w0rp/ale.svg?branch=master)](https://travis-ci.org/w0rp/ale) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/w0rp/ale?svg=true)](https://ci.appveyor.com/project/w0rp/ale)
+
![ALE Logo by Mark Grealish - https://www.bhalash.com/](img/logo.jpg?raw=true)
@@ -413,11 +414,11 @@ See `:help ale#statusline#Count()` for more information.
### 5.v. How can I show errors or warnings in my lightline?
-[lightline](https://github.com/itchyny/lightline.vim) does not have built-in
+[lightline](https://github.com/itchyny/lightline.vim) does not have built-in
support for ALE, nevertheless it's easy to do it yourself:
```vim
-" This is regular lightline configuration, we just added
+" This is regular lightline configuration, we just added
" 'linter_warnings', 'linter_errors' and 'linter_ok' to
" the active right panel. Feel free to move it anywhere.
" `component_expand' and `component_type' are required.
@@ -467,7 +468,7 @@ function! LightlineLinterOK() abort
endfunction
```
-See `:help ale#statusline#Count()` and [lightline documentation](https://github.com/itchyny/lightline.vim#advanced-configuration)
+See `:help ale#statusline#Count()` and [lightline documentation](https://github.com/itchyny/lightline.vim#advanced-configuration)
for more information.
<a name="faq-echo-format"></a>
diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim
index 29d8103a..e4192c70 100644
--- a/ale_linters/php/phpmd.vim
+++ b/ale_linters/php/phpmd.vim
@@ -14,7 +14,7 @@ function! ale_linters#php#phpmd#Handle(buffer, lines) abort
" Matches against lines like the following:
"
" /path/to/some-filename.php:18 message
- let l:pattern = '^.*:\(\d\+\)\t\(.\+\)$'
+ let l:pattern = '^.*:\(\d\+\)\s\+\(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 890d3df2..1b22df46 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -841,7 +841,7 @@ function! ale#engine#WaitForJobs(deadline) abort
" Gather all of the jobs from every buffer.
for l:info in values(g:ale_buffer_info)
- call extend(l:job_list, l:info.job_list)
+ call extend(l:job_list, get(l:info, 'job_list', []))
endfor
" NeoVim has a built-in API for this, so use that.
@@ -889,7 +889,7 @@ function! ale#engine#WaitForJobs(deadline) abort
" Check again to see if any jobs are running.
for l:info in values(g:ale_buffer_info)
- for l:job_id in l:info.job_list
+ for l:job_id in get(l:info, 'job_list', [])
if ale#job#IsRunning(l:job_id)
let l:has_new_jobs = 1
break
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 07daa402..e17521f4 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -27,6 +27,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['javascript', 'typescript'],
\ 'description': 'Apply eslint --fix to a file.',
\ },
+\ 'mix_format': {
+\ 'function': 'ale#fixers#mix_format#Fix',
+\ 'suggested_filetypes': ['elixir'],
+\ 'description': 'Apply mix format to a file.',
+\ },
\ 'format': {
\ 'function': 'ale#fixers#format#Fix',
\ 'suggested_filetypes': ['elm'],
diff --git a/autoload/ale/fixers/mix_format.vim b/autoload/ale/fixers/mix_format.vim
new file mode 100644
index 00000000..04866408
--- /dev/null
+++ b/autoload/ale/fixers/mix_format.vim
@@ -0,0 +1,16 @@
+" Author: carakan <carakan@gmail.com>
+" Description: Fixing files with elixir formatter 'mix format'.
+
+call ale#Set('elixir_mix_executable', 'mix')
+
+function! ale#fixers#mix_format#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'elixir_mix_executable')
+endfunction
+
+function! ale#fixers#mix_format#Fix(buffer) abort
+ return {
+ \ 'command': ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer))
+ \ . ' format %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
diff --git a/autoload/ale/gradle.vim b/autoload/ale/gradle.vim
index 89b56a82..dc377fb9 100644
--- a/autoload/ale/gradle.vim
+++ b/autoload/ale/gradle.vim
@@ -2,20 +2,30 @@
" Description: Functions for working with Gradle projects.
let s:script_path = fnamemodify(resolve(expand('<sfile>:p')), ':h')
+let s:init_path = has('win32')
+\ ? s:script_path . '\gradle\init.gradle'
+\ : s:script_path . '/gradle/init.gradle'
+
+function! ale#gradle#GetInitPath() abort
+ return s:init_path
+endfunction
" Given a buffer number, find a Gradle project root.
function! ale#gradle#FindProjectRoot(buffer) abort
let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew')
+
if !empty(l:gradlew_path)
return fnamemodify(l:gradlew_path, ':h')
endif
let l:settings_path = ale#path#FindNearestFile(a:buffer, 'settings.gradle')
+
if !empty(l:settings_path)
return fnamemodify(l:settings_path, ':h')
endif
let l:build_path = ale#path#FindNearestFile(a:buffer, 'build.gradle')
+
if !empty(l:build_path)
return fnamemodify(l:build_path, ':h')
endif
@@ -28,6 +38,7 @@ endfunction
" command. Returns an empty string if cannot find the executable.
function! ale#gradle#FindExecutable(buffer) abort
let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew')
+
if !empty(l:gradlew_path)
return l:gradlew_path
endif
@@ -47,7 +58,9 @@ function! ale#gradle#BuildClasspathCommand(buffer) abort
if !empty(l:executable) && !empty(l:project_root)
return ale#path#CdString(l:project_root)
- \ . l:executable . ' -I ' . s:script_path . '/gradle/init.gradle -q printClasspath'
+ \ . ale#Escape(l:executable)
+ \ . ' -I ' . ale#Escape(s:init_path)
+ \ . ' -q printClasspath'
endif
return ''
diff --git a/doc/ale-elixir.txt b/doc/ale-elixir.txt
new file mode 100644
index 00000000..a5318c0f
--- /dev/null
+++ b/doc/ale-elixir.txt
@@ -0,0 +1,17 @@
+===============================================================================
+ALE Elixir Integration *ale-elixir-options*
+
+
+===============================================================================
+mix *ale-elixir-mix*
+
+g:ale_elixir_mix_options *g:ale_elixir_mix_options*
+ *b:ale_elixir_mix_options*
+ Type: |String|
+ Default: `'mix'`
+
+
+ This variable can be changed to specify the mix executable.
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index a8d033e2..755094a3 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -174,7 +174,7 @@ g:ale_python_pylint_options *g:ale_python_pylint_options*
Python 3, you may want to set >
let g:ale_python_pylint_executable = 'python3' " or 'python' for Python 2
- let g:ale_python_pylint_options = '-rcfile /path/to/pylint.rc'
+ let g:ale_python_pylint_options = '--rcfile /path/to/pylint.rc'
" The virtualenv detection needs to be disabled.
let g:ale_python_pylint_use_global = 0
diff --git a/doc/ale.txt b/doc/ale.txt
index acf64289..47b95438 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -48,6 +48,8 @@ CONTENTS *ale-contents*
dartanalyzer........................|ale-dart-dartanalyzer|
dockerfile............................|ale-dockerfile-options|
hadolint............................|ale-dockerfile-hadolint|
+ elixir................................|ale-elixir-options|
+ mix.................................|ale-elixir-mix|
elm...................................|ale-elm-options|
elm-format..........................|ale-elm-elm-format|
elm-make............................|ale-elm-elm-make|
diff --git a/test/command_callback/test_dartanalyzer_command_callback.vader b/test/command_callback/test_dartanalyzer_command_callback.vader
index c26028de..dbd8290c 100644
--- a/test/command_callback/test_dartanalyzer_command_callback.vader
+++ b/test/command_callback/test_dartanalyzer_command_callback.vader
@@ -35,6 +35,6 @@ Execute(The .packages file should be set if detected):
AssertEqual
\ ale#Escape('dartanalyzer')
- \ . ' --packages ' . ale#Escape(g:dir . '/dart_paths/.packages')
+ \ . ' --packages ' . ale#Escape(ale#path#Winify(g:dir . '/dart_paths/.packages'))
\ . ' %t',
\ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
diff --git a/test/elixir-test-files/testfile.ex b/test/elixir-test-files/testfile.ex
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/elixir-test-files/testfile.ex
diff --git a/test/fixers/test_mix_format_fixer_callback.vader b/test/fixers/test_mix_format_fixer_callback.vader
new file mode 100644
index 00000000..c6c97c57
--- /dev/null
+++ b/test/fixers/test_mix_format_fixer_callback.vader
@@ -0,0 +1,20 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ Save g:ale_elixir_mix_executable
+
+ let g:ale_elixir_mix_executable = 'xxxinvalid'
+
+After:
+ call ale#test#RestoreDirectory()
+
+Execute(The mix_format callback should return the correct default values):
+ call ale#test#SetFilename('../elixir-test-files/testfile.ex')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' format %t',
+ \ },
+ \ ale#fixers#mix_format#Fix(bufnr(''))
+
diff --git a/test/handler/test_php_phpmd_handler.vader b/test/handler/test_php_phpmd_handler.vader
new file mode 100644
index 00000000..be36f3db
--- /dev/null
+++ b/test/handler/test_php_phpmd_handler.vader
@@ -0,0 +1,24 @@
+Before:
+ runtime ale_linters/php/phpmd.vim
+
+Execute(The php static analyzer handler should parse errors from phpmd):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 22,
+ \ 'type': 'W',
+ \ 'text': "Avoid unused local variables such as '$response'.",
+ \ },
+ \ {
+ \ 'lnum': 14,
+ \ 'type': 'W',
+ \ 'text': "The method test uses an else expression. Else is never necessary and you can simplify the code to work without else.",
+ \ },
+ \ ],
+ \ ale_linters#php#phpmd#Handle(347, [
+ \ "example.php:22 Avoid unused local variables such as '$response'.",
+ \ "example.php:14 The method test uses an else expression. Else is never necessary and you can simplify the code to work without else.",
+ \ ])
+
+After:
+ call ale#linter#Reset()
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader
index b5c16724..9968c4a5 100644
--- a/test/test_ale_fix.vader
+++ b/test/test_ale_fix.vader
@@ -11,11 +11,18 @@ Before:
let g:ale_enabled = 0
let g:ale_echo_cursor = 0
let g:ale_run_synchronously = 1
+ let g:ale_set_lists_synchronously = 1
let g:ale_fix_buffer_data = {}
let g:ale_fixers = {
\ 'testft': [],
\}
- let &shell = '/bin/bash'
+
+ if !has('win32')
+ let &shell = '/bin/bash'
+ endif
+
+ call ale#test#SetDirectory('/testplugin/test')
+ call ale#test#SetFilename('test.txt')
function AddCarets(buffer, lines) abort
" map() is applied to the original lines here.
@@ -67,6 +74,7 @@ Before:
After:
Restore
unlet! g:ale_run_synchronously
+ unlet! g:ale_set_lists_synchronously
unlet! g:ale_emulate_job_failure
unlet! b:ale_fixers
delfunction AddCarets
@@ -79,6 +87,9 @@ After:
delfunction RemoveLastLineOneArg
delfunction TestCallback
delfunction SetUpLinters
+
+ call ale#test#RestoreDirectory()
+
call ale#fix#registry#ResetToDefaults()
call ale#linter#Reset()
@@ -129,8 +140,13 @@ Expect(Only the second function should be applied):
$c
Execute(ALEFix should allow commands to be run):
- let g:ale_fixers.testft = ['CatLine']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['a', 'b', 'c', 'd'])
+ else
+ let g:ale_fixers.testft = ['CatLine']
+ ALEFix
+ endif
Expect(An extra line should be added):
a
@@ -139,22 +155,39 @@ Expect(An extra line should be added):
d
Execute(ALEFix should allow temporary files to be read):
- let g:ale_fixers.testft = ['ReplaceWithTempFile']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['x'])
+ 2,3d
+ else
+ let g:ale_fixers.testft = ['ReplaceWithTempFile']
+ ALEFix
+ endif
Expect(The line we wrote to the temporary file should be used here):
x
Execute(ALEFix should allow jobs and simple functions to be combined):
- let g:ale_fixers.testft = ['ReplaceWithTempFile', 'AddDollars']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['$x'])
+ 2,3d
+ else
+ let g:ale_fixers.testft = ['ReplaceWithTempFile', 'AddDollars']
+ ALEFix
+ endif
Expect(The lines from the temporary file should be modified):
$x
Execute(ALEFix should send lines modified by functions to jobs):
- let g:ale_fixers.testft = ['AddDollars', 'CatLine']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['$a', '$b', '$c', 'd'])
+ else
+ let g:ale_fixers.testft = ['AddDollars', 'CatLine']
+ ALEFix
+ endif
Expect(The lines should first be modified by the function, then the job):
$a
@@ -257,18 +290,20 @@ Execute(ALEFix should save files on the save event):
AssertEqual ['$a', '$b', '$c'], readfile('fix_test_file')
Assert !&modified, 'The was marked as ''modified'''
- " We have run the linter.
- AssertEqual [{
- \ 'bufnr': bufnr('%'),
- \ 'lnum': 1,
- \ 'vcol': 0,
- \ 'col': 1,
- \ 'text': 'xxx',
- \ 'type': 'E',
- \ 'nr': -1,
- \ 'pattern': '',
- \ 'valid': 1,
- \}], getloclist(0)
+ if !has('win32')
+ " We should have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], getloclist(0)
+ endif
Expect(The buffer should be modified):
$a
@@ -294,18 +329,20 @@ Execute(ALEFix should still lint with no linters to be applied):
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
- " We have run the linter.
- AssertEqual [{
- \ 'bufnr': bufnr('%'),
- \ 'lnum': 1,
- \ 'vcol': 0,
- \ 'col': 1,
- \ 'text': 'xxx',
- \ 'type': 'E',
- \ 'nr': -1,
- \ 'pattern': '',
- \ 'valid': 1,
- \}], getloclist(0)
+ if !has('win32')
+ " We have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], getloclist(0)
+ endif
Expect(The buffer should be the same):
a
@@ -326,18 +363,20 @@ Execute(ALEFix should still lint when nothing was fixed on save):
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
- " We have run the linter.
- AssertEqual [{
- \ 'bufnr': bufnr('%'),
- \ 'lnum': 1,
- \ 'vcol': 0,
- \ 'col': 1,
- \ 'text': 'xxx',
- \ 'type': 'E',
- \ 'nr': -1,
- \ 'pattern': '',
- \ 'valid': 1,
- \}], getloclist(0)
+ if !has('win32')
+ " We should have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], getloclist(0)
+ endif
Expect(The buffer should be the same):
a
@@ -358,7 +397,7 @@ Execute(ale#fix#InitBufferData() should set up the correct data):
\ bufnr(''): {
\ 'temporary_directory_list': [],
\ 'vars': b:,
- \ 'filename': simplify(getcwd() . '/fix_test_file'),
+ \ 'filename': ale#path#Winify(getcwd() . '/fix_test_file'),
\ 'done': 0,
\ 'lines_before': ['a', 'b', 'c'],
\ 'should_save': 1,
@@ -374,8 +413,13 @@ Expect(There should be only two lines):
b
Execute(ALEFix functions returning jobs should be able to accept one argument):
- let g:ale_fixers.testft = ['CatLine']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['a', 'b', 'c', 'd'])
+ else
+ let g:ale_fixers.testft = ['CatLine']
+ ALEFix
+ endif
Expect(An extra line should be added):
a
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 8ab5ad54..ceb65af6 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -354,7 +354,7 @@ Execute (ALEInfo command history should print command output if logging is on):
Execute (ALEInfo should include executable checks in the history):
call ale#linter#Define('testft', g:testlinter1)
- call ale#engine#IsExecutable(bufnr(''), 'echo')
+ call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call CheckInfo([
@@ -365,6 +365,6 @@ Execute (ALEInfo should include executable checks in the history):
\ '',
\] + g:globals_lines + g:command_header + [
\ '',
- \ '(executable check - success) echo',
+ \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
\ '(executable check - failure) TheresNoWayThisIsExecutable',
\])
diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader
index 42554ec1..d36b2177 100644
--- a/test/test_ale_lint_command.vader
+++ b/test/test_ale_lint_command.vader
@@ -28,7 +28,7 @@ Before:
\ 'lnum': 2,
\ 'vcol': 0,
\ 'col': 3,
- \ 'text': a:output[0],
+ \ 'text': join(split(a:output[0])),
\ 'type': 'E',
\ 'nr': -1,
\}]
@@ -37,7 +37,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo foo bar',
\})
@@ -63,5 +63,11 @@ Execute(ALELint should run the linters):
ALELint
call ale#engine#WaitForJobs(2000)
+ if !has('nvim')
+ " Sleep so the delayed list function can run.
+ " This breaks the tests in NeoVim for some reason.
+ sleep 1ms
+ endif
+
" Check the loclist
AssertEqual g:expected_loclist, getloclist(0)
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index f5d8599f..f3dbf102 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -67,7 +67,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo',
\ 'read_buffer': 0,
\})
diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader
index dac73f08..af185eae 100644
--- a/test/test_c_import_paths.vader
+++ b/test/test_c_import_paths.vader
@@ -39,8 +39,8 @@ Execute(The C GCC handler should include 'include' directories for projects with
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -52,8 +52,8 @@ Execute(The C GCC handler should include 'include' directories for projects with
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -65,8 +65,8 @@ Execute(The C GCC handler should include root directories for projects with .h f
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -78,8 +78,8 @@ Execute(The C GCC handler should include root directories for projects with .hpp
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -91,8 +91,8 @@ Execute(The C Clang handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -104,8 +104,8 @@ Execute(The C Clang handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -117,8 +117,8 @@ Execute(The C Clang handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -130,8 +130,8 @@ Execute(The C Clang handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -143,8 +143,8 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -156,8 +156,8 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -169,8 +169,8 @@ Execute(The C++ GCC handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -182,8 +182,8 @@ Execute(The C++ GCC handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -195,8 +195,8 @@ Execute(The C++ Clang handler should include 'include' directories for projects
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -208,8 +208,8 @@ Execute(The C++ Clang handler should include 'include' directories for projects
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -221,8 +221,8 @@ Execute(The C++ Clang handler should include root directories for projects with
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -234,8 +234,8 @@ Execute(The C++ Clang handler should include root directories for projects with
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -255,8 +255,8 @@ Execute(The C++ Clang handler shoud use the include directory based on the .git
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/git_and_nested_makefiles/src') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/git_and_nested_makefiles/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -267,8 +267,8 @@ Execute(The C++ ClangTidy handler should include json folders for projects with
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s '
- \ . '-p ' . ale#Escape(g:dir . '/test_c_projects/json_project/build')
+ \ . ' -checks=' . ale#Escape('*') . ' %s '
+ \ . '-p ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/json_project') . '/build')
\ , ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(Move .git/HEAD back):
diff --git a/test/test_command_chain.vader b/test/test_command_chain.vader
index 16472041..9059d630 100644
--- a/test/test_command_chain.vader
+++ b/test/test_command_chain.vader
@@ -1,7 +1,11 @@
Before:
Save &shell, g:ale_run_synchronously
let g:ale_run_synchronously = 1
- set shell=/bin/sh
+
+ if !has('win32')
+ set shell=/bin/sh
+ endif
+
let g:linter_output = []
let g:first_echo_called = 0
let g:second_echo_called = 0
@@ -9,7 +13,7 @@ Before:
function! CollectResults(buffer, output)
let g:final_callback_called = 1
- let g:linter_output = a:output
+ let g:linter_output = map(copy(a:output), 'join(split(v:val))')
return []
endfunction
function! RunFirstEcho(buffer)
@@ -26,7 +30,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'CollectResults',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command_chain': [
\ {
\ 'callback': 'RunFirstEcho',
diff --git a/test/test_csslint_config_detection.vader b/test/test_csslint_config_detection.vader
index b4707dc0..d84a00f9 100644
--- a/test/test_csslint_config_detection.vader
+++ b/test/test_csslint_config_detection.vader
@@ -13,7 +13,7 @@ Execute(--config should be set when the .csslintrc file is found):
AssertEqual
\ (
\ 'csslint --format=compact '
- \ . '--config=' . shellescape(g:dir . '/csslint-test-files/some-app/.csslintrc')
+ \ . '--config=' . ale#Escape(ale#path#Winify(g:dir . '/csslint-test-files/some-app/.csslintrc'))
\ . ' %t'
\ ),
\ ale_linters#css#csslint#GetCommand(bufnr(''))
diff --git a/test/test_elm_executable_detection.vader b/test/test_elm_executable_detection.vader
index 7b758fc2..cca8a6e4 100644
--- a/test/test_elm_executable_detection.vader
+++ b/test/test_elm_executable_detection.vader
@@ -12,7 +12,7 @@ Execute(should get valid executable with default params):
call ale#test#SetFilename('elm-test-files/app/testfile.elm')
AssertEqual
- \ g:dir . '/elm-test-files/app/node_modules/.bin/elm-make',
+ \ ale#path#Winify(g:dir . '/elm-test-files/app/node_modules/.bin/elm-make'),
\ ale_linters#elm#make#GetExecutable(bufnr(''))
Execute(should get valid executable with 'use_global' params):
diff --git a/test/test_errors_removed_after_filetype_changed.vader b/test/test_errors_removed_after_filetype_changed.vader
index 0498a501..92d248d0 100644
--- a/test/test_errors_removed_after_filetype_changed.vader
+++ b/test/test_errors_removed_after_filetype_changed.vader
@@ -13,7 +13,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'buffer_linter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
+ \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
@@ -21,7 +21,7 @@ Before:
call ale#linter#Define('foobar2', {
\ 'name': 'buffer_linter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
+ \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
@@ -41,12 +41,14 @@ After:
Execute(Error should be removed when the filetype changes to something else we cannot check):
call ale#Queue(0)
+ sleep 1ms
AssertEqual 1, len(getloclist(0))
noautocmd let &filetype = 'foobar2'
call ale#Queue(0)
+ sleep 1ms
" We should get some items from the second filetype.
AssertEqual 1, len(getloclist(0))
@@ -54,5 +56,6 @@ Execute(Error should be removed when the filetype changes to something else we c
noautocmd let &filetype = 'xxx'
call ale#Queue(0)
+ sleep 1ms
AssertEqual 0, len(getloclist(0))
diff --git a/test/test_eslint_executable_detection.vader b/test/test_eslint_executable_detection.vader
index 411fa134..ee792421 100644
--- a/test/test_eslint_executable_detection.vader
+++ b/test/test_eslint_executable_detection.vader
@@ -17,7 +17,7 @@ Execute(create-react-app directories should be detected correctly):
call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
AssertEqual
- \ g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js',
+ \ ale#path#Winify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'),
\ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(use-global should override create-react-app detection):
@@ -33,7 +33,7 @@ Execute(other app directories should be detected correctly):
call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
AssertEqual
- \ g:dir . '/eslint-test-files/node_modules/.bin/eslint',
+ \ ale#path#Winify(g:dir . '/eslint-test-files/node_modules/.bin/eslint'),
\ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(use-global should override other app directories):
@@ -49,7 +49,7 @@ Execute(eslint_d should be detected correctly):
call ale#test#SetFilename('eslint-test-files/app-with-eslint-d/testfile.js')
AssertEqual
- \ g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d',
+ \ ale#path#Winify(g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'),
\ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(eslint.js executables should be run with node on Windows):
@@ -59,6 +59,6 @@ Execute(eslint.js executables should be run with node on Windows):
" We have to execute the file with node.
AssertEqual
\ ale#Escape('node.exe') . ' '
- \ . ale#Escape(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
+ \ . ale#Escape(ale#path#Winify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -f unix --stdin --stdin-filename %s',
\ ale#handlers#eslint#GetCommand(bufnr(''))
diff --git a/test/test_find_nearest_directory.vader b/test/test_find_nearest_directory.vader
index 03d38862..1442c8fc 100644
--- a/test/test_find_nearest_directory.vader
+++ b/test/test_find_nearest_directory.vader
@@ -8,7 +8,7 @@ Execute(We should be able to find a directory some directory down):
call ale#test#SetFilename('top/middle/bottom/dummy.txt')
AssertEqual
- \ expand('%:p:h:h:h:h') . '/top/ale-special-directory-name-dont-use-this-please/',
+ \ ale#path#Winify(expand('%:p:h:h:h:h') . '/top/ale-special-directory-name-dont-use-this-please/'),
\ ale#path#FindNearestDirectory(bufnr('%'), 'ale-special-directory-name-dont-use-this-please')
Execute(We shouldn't find anything for files which don't match):
diff --git a/test/test_flow_command.vader b/test/test_flow_command.vader
index d9842869..32ceb57c 100644
--- a/test/test_flow_command.vader
+++ b/test/test_flow_command.vader
@@ -9,13 +9,17 @@ After:
Execute(flow should return a command to run if a .flowconfig file exists):
call ale#test#SetFilename('flow/a/sub/dummy')
- AssertEqual '''flow'' check-contents --respect-pragma --json --from ale %s', ale_linters#javascript#flow#GetCommand(bufnr('%'), [])
+ AssertEqual
+ \ ale#Escape('flow')
+ \ . ' check-contents --respect-pragma --json --from ale %s',
+ \ ale_linters#javascript#flow#GetCommand(bufnr('%'), [])
Execute(flow should should not use --respect-pragma for old versions):
call ale#test#SetFilename('flow/a/sub/dummy')
AssertEqual
- \ '''flow'' check-contents --json --from ale %s',
+ \ ale#Escape('flow')
+ \ . ' check-contents --json --from ale %s',
\ ale_linters#javascript#flow#GetCommand(bufnr('%'), [
\ 'Warning: `flow --version` is deprecated in favor of `flow version`',
\ 'Flow, a static type checker for JavaScript, version 0.27.0',
diff --git a/test/test_format_command.vader b/test/test_format_command.vader
index 156ced9b..f6143a5a 100644
--- a/test/test_format_command.vader
+++ b/test/test_format_command.vader
@@ -2,10 +2,18 @@ Before:
silent! cd /testplugin/test
silent file top/middle/bottom/dummy.txt
+ function! CheckTempFile(filename) abort
+ " Check every part of the temporary filename, except the random part.
+ AssertEqual fnamemodify(tempname(), ':h'), fnamemodify(a:filename, ':h:h')
+ AssertEqual 'dummy.txt', fnamemodify(a:filename, ':t')
+ endfunction
+
After:
unlet! g:result
unlet! g:match
+ delfunction CheckTempFile
+
Execute(FormatCommand should do nothing to basic command strings):
AssertEqual ['', 'awesome-linter do something'], ale#command#FormatCommand(bufnr('%'), 'awesome-linter do something', 0)
@@ -13,40 +21,57 @@ Execute(FormatCommand should handle %%, and ignore other percents):
AssertEqual ['', '% %%d %%f %x %'], ale#command#FormatCommand(bufnr('%'), '%% %%%d %%%f %x %', 0)
Execute(FormatCommand should convert %s to the current filename):
- AssertEqual ['', 'foo ' . shellescape(expand('%:p')) . ' bar ' . shellescape(expand('%:p'))], ale#command#FormatCommand(bufnr('%'), 'foo %s bar %s', 0)
+ AssertEqual
+ \ [
+ \ '',
+ \ 'foo ' . ale#Escape(expand('%:p')) . ' bar ' . ale#Escape(expand('%:p'))
+ \ ],
+ \ ale#command#FormatCommand(bufnr('%'), 'foo %s bar %s', 0)
Execute(FormatCommand should convert %t to a new temporary filename):
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo %t bar %t', 0)
- let g:match = matchlist(g:result[1], '\v^foo (''/tmp/[^'']*/dummy.txt'') bar (''/tmp/[^'']*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo (.*) bar (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
" The first item of the result should be a temporary filename, and it should
" be the same as the escaped name in the command string.
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
" The two temporary filenames formatted in should be the same.
AssertEqual g:match[1], g:match[2]
Execute(FormatCommand should let you combine %s and %t):
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo %t bar %s', 0)
- let g:match = matchlist(g:result[1], '\v^foo (''/tmp/.*/dummy.txt'') bar (''.*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo (.*) bar (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
" The first item of the result should be a temporary filename, and it should
" be the same as the escaped name in the command string.
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
" The second item should be equal to the original filename.
- AssertEqual shellescape(expand('%:p')), g:match[2]
+ AssertEqual ale#Escape(expand('%:p')), g:match[2]
Execute(EscapeCommandPart should escape all percent signs):
AssertEqual '%%s %%t %%%% %%s %%t %%%%', ale#engine#EscapeCommandPart('%s %t %% %s %t %%')
Execute(EscapeCommandPart should pipe in temporary files appropriately):
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo bar', 1)
- let g:match = matchlist(g:result[1], '\v^foo bar \< (''/tmp/[^'']*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo bar \< (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo bar %t', 1)
- let g:match = matchlist(g:result[1], '\v^foo bar (''/tmp/[^'']*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo bar (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
diff --git a/test/test_format_temporary_file_creation.vader b/test/test_format_temporary_file_creation.vader
index 0639c593..1afaba30 100644
--- a/test/test_format_temporary_file_creation.vader
+++ b/test/test_format_temporary_file_creation.vader
@@ -10,8 +10,8 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
- \ 'executable': 'cat',
- \ 'command': 'cat %t',
+ \ 'executable': has('win32') ? 'cmd' : 'cat',
+ \ 'command': has('win32') ? 'type %t' : 'cat %t',
\})
After:
diff --git a/test/test_get_abspath.vader b/test/test_get_abspath.vader
index 2def3773..5f813804 100644
--- a/test/test_get_abspath.vader
+++ b/test/test_get_abspath.vader
@@ -3,10 +3,10 @@ Execute(Relative paths should be resolved correctly):
\ '/foo/bar/baz/whatever.txt',
\ ale#path#GetAbsPath('/foo/bar/xyz', '../baz/whatever.txt')
AssertEqual
- \ '/foo/bar/xyz/whatever.txt',
+ \ has('win32') ? '/foo/bar/xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
\ ale#path#GetAbsPath('/foo/bar/xyz', './whatever.txt')
AssertEqual
- \ '/foo/bar/xyz/whatever.txt',
+ \ has('win32') ? '/foo/bar/xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
\ ale#path#GetAbsPath('/foo/bar/xyz', 'whatever.txt')
Execute(Absolute paths should be resolved correctly):
diff --git a/test/test_gradle_build_classpath_command.vader b/test/test_gradle_build_classpath_command.vader
index 84135268..c31dc698 100644
--- a/test/test_gradle_build_classpath_command.vader
+++ b/test/test_gradle_build_classpath_command.vader
@@ -1,37 +1,44 @@
Before:
+ Save $PATH
+ Save $PATHEXT
+
+ let $PATHEXT = '.'
+
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/kotlin/kotlinc.vim
- let g:ale_gradle_path = $PATH
+
+ let g:command_tail = ' -I ' . ale#Escape(ale#gradle#GetInitPath())
+ \ . ' -q printClasspath'
+
+ let g:gradle_init_path = ale#path#Winify(g:dir . '../../autoload/ale/gradle/init.gradle')
After:
+ Restore
+
+ unlet! g:gradle_init_path
+ unlet! g:command_tail
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- let $PATH = g:ale_gradle_path
Execute(Should return 'gradlew' command if project includes gradle wapper):
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
- let g:project_root = '/testplugin/test/gradle-test-files/wrapped-project'
- let g:gradle_executable = '/testplugin/test/gradle-test-files/wrapped-project/gradlew'
- let g:gradle_init_path = '/testplugin/autoload/ale/gradle/init.gradle'
- let g:gradle_options = '-I ' . g:gradle_init_path . ' -q printClasspath'
-
-
AssertEqual
- \ "cd '" . g:project_root . "' && " . g:gradle_executable . " " . g:gradle_options,
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project'))
+ \ . ' && ' . ale#Escape(ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project/gradlew'))
+ \ . g:command_tail,
\ ale#gradle#BuildClasspathCommand(bufnr(''))
Execute(Should return 'gradle' command if project does not include gradle wapper):
call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
- let $PATH .= ':' . g:dir . '/gradle-test-files'
-
- let g:project_root = '/testplugin/test/gradle-test-files/unwrapped-project'
- let g:gradle_executable = 'gradle'
- let g:gradle_init_path = '/testplugin/autoload/ale/gradle/init.gradle'
- let g:gradle_options = '-I ' . g:gradle_init_path . ' -q printClasspath'
+ let $PATH .= (has('win32') ? ';' : ':')
+ \ . ale#path#Winify(g:dir . '/gradle-test-files')
AssertEqual
- \ "cd '" . g:project_root . "' && " . g:gradle_executable . " " . g:gradle_options,
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/gradle-test-files/unwrapped-project'))
+ \ . ' && ' . ale#Escape('gradle')
+ \ . g:command_tail,
\ ale#gradle#BuildClasspathCommand(bufnr(''))
Execute(Should return empty string if gradle cannot be executed):
diff --git a/test/test_gradle_find_executable.vader b/test/test_gradle_find_executable.vader
index 2ae2b464..054c21a8 100644
--- a/test/test_gradle_find_executable.vader
+++ b/test/test_gradle_find_executable.vader
@@ -1,31 +1,37 @@
Before:
+ Save $PATH
+ Save $PATHEXT
+
+ " Count the gradle executable without .exe as executable on Windows
+ let $PATHEXT = '.'
+
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/kotlin/kotlinc.vim
- let g:ale_gradle_path = $PATH
After:
+ Restore
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- let $PATH = g:ale_gradle_path
-
+
Execute(Should return 'gradlew' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/wrapped-project/gradlew',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project/gradlew'),
\ ale#gradle#FindExecutable(bufnr(''))
Execute(Should return 'gradle' if 'gradlew' not found in parent directory):
call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
- let $PATH .= ':' . g:dir . '/gradle-test-files'
-
+ let $PATH .= (has('win32') ? ';': ':') . ale#path#Winify(g:dir . '/gradle-test-files')
+
AssertEqual
- \ 'gradle',
+ \ 'gradle',
\ ale#gradle#FindExecutable(bufnr(''))
Execute(Should return empty string if 'gradlew' not in parent directory and gradle not in path):
call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
-
+
AssertEqual
- \ '',
+ \ '',
\ ale#gradle#FindExecutable(bufnr(''))
diff --git a/test/test_gradle_find_project_root.vader b/test/test_gradle_find_project_root.vader
index bd1b8d7d..87af1109 100644
--- a/test/test_gradle_find_project_root.vader
+++ b/test/test_gradle_find_project_root.vader
@@ -10,21 +10,21 @@ Execute(Should return directory for 'gradlew' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/wrapped-project',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project'),
\ ale#gradle#FindProjectRoot(bufnr(''))
Execute(Should return directory for 'settings.gradle' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/settings-gradle-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/settings-gradle-project',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/settings-gradle-project'),
\ ale#gradle#FindProjectRoot(bufnr(''))
Execute(Should return directory for 'build.gradle' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/build-gradle-project',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/build-gradle-project'),
\ ale#gradle#FindProjectRoot(bufnr(''))
Execute(Should return empty string if gradle files are not found in parent directory):
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index c1909c4f..de8decc1 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -36,7 +36,7 @@ Before:
call ale#linter#Define('testft', {
\ 'name': 'x',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd': 'echo',
\ 'command': 'echo',
\ 'callback': 'GenerateResults',
\})
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index dc7ce0d7..020ceb53 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -67,7 +67,10 @@ Execute(History should be set when commands are run):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
- let g:history = ale#history#Get(bufnr(''))
+ let g:history = filter(
+ \ copy(ale#history#Get(bufnr(''))),
+ \ 'v:val.job_id isnot# ''executable''',
+ \)
AssertEqual 1, len(g:history)
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader
index 4d4f19cc..d2b38e04 100644
--- a/test/test_lint_on_enter_when_file_changed.vader
+++ b/test/test_lint_on_enter_when_file_changed.vader
@@ -2,9 +2,12 @@ Before:
Save &filetype
Save g:ale_buffer_info
Save g:ale_lint_on_enter
+ Save g:ale_set_lists_synchronously
+
let g:buf = bufnr('')
let g:ale_lint_on_enter = 1
let g:ale_run_synchronously = 1
+ let g:ale_set_lists_synchronously = 1
function! TestCallback(buffer, output)
return [{
@@ -17,8 +20,8 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
- \ 'command': 'true',
+ \ 'executable': has('win32') ? 'cmd' : 'true',
+ \ 'command': has('win32') ? 'echo' : 'true',
\})
After: