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