aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-04-02 11:26:44 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-04-02 11:33:48 -0300
commit6abde99ff243d3ead24c26eff24121140a039fb7 (patch)
tree187dccd882d8ff87a4cc253b2d92a5bfc2f830ae
parentd487dc1a9a63bb1d6d12658ed7ed24382b55a4b1 (diff)
downloadrneovim-6abde99ff243d3ead24c26eff24121140a039fb7.tar.gz
rneovim-6abde99ff243d3ead24c26eff24121140a039fb7.tar.bz2
rneovim-6abde99ff243d3ead24c26eff24121140a039fb7.zip
test: Remove indeterminism from `jobwait` tests
- Use on_exit instead of on_stdout since there's no guarantee that the OS will send the data in time(It fails randomly in slow environments such as travis/valgrind) - Increase the timeout gap for the "jobwait with timeout" test
-rw-r--r--test/functional/job/job_spec.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index c1c559eb34..c517ae4c1b 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -200,19 +200,22 @@ describe('jobs', function()
it('will run callbacks while waiting', function()
source([[
let g:dict = {'id': 10}
- let g:l = []
- function g:dict.on_stdout(id, data)
- call add(g:l, a:data[0])
+ let g:exits = 0
+ function g:dict.on_exit(id, code)
+ if a:code != 5
+ throw 'Error!'
+ endif
+ let g:exits += 1
endfunction
call jobwait([
- \ jobstart([&sh, '-c', 'sleep 0.010; echo 4'], g:dict),
- \ jobstart([&sh, '-c', 'sleep 0.030; echo 5'], g:dict),
- \ jobstart([&sh, '-c', 'sleep 0.050; echo 6'], g:dict),
- \ jobstart([&sh, '-c', 'sleep 0.070; echo 7'], g:dict)
+ \ jobstart([&sh, '-c', 'sleep 0.010; exit 5'], g:dict),
+ \ jobstart([&sh, '-c', 'sleep 0.030; exit 5'], g:dict),
+ \ jobstart([&sh, '-c', 'sleep 0.050; exit 5'], g:dict),
+ \ jobstart([&sh, '-c', 'sleep 0.070; exit 5'], g:dict)
\ ])
- call rpcnotify(g:channel, 'wait', g:l)
+ call rpcnotify(g:channel, 'wait', g:exits)
]])
- eq({'notification', 'wait', {{'4', '5', '6', '7'}}}, next_msg())
+ eq({'notification', 'wait', {4}}, next_msg())
end)
it('will return status codes in the order of passed ids', function()
@@ -250,8 +253,8 @@ describe('jobs', function()
it('will return -1 if the wait timed out', function()
source([[
call rpcnotify(g:channel, 'wait', jobwait([
- \ jobstart([&sh, '-c', 'sleep 0.05; exit 4']),
- \ jobstart([&sh, '-c', 'sleep 0.3; exit 5']),
+ \ jobstart([&sh, '-c', 'exit 4']),
+ \ jobstart([&sh, '-c', 'sleep 10000; exit 5']),
\ ], 100))
]])
eq({'notification', 'wait', {{4, -1}}}, next_msg())