Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bartek thindil Jasicki
2020-09-04 13:46:11 +02:00
29 changed files with 452 additions and 84 deletions

View File

@@ -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 -'

View File

@@ -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')
for g:i in range(4)
if !isdirectory(g:dir . '/.git')
call mkdir(g:dir . '/.git')
endif
try
AssertLSPProject g:dir
catch /.+/
endtry
let g:matched = 1
break
endfor
if !g:matched
AssertLSPProject g:dir
endif
AssertLSPProject g:dir

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;',
\ ' | ^~~~',
\ ])

View File

@@ -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')

View File

@@ -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']
}

View File

@@ -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",
\ },
\ {

View File

@@ -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'

View File

@@ -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