make_spec.lua (2417B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 4 local clear = n.clear 5 local eval = n.eval 6 local has_powershell = n.has_powershell 7 local matches = t.matches 8 local api = n.api 9 local testprg = n.testprg 10 11 describe(':make', function() 12 clear() 13 before_each(function() 14 clear() 15 end) 16 17 describe('with powershell', function() 18 if not has_powershell() then 19 pending('not tested; powershell was not found', function() end) 20 return 21 end 22 before_each(function() 23 n.set_shell_powershell() 24 end) 25 26 it('captures stderr & non zero exit code using "commands" #14349', function() 27 api.nvim_set_option_value('makeprg', testprg('shell-test') .. ' foo', {}) 28 local out = eval('execute("make")') 29 -- Error message is captured in the file and printed in the footer 30 matches('[\r\n]+.*[\r\n]+%(1 of 1%)%: Unknown first argument%: foo', out) 31 end) 32 33 it('captures stderr & zero exit code using "commands" #14349', function() 34 api.nvim_set_option_value('makeprg', testprg('shell-test'), {}) 35 local out = eval('execute("make")') 36 -- Ensure there are no "shell returned X" messages between 37 -- command and last line (indicating zero exit) 38 matches('[\n]+%(1 of 1%)%: ready [$]', out) 39 end) 40 41 it('captures stderr & non zero exit code using "cmdlets"', function() 42 api.nvim_set_option_value( 43 'shellpipe', 44 '2>&1 | Tee-Object -FilePath %s; exit $LastExitCode', 45 {} 46 ) 47 api.nvim_set_option_value('makeprg', testprg('shell-test') .. ' foo', {}) 48 local out = eval('execute("make")') 49 -- Error message is captured in the file and printed in the footer 50 matches( 51 '[\r\n]+.*[\r\n]+.*Unknown first argument%: foo%^%[%[0m[\r\n]+shell returned 3[\r\n]+%(1 of 1%)%: Unknown first argument%: foo', 52 out 53 ) 54 end) 55 56 it('captures stderr & zero exit code using "cmdlets"', function() 57 api.nvim_set_option_value( 58 'shellpipe', 59 '2>&1 | Tee-Object -FilePath %s; exit $LastExitCode', 60 {} 61 ) 62 api.nvim_set_option_value('makeprg', testprg('shell-test'), {}) 63 local out = eval('execute("make")') 64 -- Ensure there are no "shell returned X" messages between 65 -- command and last line (indicating zero exit) 66 matches('.*ready [$]%s+%^%[%[0m', out) 67 matches('\n.*%: ready [$]', out) 68 end) 69 end) 70 end)