aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-03-08 20:28:51 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-03-11 12:43:42 +0100
commit2bf08691609c763cc8a87e38ba24596ff8622a79 (patch)
treeb1f26dd5d5ad0ca4508dcc161c30490b58d1bc2b
parent91547823869cbd76bb3f24365919e94e8d72b528 (diff)
downloadrneovim-2bf08691609c763cc8a87e38ba24596ff8622a79.tar.gz
rneovim-2bf08691609c763cc8a87e38ba24596ff8622a79.tar.bz2
rneovim-2bf08691609c763cc8a87e38ba24596ff8622a79.zip
test: handle non-deterministic message cadence
-rw-r--r--test/functional/core/job_spec.lua44
1 files changed, 37 insertions, 7 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index e3c93d4b5a..e260069ea7 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -292,8 +292,16 @@ describe('jobs', function()
nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}')
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
local data = {n = 5, s = 'str', l = {1}}
- eq({'notification', 'stdout', {data, {'foo', ''}}}, next_msg())
- eq({'notification', 'stdout', {data, {''}}}, next_msg())
+ expect_msg_seq(
+ { {'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())
end)
@@ -310,11 +318,12 @@ describe('jobs', function()
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]])
expect_msg_seq(
{ {'notification', 'stdout', {5, {'foo', ''} } },
- {'notification', 'stdout', {5, {''} } }
+ {'notification', 'stdout', {5, {''} } },
},
-- Alternative sequence:
{ {'notification', 'stdout', {5, {'foo'} } },
- {'notification', 'stdout', {5, {'', ''} } }
+ {'notification', 'stdout', {5, {'', ''} } },
+ {'notification', 'stdout', {5, {''} } },
}
)
end)
@@ -417,7 +426,14 @@ describe('jobs', function()
let g:job_opts = {'on_stdout': Callback}
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)
it('jobstart() works with closures', function()
@@ -430,7 +446,14 @@ describe('jobs', function()
let g:job_opts = {'on_stdout': MkFun()}
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)
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)}}
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)
describe('jobwait', function()