summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_javac_command_callback.vader6
-rw-r--r--test/test_ale_toggle.vader15
-rw-r--r--test/test_errors_removed_after_filetype_changed.vader58
-rw-r--r--test/test_highlight_placement.vader92
-rw-r--r--test/test_lint_file_linters.vader16
-rw-r--r--test/test_lint_on_enter_when_file_changed.vader2
-rw-r--r--test/test_linting_updates_loclist.vader4
-rw-r--r--test/test_temporary_file_management.vader4
8 files changed, 131 insertions, 66 deletions
diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader
index 2f0bc50e..706839e4 100644
--- a/test/command_callback/test_javac_command_callback.vader
+++ b/test/command_callback/test_javac_command_callback.vader
@@ -8,7 +8,7 @@ After:
call ale#linter#Reset()
" We need to clean up the buffer to remove the temporary directories created
" for the command.
- call ale#cleanup#Buffer(bufnr(''))
+ call ale#engine#Cleanup(bufnr(''))
let g:ale_java_javac_options = ''
let g:ale_java_javac_classpath = ''
@@ -63,7 +63,7 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ 'Invalid command string: ' . b:command
Execute(The javac callback should detect source directories):
- call ale#cleanup#Buffer(bufnr(''))
+ call ale#engine#Cleanup(bufnr(''))
:e! java_paths/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr(''))
@@ -73,7 +73,7 @@ Execute(The javac callback should detect source directories):
\ 'Invalid command string: ' . b:command
Execute(The javac callback should combine detected source directories and classpaths):
- call ale#cleanup#Buffer(bufnr(''))
+ call ale#engine#Cleanup(bufnr(''))
:e! java_paths/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr(''))
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index 3546ad71..202d8a35 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -11,7 +11,6 @@ Before:
\ 'valid': 1,
\}]
let g:expected_groups = [
- \ 'ALEBufferFixGroup',
\ 'ALECleanupGroup',
\ 'ALECursorGroup',
\ 'ALEHighlightBufferGroup',
@@ -43,7 +42,10 @@ Before:
for l:line in split(l:output, "\n")
let l:match = matchlist(l:line, '^ALE[a-zA-Z]\+Group')
+ " We don't care about checking for the completion or fixing groups here.
if !empty(l:match)
+ \&& l:match[0] !=# 'ALECompletionGroup'
+ \&& l:match[0] !=# 'ALEBufferFixGroup'
call add(l:results, l:match[0])
endif
endfor
@@ -94,15 +96,17 @@ Execute(ALEToggle should reset everything and then run again):
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
AssertEqual g:expected_groups, ParseAuGroups()
+ AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
" Now Toggle ALE off.
ALEToggle
" Everything should be cleared.
- AssertEqual [], getloclist(0)
- AssertEqual [], ale#sign#FindCurrentSigns(bufnr('%'))
- AssertEqual [], getmatches()
- AssertEqual ['ALEBufferFixGroup', 'ALECleanupGroup', 'ALEHighlightBufferGroup'], ParseAuGroups()
+ Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
+ AssertEqual [], getloclist(0), 'The loclist was not cleared'
+ AssertEqual [], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
+ AssertEqual [], getmatches(), 'The highlights were not cleared'
+ AssertEqual ['ALECleanupGroup', 'ALEHighlightBufferGroup'], ParseAuGroups()
" Toggle ALE on, everything should be set up and run again.
ALEToggle
@@ -114,3 +118,4 @@ Execute(ALEToggle should reset everything and then run again):
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
AssertEqual g:expected_groups, ParseAuGroups()
+ AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
diff --git a/test/test_errors_removed_after_filetype_changed.vader b/test/test_errors_removed_after_filetype_changed.vader
new file mode 100644
index 00000000..0498a501
--- /dev/null
+++ b/test/test_errors_removed_after_filetype_changed.vader
@@ -0,0 +1,58 @@
+Before:
+ Save g:ale_run_synchronously
+
+ let b:old_filetype = &filetype
+ let g:ale_run_synchronously = 1
+
+ noautocmd let &filetype = 'foobar'
+
+ function! TestCallback(buffer, output)
+ return [{'text': 'x', 'lnum': 1}]
+ endfunction
+
+ call ale#linter#Define('foobar', {
+ \ 'name': 'buffer_linter',
+ \ 'callback': 'TestCallback',
+ \ 'executable': 'true',
+ \ 'command': 'true',
+ \ 'read_buffer': 0,
+ \})
+
+ call ale#linter#Define('foobar2', {
+ \ 'name': 'buffer_linter',
+ \ 'callback': 'TestCallback',
+ \ 'executable': 'true',
+ \ 'command': 'true',
+ \ 'read_buffer': 0,
+ \})
+
+After:
+ Restore
+
+ noautocmd let &filetype = b:old_filetype
+ unlet b:old_filetype
+ delfunction TestCallback
+
+ if has_key(g:ale_buffer_info, bufnr(''))
+ call remove(g:ale_buffer_info, bufnr(''))
+ endif
+
+ call ale#Queue(0)
+
+Execute(Error should be removed when the filetype changes to something else we cannot check):
+ call ale#Queue(0)
+
+ AssertEqual 1, len(getloclist(0))
+
+ noautocmd let &filetype = 'foobar2'
+
+ call ale#Queue(0)
+
+ " We should get some items from the second filetype.
+ AssertEqual 1, len(getloclist(0))
+
+ noautocmd let &filetype = 'xxx'
+
+ call ale#Queue(0)
+
+ AssertEqual 0, len(getloclist(0))
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index a134916f..3fa45ed2 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -22,6 +22,18 @@ Before:
\]
endfunction
+ " We don't care what the IDs are, just that we have some matches.
+ " The IDs are generated.
+ function! GetMatchesWithoutIDs() abort
+ let l:list = getmatches()
+
+ for l:item in l:list
+ call remove(l:item, 'id')
+ endfor
+
+ return l:list
+ endfunction
+
call ale#linter#Define('testft', {
\ 'name': 'x',
\ 'executable': 'echo',
@@ -51,33 +63,11 @@ Execute(Highlights should be set when a linter runs):
AssertEqual
\ [
- \ {'group': 'ALEError', 'id': 4, 'priority': 10, 'pos1': [1, 1, 1]},
- \ {'group': 'ALEWarning', 'id': 5, 'priority': 10, 'pos1': [2, 1, 1]},
- \ {'group': 'ALEError', 'id': 6, 'priority': 10, 'pos1': [3, 5, 1]}
- \ ],
- \ getmatches()
-
- AssertEqual [[4], [5], [6]], map(copy(g:ale_buffer_info[bufnr('')].loclist), 'v:val.match_id_list')
-
-Execute(Existing highlights should be kept):
- call matchaddpos('ALEError', [[1, 2, 1]], 10, 347)
- call matchaddpos('ALEWarning', [[2, 2, 1]], 10, 348)
-
- call ale#highlight#SetHighlights(bufnr('%'), [
- \ {'bufnr': bufnr('%'), 'match_id_list': [347], 'type': 'E', 'lnum': 1, 'col': 2},
- \ {'bufnr': bufnr('%'), 'match_id_list': [348], 'type': 'W', 'lnum': 2, 'col': 2},
- \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2},
- \ {'bufnr': bufnr('%'), 'type': 'W', 'lnum': 4, 'col': 1},
- \])
-
- AssertEqual
- \ [
- \ {'group': 'ALEError', 'id': 347, 'priority': 10, 'pos1': [1, 2, 1]},
- \ {'group': 'ALEWarning', 'id': 348, 'priority': 10, 'pos1': [2, 2, 1]},
- \ {'group': 'ALEError', 'id': 7, 'priority': 10, 'pos1': [3, 2, 1]},
- \ {'group': 'ALEWarning', 'id': 8, 'priority': 10, 'pos1': [4, 1, 1]},
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
+ \ {'group': 'ALEWarning', 'priority': 10, 'pos1': [2, 1, 1]},
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 5, 1]}
\ ],
- \ getmatches()
+ \ GetMatchesWithoutIDs()
" This test is important for preventing ALE from showing highlights for
" the wrong files.
@@ -89,12 +79,12 @@ Execute(Highlights set by ALE should be removed when buffer cleanup is done):
\])
AssertEqual
- \ [{'group': 'ALEError', 'id': 9, 'priority': 10, 'pos1': [3, 2, 1]}],
- \ getmatches()
+ \ [{'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 1]}],
+ \ GetMatchesWithoutIDs()
- call ale#cleanup#Buffer(bufnr('%'))
+ call ale#engine#Cleanup(bufnr('%'))
- AssertEqual [], getmatches()
+ AssertEqual [], GetMatchesWithoutIDs()
Execute(Highlights should be cleared when buffers are hidden):
call ale#engine#InitBufferInfo(bufnr('%'))
@@ -108,15 +98,15 @@ Execute(Highlights should be cleared when buffers are hidden):
\ g:ale_buffer_info[bufnr('%')].loclist
\)
- AssertEqual 1, len(getmatches()), 'The highlights weren''t initially set!'
+ AssertEqual 1, len(GetMatchesWithoutIDs()), 'The highlights weren''t initially set!'
call ale#highlight#BufferHidden(bufnr('%'))
- AssertEqual 0, len(getmatches()), 'The highlights weren''t cleared!'
+ AssertEqual 0, len(GetMatchesWithoutIDs()), 'The highlights weren''t cleared!'
call ale#highlight#UpdateHighlights()
- AssertEqual 1, len(getmatches()), 'The highlights weren''t set again!'
+ AssertEqual 1, len(GetMatchesWithoutIDs()), 'The highlights weren''t set again!'
Execute(Only ALE highlights should be restored when buffers are restored):
call ale#engine#InitBufferInfo(bufnr('%'))
@@ -131,16 +121,16 @@ Execute(Only ALE highlights should be restored when buffers are restored):
call matchaddpos('SomeOtherGroup', [[1, 1, 1]])
" We should have one more match here.
- AssertEqual 2, len(getmatches()), 'The highlights weren''t initially set!'
+ AssertEqual 2, len(GetMatchesWithoutIDs()), 'The highlights weren''t initially set!'
call ale#highlight#BufferHidden(bufnr('%'))
- AssertEqual 0, len(getmatches()), 'The highlights weren''t cleared!'
+ AssertEqual 0, len(GetMatchesWithoutIDs()), 'The highlights weren''t cleared!'
call ale#highlight#UpdateHighlights()
" Only our matches should appear again.
- AssertEqual 1, len(getmatches()), 'The highlights weren''t set again!'
+ AssertEqual 1, len(GetMatchesWithoutIDs()), 'The highlights weren''t set again!'
Execute(Higlight end columns should set an appropriate size):
call ale#highlight#SetHighlights(bufnr('%'), [
@@ -150,10 +140,10 @@ Execute(Higlight end columns should set an appropriate size):
AssertEqual
\ [
- \ {'group': 'ALEError', 'id': 15, 'priority': 10, 'pos1': [3, 2, 4]},
- \ {'group': 'ALEWarning', 'id': 16, 'priority': 10, 'pos1': [4, 1, 5]},
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [3, 2, 4]},
+ \ {'group': 'ALEWarning', 'priority': 10, 'pos1': [4, 1, 5]},
\ ],
- \ getmatches()
+ \ GetMatchesWithoutIDs()
Execute(Higlight end columns should set an appropriate size):
call ale#highlight#SetHighlights(bufnr('%'), [
@@ -168,15 +158,15 @@ Execute(Higlight end columns should set an appropriate size):
AssertEqual
\ [
- \ {'group': 'ALEError', 'id': 17, 'priority': 10, 'pos1': [1, 1, 1]},
- \ {'group': 'ALEError', 'id': 18, 'priority': 10, 'pos1': [2, 1, 1]},
- \ {'group': 'ALEStyleError', 'id': 19, 'priority': 10, 'pos1': [3, 1, 1]},
- \ {'group': 'ALEWarning', 'id': 20, 'priority': 10, 'pos1': [4, 1, 1]},
- \ {'group': 'ALEWarning', 'id': 21, 'priority': 10, 'pos1': [5, 1, 1]},
- \ {'group': 'ALEStyleWarning', 'id': 22, 'priority': 10, 'pos1': [6, 1, 1]},
- \ {'group': 'ALEInfo', 'id': 23, 'priority': 10, 'pos1': [7, 1, 1]},
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [2, 1, 1]},
+ \ {'group': 'ALEStyleError', 'priority': 10, 'pos1': [3, 1, 1]},
+ \ {'group': 'ALEWarning', 'priority': 10, 'pos1': [4, 1, 1]},
+ \ {'group': 'ALEWarning', 'priority': 10, 'pos1': [5, 1, 1]},
+ \ {'group': 'ALEStyleWarning', 'priority': 10, 'pos1': [6, 1, 1]},
+ \ {'group': 'ALEInfo', 'priority': 10, 'pos1': [7, 1, 1]},
\ ],
- \ getmatches()
+ \ GetMatchesWithoutIDs()
Execute(Highlighting should support errors spanning many lines):
let g:items = [
@@ -189,15 +179,13 @@ Execute(Highlighting should support errors spanning many lines):
AssertEqual
\ [
\ {
- \ 'group': 'ALEError', 'id': 24, 'priority': 10, 'pos1': [1, 1, 1073741824],
+ \ 'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1073741824],
\ 'pos2': [2], 'pos3': [3], 'pos4': [4], 'pos5': [5], 'pos6': [6],
\ 'pos7': [7], 'pos8': [8],
\ },
\ {
- \ 'group': 'ALEError', 'id': 25, 'priority': 10,
+ \ 'group': 'ALEError', 'priority': 10,
\ 'pos1': [9], 'pos2': [10, 1, 3]
\ },
\ ],
- \ getmatches()
-
- AssertEqual [[24, 25]], map(copy(g:items), 'v:val.match_id_list')
+ \ GetMatchesWithoutIDs()
diff --git a/test/test_lint_file_linters.vader b/test/test_lint_file_linters.vader
index a02ecca3..b0dc1eb3 100644
--- a/test/test_lint_file_linters.vader
+++ b/test/test_lint_file_linters.vader
@@ -69,6 +69,10 @@ Before:
\ 'read_buffer': 0,
\})
+ let g:filename = tempname()
+ call writefile([], g:filename)
+ call ale#test#SetFilename(g:filename)
+
After:
Restore
@@ -79,6 +83,12 @@ After:
delfunction LintFileCallback
delfunction BufferCallback
+ if filereadable(g:filename)
+ call delete(g:filename)
+ endif
+
+ unlet g:filename
+
Given foobar (Some imaginary filetype):
foo
bar
@@ -107,6 +117,9 @@ Execute(Running linters without 'lint_file' should run only buffer linters):
Execute(Running linters with 'lint_file' should run all linters):
call ale#ResetLintFileMarkers()
let g:ale_buffer_info = {}
+
+ Assert filereadable(expand('%:p')), 'The file was not readable'
+
call ale#Queue(0, 'lint_file')
AssertEqual [
@@ -139,6 +152,9 @@ Execute(Running linters with 'lint_file' should run all linters):
Execute(Linter errors from files should be kept):
call ale#ResetLintFileMarkers()
let g:ale_buffer_info = {}
+
+ Assert filereadable(expand('%:p')), 'The file was not readable'
+
call ale#Queue(0, 'lint_file')
" Change the results for the buffer callback.
diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader
index ff4e7dd5..cfa53878 100644
--- a/test/test_lint_on_enter_when_file_changed.vader
+++ b/test/test_lint_on_enter_when_file_changed.vader
@@ -30,6 +30,8 @@ After:
call setloclist(0, [])
Execute(The file changed event function should set b:ale_file_changed):
+ let g:ale_lint_on_enter = 0
+
if has('gui')
new
else
diff --git a/test/test_linting_updates_loclist.vader b/test/test_linting_updates_loclist.vader
index 009a4537..19adfa1f 100644
--- a/test/test_linting_updates_loclist.vader
+++ b/test/test_linting_updates_loclist.vader
@@ -65,8 +65,4 @@ Execute(The loclist should be updated after linting is done):
call ale#engine#WaitForJobs(2000)
AssertEqual ['' . bufnr('%')], keys(g:ale_buffer_info)
-
- let g:expected_data[0].match_id_list = [getmatches()[0].id]
- let g:expected_data[1].match_id_list = [getmatches()[1].id]
-
AssertEqual g:expected_data, g:ale_buffer_info[bufnr('%')].loclist
diff --git a/test/test_temporary_file_management.vader b/test/test_temporary_file_management.vader
index 4eed345c..6d1f0dfd 100644
--- a/test/test_temporary_file_management.vader
+++ b/test/test_temporary_file_management.vader
@@ -84,7 +84,7 @@ Execute(ALE should delete managed files even if no command is run):
Execute(ALE should delete managed files when the buffer is removed):
call ale#engine#InitBufferInfo(bufnr('%'))
call TestCommandCallback(bufnr('%'))
- call ale#cleanup#Buffer(bufnr('%'))
+ call ale#engine#Cleanup(bufnr('%'))
Assert !filereadable(g:filename), 'The temporary file was not deleted'
Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
@@ -105,7 +105,7 @@ Execute(ALE should create and delete directories for ale#engine#CreateDirectory(
" The two directories shouldn't be the same.
AssertNotEqual b:dir2, b:dir
- call ale#cleanup#Buffer(bufnr('%'))
+ call ale#engine#Cleanup(bufnr('%'))
Assert !isdirectory(b:dir), 'The directory was not deleted'
Assert !isdirectory(b:dir2), 'The second directory was not deleted'