aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-03-06 05:22:48 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-03-16 10:55:12 +0100
commitde475154770ef27374747b5401ef9fcbbe5f9a81 (patch)
treee9d8a33bd2e17fcd2b896fba64418bcec3aedf56
parentcca407b43e62d5e1abdfc59ae47b0e24eacc5807 (diff)
downloadrneovim-de475154770ef27374747b5401ef9fcbbe5f9a81.tar.gz
rneovim-de475154770ef27374747b5401ef9fcbbe5f9a81.tar.bz2
rneovim-de475154770ef27374747b5401ef9fcbbe5f9a81.zip
test: use luv.now() instead of os.time()
-rw-r--r--test/functional/autocmd/termclose_spec.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua
index 9918cbe4fa..0804579a4f 100644
--- a/test/functional/autocmd/termclose_spec.lua
+++ b/test/functional/autocmd/termclose_spec.lua
@@ -1,3 +1,4 @@
+local luv = require('luv')
local helpers = require('test.functional.helpers')(after_each)
local clear, command, nvim, nvim_dir =
@@ -39,13 +40,15 @@ describe('TermClose event', function()
.. [[ 'on_exit': {-> execute('let g:test_job_exited = 1')}}) ]])
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_started", 0)')) end)
- local start = os.time()
+ luv.update_time()
+ local start = luv.now()
command('call jobstop(g:test_job)')
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_exited", 0)')) end)
- local duration = os.time() - start
- -- nvim starts sending SIGTERM after KILL_TIMEOUT_MS
- ok(duration >= 2)
- ok(duration <= 4) -- <= 2 + delta because of slow CI
+ luv.update_time()
+ local duration = luv.now() - start
+ -- Nvim begins SIGTERM after KILL_TIMEOUT_MS.
+ ok(duration >= 2000)
+ ok(duration <= 4000) -- Epsilon for slow CI
end)
it('kills pty job trapping SIGHUP and SIGTERM', function()
@@ -58,13 +61,15 @@ describe('TermClose event', function()
.. [[ 'on_exit': {-> execute('let g:test_job_exited = 1')}}) ]])
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_started", 0)')) end)
- local start = os.time()
+ luv.update_time()
+ local start = luv.now()
command('call jobstop(g:test_job)')
retry(nil, nil, function() eq(1, eval('get(g:, "test_job_exited", 0)')) end)
- local duration = os.time() - start
- -- nvim starts sending kill after 2*KILL_TIMEOUT_MS
- ok(duration >= 4)
- ok(duration <= 7) -- <= 4 + delta because of slow CI
+ luv.update_time()
+ local duration = luv.now() - start
+ -- Nvim begins SIGKILL after (2 * KILL_TIMEOUT_MS).
+ ok(duration >= 4000)
+ ok(duration <= 7000) -- Epsilon for slow CI
end)
it('reports the correct <abuf>', function()