From eac0a41ae1aba77e1d017833425fa8132130df13 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 16 Feb 2017 23:18:57 +0000 Subject: #254 Add an option for logging the output of commands --- test/test_ale_info.vader | 64 ++++++++++++++++++++++++++++++++++++++++++ test/test_history_saving.vader | 14 +++++++++ 2 files changed, 78 insertions(+) (limited to 'test') diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader index 92025f23..ecea899b 100644 --- a/test/test_ale_info.vader +++ b/test/test_ale_info.vader @@ -41,6 +41,7 @@ After: unlet! g:globals_string unlet! g:command_header let g:ale_buffer_info = {} + let g:ale_history_log_output = 0 unlet! g:ale_testft_testlinter1_foo unlet! g:ale_testft_testlinter1_bar unlet! g:ale_testft2_testlinter2_foo @@ -218,3 +219,66 @@ Execute (ALEInfo command history should print exit codes correctly): \ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']', \ ], "\n"), \ g:output + +Given testft.testft2 (Empty buffer with two filetypes): +Execute (ALEInfo command history should print command output if logging is on): + let g:ale_history_log_output = 1 + + let g:ale_buffer_info[bufnr('%')] = { + \ 'history': [ + \ { + \ 'status': 'finished', + \ 'exit_code': 0, + \ 'job_id': 347, + \ 'command': 'first command', + \ 'output': ['some', 'first command output'], + \ }, + \ { + \ 'status': 'finished', + \ 'exit_code': 1, + \ 'job_id': 347, + \ 'command': ['/bin/bash', '\c', 'last command'], + \ 'output': ['different second command output'], + \ }, + \ { + \ 'status': 'finished', + \ 'exit_code': 0, + \ 'job_id': 347, + \ 'command': 'command with no output', + \ 'output': [], + \ }, + \ ], + \} + + call ale#linter#Define('testft', g:testlinter1) + call ale#linter#Define('testft2', g:testlinter2) + redir => g:output + silent ALEInfo + redir END + AssertEqual + \ join([ + \ '', + \ ' Current Filetype: testft.testft2', + \ 'Available Linters: [''testlinter1'', ''testlinter2'']', + \ ' Enabled Linters: [''testlinter1'', ''testlinter2'']', + \ ' Linter Variables:', + \ g:globals_string . g:command_header, + \ '(finished - exit code 0) ''first command''', + \ '', + \ '<<>>', + \ 'some', + \ 'first command output', + \ '<<>>', + \ '', + \ '(finished - exit code 1) [''/bin/bash'', ''\c'', ''last command'']', + \ '', + \ '<<>>', + \ 'different second command output', + \ '<<>>', + \ '', + \ '(finished - exit code 0) ''command with no output''', + \ '', + \ '<<>>', + \ '', + \ ], "\n"), + \ g:output diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader index 23b9170b..303a02fa 100644 --- a/test/test_history_saving.vader +++ b/test/test_history_saving.vader @@ -17,6 +17,7 @@ Before: After: let g:ale_history_enabled = 1 + let g:ale_history_log_output = 0 unlet g:history let g:ale_buffer_info = {} let g:ale_max_buffer_history_size = 20 @@ -52,6 +53,19 @@ Execute(History should be not set when disabled): AssertEqual 0, len(g:ale_buffer_info[bufnr('%')].history) +Execute(History should include command output if logging is enabled): + AssertEqual 'foobar', &filetype + + let g:ale_history_log_output = 1 + + call ale#Lint() + call ale#engine#WaitForJobs(2000) + + let g:history = g:ale_buffer_info[bufnr('%')].history + + AssertEqual 1, len(g:history) + AssertEqual ['command history test'], g:history[0].output + Execute(History items should be popped after going over the max): let g:ale_buffer_info[1] = { \ 'history': map(range(20), '{''status'': ''started'', ''job_id'': v:val, ''command'': ''foobar''}'), -- cgit v1.2.3