robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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