diff options
author | w0rp <devw0rp@gmail.com> | 2017-10-17 00:37:29 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-10-17 00:37:29 +0100 |
commit | 81d993086eae20cd8d2871b62e8889e54cfa9187 (patch) | |
tree | fbae675444608aa4fb354aa1aeecc7aa27b0f6cd /test | |
parent | 5946a128c30f24fdb69cb3ba59a55bc496b51a86 (diff) | |
download | ale-81d993086eae20cd8d2871b62e8889e54cfa9187.zip |
#904 - Allow linting to run on save a second after :q fails
Diffstat (limited to 'test')
-rw-r--r-- | test/test_no_linting_on_write_quit.vader | 26 | ||||
-rw-r--r-- | test/test_quitting_variable.vader | 21 |
2 files changed, 45 insertions, 2 deletions
diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader index dc78ef75..271adf65 100644 --- a/test/test_no_linting_on_write_quit.vader +++ b/test/test_no_linting_on_write_quit.vader @@ -55,6 +55,19 @@ Execute(No linting should be done on :wq or :x): AssertEqual [], getloclist(0) +Execute(No linting should be for :w after :q fails): + let g:ale_lint_on_save = 1 + let g:ale_fix_on_save = 0 + + call ale#events#QuitEvent(bufnr('')) + + " Simulate 2 seconds passing. + let b:ale_quitting -= 1000 + + call ale#events#SaveEvent(bufnr('')) + + AssertEqual 1, len(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 @@ -69,3 +82,16 @@ Execute(No linting should be done on :wq or :x after fixing files): call ale#events#SaveEvent(bufnr('')) AssertEqual [], getloclist(0) + +Execute(Linting should be done after :q fails and fixing files): + let g:ale_lint_on_save = 0 + let g:ale_fix_on_save = 1 + + call ale#events#QuitEvent(bufnr('')) + + " Simulate 2 seconds passing. + let b:ale_quitting -= 1000 + + call ale#events#SaveEvent(bufnr('')) + + AssertEqual 1, len(getloclist(0)) diff --git a/test/test_quitting_variable.vader b/test/test_quitting_variable.vader index 80b0a8dd..bef344a8 100644 --- a/test/test_quitting_variable.vader +++ b/test/test_quitting_variable.vader @@ -8,11 +8,15 @@ After: Restore unlet! b:ale_quitting + unlet! b:time_before + +Execute(QuitEvent should set b:ale_quitting some time from the clock): + let b:time_before = ale#util#ClockMilliseconds() -Execute(QuitEvent should set b:ale_quitting to 1): call ale#events#QuitEvent(bufnr('')) - AssertEqual 1, b:ale_quitting + Assert b:ale_quitting >= b:time_before + Assert b:ale_quitting <= ale#util#ClockMilliseconds() Execute(EnterEvent should set b:ale_quitting to 0): let b:ale_quitting = 1 @@ -20,3 +24,16 @@ Execute(EnterEvent should set b:ale_quitting to 0): call ale#events#EnterEvent(bufnr('')) AssertEqual 0, b:ale_quitting + +Execute(The QuitRecently function should work when the variable isn't set): + AssertEqual 0, ale#events#QuitRecently(bufnr('')) + +Execute(The QuitRecently function should return 1 when ALE quit recently): + let b:ale_quitting = ale#util#ClockMilliseconds() + + AssertEqual 1, ale#events#QuitRecently(bufnr('')) + +Execute(The QuitRecently function should return 0 when a second has passed): + let b:ale_quitting = ale#util#ClockMilliseconds() - 1001 + + AssertEqual 0, ale#events#QuitRecently(bufnr('')) |