summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2020-09-04 13:46:11 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2020-09-04 13:46:11 +0200
commitc78be861035765d268a5533cf583803e22d56d1c (patch)
tree63b2294216911121d594b885ae93fb82edc00273 /test
parent0de847a8e1793b597ba0a73ae8e20797a5fce920 (diff)
parent844febb9fbfb66bb13dd652d958495e47f0bd408 (diff)
downloadale-c78be861035765d268a5533cf583803e22d56d1c.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_flake8_command_callback.vader43
-rw-r--r--test/command_callback/test_psalm_command_callbacks.vader32
-rw-r--r--test/command_callback/test_vint_command_callback.vader2
-rw-r--r--test/completion/test_completion_events.vader2
-rw-r--r--test/ember-template-lint-test-files/app/template.hbs0
-rw-r--r--test/ember-template-lint-test-files/package.json0
-rw-r--r--test/fix/test_ale_fix.vader13
-rw-r--r--test/handler/test_gcc_handler.vader35
-rw-r--r--test/test_c_flag_parsing.vader20
-rw-r--r--test/test_code_action.vader46
-rw-r--r--test/test_cursor_warnings.vader2
-rw-r--r--test/test_embertemplatelint_executable_detection.vader22
-rw-r--r--test/test_list_formatting.vader4
13 files changed, 205 insertions, 16 deletions
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index f082a63a..09f64ee3 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -34,13 +34,52 @@ Execute(The flake8 callbacks should return the correct default values):
\]
Execute(The option for disabling changing directories should work):
- let g:ale_python_flake8_change_directory = 0
+ let g:ale_python_flake8_change_directory = 'off'
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
+ let g:ale_python_flake8_change_directory = 0
+
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
+ \]
+
+ " Invalid options should be considered the same as turning the setting off.
+ let g:ale_python_flake8_change_directory = 'xxx'
+
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
+ \]
+
+Execute(The option for changing directory to project root should work):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_tox/namespace/foo/bar.py')
+
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --version',
+ \ ale#path#CdString(ale#python#FindProjectRootIni(bufnr('')))
+ \ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
+ \]
+
+Execute(The option for changing directory to file dir should work):
+ let g:ale_python_flake8_change_directory = 'file'
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_tox/namespace/foo/bar.py')
+
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --version',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
+ \]
+
+ let g:ale_python_flake8_change_directory = 1
+
+ AssertLinter 'flake8', [
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
+ \]
+
Execute(The flake8 command callback should let you set options):
let g:ale_python_flake8_options = '--some-option'
@@ -163,5 +202,5 @@ Execute(Pipenv is detected when python_flake8_auto_pipenv is set):
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
AssertLinter 'pipenv',
- \ ale#path#BufferCdString(bufnr(''))
+ \ ale#path#CdString(ale#python#FindProjectRootIni(bufnr('')))
\ . ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -'
diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader
index 70b5af95..d32780e6 100644
--- a/test/command_callback/test_psalm_command_callbacks.vader
+++ b/test/command_callback/test_psalm_command_callbacks.vader
@@ -2,6 +2,9 @@ Before:
call ale#assert#SetUpLinterTest('php', 'psalm')
After:
+ unlet! g:i
+ unlet! g:matched
+
if isdirectory(g:dir . '/.git')
call delete(g:dir . '/.git', 'd')
endif
@@ -22,19 +25,36 @@ Execute(Vendor executables should be detected):
\ . '/psalm-project/vendor/bin/psalm'
\ )) . ' --language-server'
+ let g:ale_php_psalm_use_global = 1
+
+ AssertLinter 'psalm',
+ \ ale#Escape('psalm') . ' --language-server'
+
Execute(User provided options should be used):
- let g:ale_psalm_langserver_options = '--my-user-provided-option my-value'
+ let g:ale_php_psalm_options = '--my-user-provided-option my-value'
AssertLinter 'psalm',
\ ale#Escape('psalm')
\ . ' --language-server --my-user-provided-option my-value'
-
Execute(The project path should be correct for .git directories):
call ale#test#SetFilename('psalm-project/test.php')
+ let g:matched = 0
- if !isdirectory(g:dir . '/.git')
- call mkdir(g:dir . '/.git')
- endif
+ for g:i in range(4)
+ if !isdirectory(g:dir . '/.git')
+ call mkdir(g:dir . '/.git')
+ endif
+
+ try
+ AssertLSPProject g:dir
+ catch /.+/
+ endtry
- AssertLSPProject g:dir
+ let g:matched = 1
+ break
+ endfor
+
+ if !g:matched
+ AssertLSPProject g:dir
+ endif
diff --git a/test/command_callback/test_vint_command_callback.vader b/test/command_callback/test_vint_command_callback.vader
index e0051f26..4ce277e8 100644
--- a/test/command_callback/test_vint_command_callback.vader
+++ b/test/command_callback/test_vint_command_callback.vader
@@ -1,7 +1,7 @@
Before:
call ale#assert#SetUpLinterTest('vim', 'vint')
let b:command_tail = (has('nvim') ? ' --enable-neovim' : '')
- \ . ' -f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})" %t'
+ \ . ' -f "{file_path}:{line_number}:{column_number}: {severity}: {policy_name} - {description} (see {reference})" %t'
After:
unlet! b:bin_dir
diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader
index 3a7a31d0..87bd10ad 100644
--- a/test/completion/test_completion_events.vader
+++ b/test/completion/test_completion_events.vader
@@ -35,7 +35,7 @@ Before:
let g:ale_completion_delay = 0
" Run this check a few times, as it can fail randomly.
- for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
+ for l:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
call ale#completion#Queue()
sleep 1m
diff --git a/test/ember-template-lint-test-files/app/template.hbs b/test/ember-template-lint-test-files/app/template.hbs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/ember-template-lint-test-files/app/template.hbs
diff --git a/test/ember-template-lint-test-files/package.json b/test/ember-template-lint-test-files/package.json
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/ember-template-lint-test-files/package.json
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader
index e8a9dd7a..a51a5a53 100644
--- a/test/fix/test_ale_fix.vader
+++ b/test/fix/test_ale_fix.vader
@@ -727,6 +727,19 @@ Expect(There should be only two lines):
a
b
+Execute(ALEFix should modify a buffer that is not modifiable, if it becomes modifiable later):
+ let g:ale_fixers.testft = ['RemoveLastLineOneArg']
+
+ set nomodifiable
+ ALEFix
+ call ale#test#FlushJobs()
+ set modifiable
+ call ale#fix#ApplyQueuedFixes(bufnr(''))
+
+Expect(There should be only two lines):
+ a
+ b
+
Execute(b:ale_fix_on_save = 1 should override g:ale_fix_on_save = 0):
let g:ale_fix_on_save = 0
let b:ale_fix_on_save = 1
diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader
index b67483a6..a4231cab 100644
--- a/test/handler/test_gcc_handler.vader
+++ b/test/handler/test_gcc_handler.vader
@@ -279,3 +279,38 @@ Execute(The GCC handler should handle errors for inlined header functions):
\ ' __open_too_many_args ();',
\ ' ^~~~~~~~~~~~~~~~~~~~~~~',
\ ])
+
+Execute(The GCC handler should handle macro expansion errors in current file):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 19,
+ \ 'type': 'E',
+ \ 'text': 'error message',
+ \ 'detail': "error message\n<stdin>:1:19: note: in expansion of macro 'TEST'",
+ \ },
+ \ ],
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
+ \ '<command-line>: error: error message',
+ \ '<stdin>:1:19: note: in expansion of macro ‘TEST’',
+ \ ' 1 | std::string str = TEST;',
+ \ ' | ^~~~',
+ \ ])
+
+Execute(The GCC handler should handle macro expansion errors in other files):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 0,
+ \ 'type': 'E',
+ \ 'text': 'Error found in macro expansion. See :ALEDetail',
+ \ 'detail': "error message\ninc.h:1:19: note: in expansion of macro 'TEST'",
+ \ },
+ \ ],
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
+ \ '<command-line>: error: error message',
+ \ 'inc.h:1:19: note: in expansion of macro ‘TEST’',
+ \ ' 1 | std::string str = TEST;',
+ \ ' | ^~~~',
+ \ ])
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader
index 076be6a1..99722b17 100644
--- a/test/test_c_flag_parsing.vader
+++ b/test/test_c_flag_parsing.vader
@@ -1,9 +1,13 @@
Before:
Save g:ale_c_parse_makefile
+ Save g:ale_c_always_make
+ Save b:ale_c_always_make
call ale#test#SetDirectory('/testplugin/test')
let g:ale_c_parse_makefile = 1
+ let g:ale_c_always_make = 1
+ let b:ale_c_always_make = 1
function SplitAndParse(path_prefix, command) abort
let l:args = ale#c#ShellSplit(a:command)
@@ -18,6 +22,22 @@ After:
call ale#test#RestoreDirectory()
+Execute(The make command should be correct):
+ call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
+
+ AssertEqual
+ \ ale#path#CdString(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'))
+ \ . 'make -n --always-make',
+ \ ale#c#GetMakeCommand(bufnr(''))
+
+ " You should be able to disable --always-make for a buffer.
+ let b:ale_c_always_make = 0
+
+ AssertEqual
+ \ ale#path#CdString(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'))
+ \ . 'make -n',
+ \ ale#c#GetMakeCommand(bufnr(''))
+
Execute(The CFlags parser should be able to parse include directives):
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
diff --git a/test/test_code_action.vader b/test/test_code_action.vader
index b47f24ff..19de7268 100644
--- a/test/test_code_action.vader
+++ b/test/test_code_action.vader
@@ -1,4 +1,8 @@
Before:
+ Save g:ale_enabled
+
+ let g:ale_enabled = 0
+
runtime autoload/ale/code_action.vim
runtime autoload/ale/util.vim
@@ -35,6 +39,8 @@ Before:
endfunction!
After:
+ Restore
+
" Close the extra buffers if we opened it.
if bufnr(g:file1) != -1
execute ':bp! | :bd! ' . bufnr(g:file1)
@@ -50,9 +56,10 @@ After:
call delete(g:file2)
endif
- unlet g:file1
- unlet g:file2
- unlet g:test
+ unlet! g:file1
+ unlet! g:file2
+ unlet! g:test
+ unlet! g:changes
delfunction WriteFileAndEdit
runtime autoload/ale/code_action.vim
@@ -350,3 +357,36 @@ Execute(It should just modify file when should_save is set to v:false):
\ ' value: string',
\ '}',
\], getline(1, '$')
+
+Given typescript(An example TypeScript file):
+ type Foo = {}
+
+ export interface ISomething {
+ fooLongName: Foo | null
+ }
+
+ export class SomethingElse implements ISomething {
+ // Bindings
+ fooLongName!: ISomething['fooLongName']
+ }
+
+Execute():
+ let g:changes = [
+ \ {'end': {'offset': 14, 'line': 4}, 'newText': 'foo', 'start': {'offset': 3, 'line': 4}},
+ \ {'end': {'offset': 40, 'line': 9}, 'newText': 'foo', 'start': {'offset': 29, 'line': 9}},
+ \ {'end': {'offset': 14, 'line': 9}, 'newText': 'foo', 'start': {'offset': 3, 'line': 9}},
+ \]
+
+ call ale#code_action#ApplyChanges(expand('%:p'), g:changes, 0)
+
+Expect(The changes should be applied correctly):
+ type Foo = {}
+
+ export interface ISomething {
+ foo: Foo | null
+ }
+
+ export class SomethingElse implements ISomething {
+ // Bindings
+ foo!: ISomething['foo']
+ }
diff --git a/test/test_cursor_warnings.vader b/test/test_cursor_warnings.vader
index 339cd71e..ef385061 100644
--- a/test/test_cursor_warnings.vader
+++ b/test/test_cursor_warnings.vader
@@ -30,7 +30,7 @@ Before:
\ 'nr': -1,
\ 'type': 'E',
\ 'code': 'semi',
- \ 'text': 'Missing semicolon.',
+ \ 'text': "Missing semicolon.\r",
\ 'detail': "Every statement should end with a semicolon\nsecond line",
\ },
\ {
diff --git a/test/test_embertemplatelint_executable_detection.vader b/test/test_embertemplatelint_executable_detection.vader
new file mode 100644
index 00000000..bd0f5dd9
--- /dev/null
+++ b/test/test_embertemplatelint_executable_detection.vader
@@ -0,0 +1,22 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test')
+
+ runtime ale_linters/handlebars/embertemplatelint.vim
+
+After:
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(ember-template-lint executables runs the right command):
+ call ale#test#SetFilename('ember-template-lint-test-files/app/template.hbs')
+
+ AssertEqual
+ \ ale_linters#handlebars#embertemplatelint#GetCommand(bufnr(''), [2, 0, 0]),
+ \ '%e --json --filename %s'
+
+Execute(old ember-template-lint executables runs the right command):
+ call ale#test#SetFilename('ember-template-lint-test-files/app/template.hbs')
+
+ AssertEqual
+ \ ale_linters#handlebars#embertemplatelint#GetCommand(bufnr(''), [1, 5, 0]),
+ \ '%e --json %t'
diff --git a/test/test_list_formatting.vader b/test/test_list_formatting.vader
index dcefac53..d79a664b 100644
--- a/test/test_list_formatting.vader
+++ b/test/test_list_formatting.vader
@@ -36,7 +36,7 @@ After:
call setqflist([])
Execute(Formatting with codes should work for the loclist):
- call AddItem({'text': 'nocode'})
+ call AddItem({'text': "nocode\r"})
call ale#list#SetLists(bufnr(''), g:loclist)
AssertEqual
@@ -79,7 +79,7 @@ Execute(Formatting with codes should work for the quickfix list):
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
- call AddItem({'text': 'nocode'})
+ call AddItem({'text': "nocode\r"})
call ale#list#SetLists(bufnr(''), g:loclist)
AssertEqual