test(core/startup_spec): use retry() instead of jobwait() (#24481)

This should work on Windows.
This commit is contained in:
zeertzjq 2023-07-25 20:32:59 +08:00 committed by GitHub
parent aaa151d506
commit 898384ac69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ local ok = helpers.ok
local eq = helpers.eq local eq = helpers.eq
local matches = helpers.matches local matches = helpers.matches
local eval = helpers.eval local eval = helpers.eval
local exec = helpers.exec
local exec_capture = helpers.exec_capture local exec_capture = helpers.exec_capture
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local feed = helpers.feed local feed = helpers.feed
@ -21,7 +22,6 @@ local nvim_set = helpers.nvim_set
local read_file = helpers.read_file local read_file = helpers.read_file
local retry = helpers.retry local retry = helpers.retry
local rmdir = helpers.rmdir local rmdir = helpers.rmdir
local skip = helpers.skip
local sleep = helpers.sleep local sleep = helpers.sleep
local startswith = helpers.startswith local startswith = helpers.startswith
local write_file = helpers.write_file local write_file = helpers.write_file
@ -462,15 +462,23 @@ describe('startup', function()
end) end)
it('-r works without --headless in PTY #23294', function() it('-r works without --headless in PTY #23294', function()
skip(is_os('win')) exec([[
eq({ 0 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart({...}, { func Normalize(data) abort
pty = true, " Windows: remove ^M and term escape sequences
stdout_buffered = true, return map(a:data, 'substitute(substitute(v:val, "\r", "", "g"), "\x1b\\%(\\]\\d\\+;.\\{-}\x07\\|\\[.\\{-}[\x40-\x7E]\\)", "", "g")')
on_stdout = function(_, data, _) endfunc
_G.Recovery_stdout = data func OnOutput(id, data, event) dict
end, let g:stdout = Normalize(a:data)
}) })]], nvim_prog, '-u', 'NONE', '-i', 'NONE', '-r')) endfunc
matches('Swap files found:\r*', exec_lua('return _G.Recovery_stdout[1]')) call jobstart([v:progpath, '-u', 'NONE', '-i', 'NONE', '-r'], {
\ 'pty': v:true,
\ 'stdout_buffered': v:true,
\ 'on_stdout': function('OnOutput'),
\ })
]])
retry(nil, nil, function()
eq('Swap files found:', eval('g:stdout[0]'))
end)
end) end)
it('fixed hang issue with --headless (#11386)', function() it('fixed hang issue with --headless (#11386)', function()