Skip to content

Commit f7852db

Browse files
committed
dense-analysis#3633 - Move linter tests into test/linter
1 parent 35caaec commit f7852db

File tree

256 files changed

+40
-144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+40
-144
lines changed

ale_linters/json/jq.vim

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
" Author: jD91mZM2 <[email protected]>
2+
call ale#Set('json_jq_executable', 'jq')
3+
call ale#Set('json_jq_options', '')
4+
call ale#Set('json_jq_filters', '.')
25

3-
function! ale_linters#json#jq#GetCommand(buffer) abort
4-
let l:executable = ale#fixers#jq#GetExecutable(a:buffer)
5-
6-
return ale#Escape(l:executable)
7-
endfunction
6+
" Matches patterns like the following:
7+
" parse error: Expected another key-value pair at line 4, column 3
8+
let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$'
89

910
function! ale_linters#json#jq#Handle(buffer, lines) abort
10-
" Matches patterns like the following:
11-
" parse error: Expected another key-value pair at line 4, column 3
12-
let l:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$'
13-
let l:output = []
14-
15-
for l:match in ale#util#GetMatches(a:lines, l:pattern)
16-
call add(l:output, {
17-
\ 'text': l:match[1],
18-
\ 'lnum': l:match[2] + 0,
19-
\ 'col': l:match[3] + 0,
20-
\})
21-
endfor
22-
23-
return l:output
11+
return ale#util#MapMatches(a:lines, s:pattern, {match -> {
12+
\ 'text': match[1],
13+
\ 'lnum': match[2] + 0,
14+
\ 'col': match[3] + 0,
15+
\}})
2416
endfunction
2517

2618
call ale#linter#Define('json', {
2719
\ 'name': 'jq',
28-
\ 'executable': function('ale#fixers#jq#GetExecutable'),
20+
\ 'executable': {b -> ale#Var(b, 'json_jq_executable')},
2921
\ 'output_stream': 'stderr',
30-
\ 'command': function('ale_linters#json#jq#GetCommand'),
22+
\ 'command': '%e',
3123
\ 'callback': 'ale_linters#json#jq#Handle',
3224
\})

autoload/ale/assert.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
293293
execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim'
294294

295295
if !exists('g:dir')
296-
call ale#test#SetDirectory('/testplugin/test/command_callback')
296+
call ale#test#SetDirectory('/testplugin/test/linter')
297297
endif
298298

299299
call ale#assert#SetUpLinterTestCommands()

doc/ale-development.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Generally write tests for any changes you make. The following types of tests
181181
are recommended for the following types of code.
182182

183183
* New/edited error handler callbacks -> Write tests in `test/handler`
184-
* New/edited command callbacks -> Write tests in `test/command_callback`
184+
* New/edited linter definition -> Write tests in `test/linter`
185185
* New/edited fixer functions -> Write tests in `test/fixers`
186186

187187
Look at existing tests in the codebase for examples of how to write tests.
@@ -278,8 +278,8 @@ be written like so. >
278278
\ '1:Something went wrong',
279279
\ ]
280280
<
281-
Tests for what ALE runs should go in the `test/command_callback` directory,
282-
and should be written like so. >
281+
Tests for what ALE runs should go in the `test/linter` directory, and should
282+
be written like so. >
283283
284284
Before:
285285
" Load the linter and set up a series of commands, reset linter variables,

test/completion/test_completion_events.vader

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Before:
1111
let g:feedkeys_calls = []
1212
let g:fake_mode = 'i'
1313

14+
let b:ale_linters = {
15+
\ 'typescript': ['tsserver'],
16+
\}
17+
1418
let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
1519

1620
runtime autoload/ale/util.vim
@@ -69,6 +73,7 @@ After:
6973
unlet! b:ale_completion_info
7074
unlet! b:ale_completion_result
7175
unlet! b:ale_complete_done_time
76+
unlet! b:ale_linters
7277

7378
delfunction CheckCompletionCalled
7479
delfunction ale#code_action#HandleCodeAction

test/fixers/test_autoimport_fixer_callback.vader

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ Before:
77
let g:ale_python_autoimport_options = ''
88

99
call ale#test#SetDirectory('/testplugin/test/fixers')
10-
silent cd ..
11-
silent cd command_callback
12-
let g:dir = getcwd()
1310

1411
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
1512

test/fixers/test_autopep8_fixer_callback.vader

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Before:
77
let g:ale_python_autopep8_options = ''
88

99
call ale#test#SetDirectory('/testplugin/test/fixers')
10-
silent cd ..
11-
silent cd command_callback
1210
let g:dir = getcwd()
1311

1412
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'

test/fixers/test_bibclean_fixer_callback.vader

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ After:
1212
call ale#test#RestoreDirectory()
1313

1414
Execute(The bibclean callback should return the correct default values):
15-
call ale#test#SetFilename('../command_callback/../test-files/bib/dummy.bib')
15+
call ale#test#SetFilename('../test-files/bib/dummy.bib')
1616

1717
AssertEqual
1818
\ {'command': ale#Escape(g:ale_bib_bibclean_executable) . ' -align-equals'},
1919
\ ale#fixers#bibclean#Fix(bufnr(''))
2020

2121
Execute(The bibclean callback should include custom bibclean options):
2222
let g:ale_bib_bibclean_options = '-author -check-values'
23-
call ale#test#SetFilename('../command_callback/../test-files/bib/dummy.bib')
23+
call ale#test#SetFilename('../test-files/bib/dummy.bib')
2424

2525
AssertEqual
2626
\ {

test/fixers/test_black_fixer_callback.vader

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Before:
22
call ale#assert#SetUpFixerTest('python', 'black')
33

4-
silent cd ..
5-
silent cd command_callback
64
let g:dir = getcwd()
75
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
86

test/fixers/test_clangformat_fixer_callback.vader

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Before:
77
let g:ale_c_clangformat_executable = 'xxxinvalid'
88

99
call ale#test#SetDirectory('/testplugin/test/fixers')
10-
silent cd ..
11-
silent cd command_callback
1210
let g:dir = getcwd()
1311

1412
After:

test/fixers/test_clangtidy_fixer_callback.vader

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Before:
1717
let g:ale_c_build_dir = ''
1818

1919
call ale#test#SetDirectory('/testplugin/test/fixers')
20-
silent cd ../command_callback
21-
let g:dir = getcwd()
2220

2321
After:
2422
Restore

0 commit comments

Comments
 (0)