summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-10-30 22:19:57 +0000
committerw0rp <devw0rp@gmail.com>2017-10-30 22:19:57 +0000
commit50f7ad35529e0672e4161e3c74be5cb87196a2f1 (patch)
tree3feeaa166f4a52a5cb4962cb890622168ba50547 /test
parent1575b3d7ddc5c2844d987f2abb0a5defe493972b (diff)
downloadale-50f7ad35529e0672e4161e3c74be5cb87196a2f1.zip
#857 - Add b:ale_fix_on_save for controlling fixing on save for specific buffers
Diffstat (limited to 'test')
-rw-r--r--test/test_ale_fix.vader24
-rw-r--r--test/test_ale_toggle.vader8
-rw-r--r--test/test_autocmd_commands.vader26
-rw-r--r--test/test_lint_file_linters.vader15
4 files changed, 47 insertions, 26 deletions
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader
index 9968c4a5..fac9a25b 100644
--- a/test/test_ale_fix.vader
+++ b/test/test_ale_fix.vader
@@ -77,6 +77,7 @@ After:
unlet! g:ale_set_lists_synchronously
unlet! g:ale_emulate_job_failure
unlet! b:ale_fixers
+ unlet! b:ale_fix_on_save
delfunction AddCarets
delfunction AddDollars
delfunction DoNothing
@@ -412,6 +413,29 @@ 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
+
+ let g:ale_fixers.testft = ['RemoveLastLineOneArg']
+ call ale#events#SaveEvent(bufnr(''))
+
+Expect(There should be only two lines):
+ a
+ b
+
+Execute(b:ale_fix_on_save = 0 should override g:ale_fix_on_save = 1):
+ let g:ale_fix_on_save = 1
+ let b:ale_fix_on_save = 0
+
+ let g:ale_fixers.testft = ['RemoveLastLineOneArg']
+ call ale#events#SaveEvent(bufnr(''))
+
+Expect(The lines should be the same):
+ a
+ b
+ c
+
Execute(ALEFix functions returning jobs should be able to accept one argument):
if has('win32')
" Just skip this test on Windows, we can't run it.
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index c3bd2f52..a57546fc 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -131,7 +131,13 @@ Execute(ALEToggle should reset everything and then run again):
AssertEqual [], getloclist(0), 'The loclist was not cleared'
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
AssertEqual [], getmatches(), 'The highlights were not cleared'
- AssertEqual ['ALECleanupGroup', 'ALEHighlightBufferGroup'], ParseAuGroups()
+ AssertEqual
+ \ [
+ \ 'ALECleanupGroup',
+ \ 'ALEHighlightBufferGroup',
+ \ 'ALERunOnSaveGroup',
+ \ ],
+ \ ParseAuGroups()
" Toggle ALE on, everything should be set up and run again.
ALEToggle
diff --git a/test/test_autocmd_commands.vader b/test/test_autocmd_commands.vader
index 6bc3f5cd..88504a9b 100644
--- a/test/test_autocmd_commands.vader
+++ b/test/test_autocmd_commands.vader
@@ -155,32 +155,10 @@ Execute (g:ale_lint_on_filetype_changed = 1 should bind the FileType event):
\ ],
\ CheckAutocmd('ALERunOnFiletypeChangeGroup')
-Execute (g:ale_lint_on_save = 0 should bind no events):
- let g:ale_lint_on_save = 0
- let g:ale_fix_on_save = 0
-
- AssertEqual [], CheckAutocmd('ALERunOnSaveGroup')
-
-Execute (g:ale_lint_on_save = 1 should bind no events):
- let g:ale_lint_on_save = 1
- let g:ale_fix_on_save = 0
-
- AssertEqual [
- \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALERunOnSaveGroup')
-
-Execute (g:ale_lint_on_save = 0 and g:ale_fix_on_save = 1 should bind events):
- let g:ale_lint_on_save = 0
- let g:ale_fix_on_save = 1
-
- AssertEqual [
- \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALERunOnSaveGroup')
-
-Execute (g:ale_fix_on_save = 1 should bind events even when ALE is disabled):
+Execute (The SaveEvent should always be bound):
let g:ale_enabled = 0
let g:ale_lint_on_save = 0
- let g:ale_fix_on_save = 1
+ let g:ale_fix_on_save = 0
AssertEqual [
\ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
diff --git a/test/test_lint_file_linters.vader b/test/test_lint_file_linters.vader
index bea8c3f0..2e992e13 100644
--- a/test/test_lint_file_linters.vader
+++ b/test/test_lint_file_linters.vader
@@ -1,4 +1,6 @@
Before:
+ Save g:ale_fix_on_save
+ Save g:ale_enabled
Save g:ale_run_synchronously
Save g:ale_set_lists_synchronously
Save g:ale_buffer_info
@@ -7,6 +9,7 @@ Before:
let g:ale_buffer_info = {}
let g:ale_run_synchronously = 1
let g:ale_set_lists_synchronously = 1
+ let b:ale_save_event_fired = 0
call ale#ResetLintFileMarkers()
let g:buffer_result = [
@@ -261,7 +264,10 @@ Execute(The Save event should respect the buffer number):
\], GetSimplerLoclist()
Execute(The Save event should set b:ale_save_event_fired to 1):
- let b:ale_enabled = 0
+ let g:ale_lint_on_save = 1
+ let b:ale_enabled = 1
+
+ call ale#linter#Reset()
call ale#events#SaveEvent(bufnr(''))
" This flag needs to be set so windows can be opened, etc.
@@ -289,3 +295,10 @@ Execute(lint_file linters should stay running after checking without them):
AssertEqual 2, len(g:ale_buffer_info[bufnr('')].job_list)
call ale#engine#WaitForJobs(2000)
+
+Execute(The save event should not lint the buffer when ALE is disabled):
+ let g:ale_enabled = 0
+ call ale#events#SaveEvent(bufnr(''))
+
+ AssertEqual [], GetSimplerLoclist()
+ AssertEqual 0, b:ale_save_event_fired