summaryrefslogtreecommitdiff
path: root/test/test_no_linting_on_write_quit.vader
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_no_linting_on_write_quit.vader')
-rw-r--r--test/test_no_linting_on_write_quit.vader71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader
new file mode 100644
index 00000000..dc78ef75
--- /dev/null
+++ b/test/test_no_linting_on_write_quit.vader
@@ -0,0 +1,71 @@
+Before:
+ Save g:ale_echo_cursor
+ Save g:ale_fix_on_save
+ Save g:ale_fixers
+ Save g:ale_lint_on_save
+
+ let g:ale_echo_cursor = 0
+ let g:ale_run_synchronously = 1
+
+ function! TestCallback(buffer, output)
+ return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
+ endfunction
+
+ function AddLine(buffer, lines) abort
+ return a:lines + ['x']
+ endfunction
+
+ let g:ale_fixers = {
+ \ 'testft': ['AddLine'],
+ \}
+
+ call ale#linter#Define('testft', {
+ \ 'name': 'testlinter',
+ \ 'callback': 'TestCallback',
+ \ 'executable': 'true',
+ \ 'command': 'true',
+ \})
+
+Given testft (An empty file):
+
+After:
+ Restore
+
+ unlet! g:ale_run_synchronously
+ unlet! b:ale_quitting
+ delfunction TestCallback
+ delfunction AddLine
+
+ call ale#linter#Reset()
+ call setloclist(0, [])
+
+Execute(No linting should be done on :wq or :x):
+ let g:ale_lint_on_save = 1
+ let g:ale_fix_on_save = 0
+
+ " First try just the SaveEvent, to be sure that we set errors in the test.
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual 1, len(getloclist(0))
+
+ " Now try doing it again, but where we run the quit event first.
+ call setloclist(0, [])
+ call ale#events#QuitEvent(bufnr(''))
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual [], getloclist(0)
+
+Execute(No linting should be done on :wq or :x after fixing files):
+ let g:ale_lint_on_save = 0
+ let g:ale_fix_on_save = 1
+
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual 1, len(getloclist(0))
+
+ " Now try doing it again, but where we run the quit event first.
+ call setloclist(0, [])
+ call ale#events#QuitEvent(bufnr(''))
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual [], getloclist(0)