mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
test: handle non-deterministic message cadence
This commit is contained in:
@@ -292,8 +292,16 @@ describe('jobs', function()
|
|||||||
nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}')
|
nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}')
|
||||||
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
|
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
|
||||||
local data = {n = 5, s = 'str', l = {1}}
|
local data = {n = 5, s = 'str', l = {1}}
|
||||||
eq({'notification', 'stdout', {data, {'foo', ''}}}, next_msg())
|
expect_msg_seq(
|
||||||
eq({'notification', 'stdout', {data, {''}}}, next_msg())
|
{ {'notification', 'stdout', {data, {'foo', ''}}},
|
||||||
|
{'notification', 'stdout', {data, {''}}},
|
||||||
|
},
|
||||||
|
-- Alternative sequence:
|
||||||
|
{ {'notification', 'stdout', {data, {'foo'}}},
|
||||||
|
{'notification', 'stdout', {data, {'', ''}}},
|
||||||
|
{'notification', 'stdout', {data, {''}}},
|
||||||
|
}
|
||||||
|
)
|
||||||
eq({'notification', 'exit', {data, 0}}, next_msg())
|
eq({'notification', 'exit', {data, 0}}, next_msg())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -310,11 +318,12 @@ describe('jobs', function()
|
|||||||
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
|
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
|
||||||
expect_msg_seq(
|
expect_msg_seq(
|
||||||
{ {'notification', 'stdout', {5, {'foo', ''} } },
|
{ {'notification', 'stdout', {5, {'foo', ''} } },
|
||||||
{'notification', 'stdout', {5, {''} } }
|
{'notification', 'stdout', {5, {''} } },
|
||||||
},
|
},
|
||||||
-- Alternative sequence:
|
-- Alternative sequence:
|
||||||
{ {'notification', 'stdout', {5, {'foo'} } },
|
{ {'notification', 'stdout', {5, {'foo'} } },
|
||||||
{'notification', 'stdout', {5, {'', ''} } }
|
{'notification', 'stdout', {5, {'', ''} } },
|
||||||
|
{'notification', 'stdout', {5, {''} } },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
@@ -417,7 +426,14 @@ describe('jobs', function()
|
|||||||
let g:job_opts = {'on_stdout': Callback}
|
let g:job_opts = {'on_stdout': Callback}
|
||||||
call jobstart('echo "some text"', g:job_opts)
|
call jobstart('echo "some text"', g:job_opts)
|
||||||
]])
|
]])
|
||||||
eq({'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}}, next_msg())
|
expect_msg_seq(
|
||||||
|
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
|
||||||
|
},
|
||||||
|
-- Alternative sequence:
|
||||||
|
{ {'notification', '1', {'foo', 'bar', {'some text'}, 'stdout'}},
|
||||||
|
{'notification', '1', {'foo', 'bar', {'', ''}, 'stdout'}},
|
||||||
|
}
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('jobstart() works with closures', function()
|
it('jobstart() works with closures', function()
|
||||||
@@ -430,7 +446,14 @@ describe('jobs', function()
|
|||||||
let g:job_opts = {'on_stdout': MkFun()}
|
let g:job_opts = {'on_stdout': MkFun()}
|
||||||
call jobstart('echo "some text"', g:job_opts)
|
call jobstart('echo "some text"', g:job_opts)
|
||||||
]])
|
]])
|
||||||
eq({'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}}, next_msg())
|
expect_msg_seq(
|
||||||
|
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
|
||||||
|
},
|
||||||
|
-- Alternative sequence:
|
||||||
|
{ {'notification', '1', {'foo', 'bar', {'some text'}, 'stdout'}},
|
||||||
|
{'notification', '1', {'foo', 'bar', {'', ''}, 'stdout'}},
|
||||||
|
}
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('jobstart() works when closure passed directly to `jobstart`', function()
|
it('jobstart() works when closure passed directly to `jobstart`', function()
|
||||||
@@ -438,7 +461,14 @@ describe('jobs', function()
|
|||||||
let g:job_opts = {'on_stdout': {id, data, event -> rpcnotify(g:channel, '1', 'foo', 'bar', Normalize(data), event)}}
|
let g:job_opts = {'on_stdout': {id, data, event -> rpcnotify(g:channel, '1', 'foo', 'bar', Normalize(data), event)}}
|
||||||
call jobstart('echo "some text"', g:job_opts)
|
call jobstart('echo "some text"', g:job_opts)
|
||||||
]])
|
]])
|
||||||
eq({'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}}, next_msg())
|
expect_msg_seq(
|
||||||
|
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
|
||||||
|
},
|
||||||
|
-- Alternative sequence:
|
||||||
|
{ {'notification', '1', {'foo', 'bar', {'some text'}, 'stdout'}},
|
||||||
|
{'notification', '1', {'foo', 'bar', {'', ''}, 'stdout'}},
|
||||||
|
}
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('jobwait', function()
|
describe('jobwait', function()
|
||||||
|
Reference in New Issue
Block a user