From 9d6bffd517e4b262b85c27a4ff620a2b1aae4a68 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 17 Jan 2019 14:20:23 +0100 Subject: tests: fix Test_help_tagjump() The Vim version of Test_help_tagjump() tests for `:help sm?le` here. That command got removed from Nvim, so the test was changed to check against `:help sp?it` instead. The new test already handled the case that on Win `:h split` would jump to the entry for split() and on all other systems to the entry for :split. Then this commit happened: bb3aa824b lua/stdlib: vim.inspect, string functions Since then `:h split` would jump to split() for macOS as well! I'm not sure why. Anyway, instead of adding another check for has('mac'), we change the test once more to be more akin to the original test. Instead of testing for :smile, which is exclusive to Vim, we check against :checkhealth, which is exclusive to Nvim. --- src/nvim/testdir/test_help_tagjump.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index c873487b92..a6494c531c 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -28,9 +28,9 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*quotestar\*') helpclose - help sp?it + help ch?ckhealth call assert_equal("help", &filetype) - call assert_true(getline('.') =~ '\*'.(has('win32') ? 'split()' : ':split').'\*') + call assert_true(getline('.') =~ '\*:checkhealth\*') helpclose help :? -- cgit From 0afd452ef19ed08db8e74d72c0316bc40ac9c9bd Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 16 Jan 2019 21:20:38 +0100 Subject: tests: load-adjust timer tests (oldtest) --- src/nvim/testdir/load.vim | 30 ++++++++++++++++++++++++++++++ src/nvim/testdir/test_autocmd.vim | 6 ++++-- src/nvim/testdir/test_lambda.vim | 16 +++++++++++----- src/nvim/testdir/test_timers.vim | 13 +++++++++---- 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 src/nvim/testdir/load.vim diff --git a/src/nvim/testdir/load.vim b/src/nvim/testdir/load.vim new file mode 100644 index 0000000000..2e01338dd0 --- /dev/null +++ b/src/nvim/testdir/load.vim @@ -0,0 +1,30 @@ +function! s:load_factor() abort + let timeout = 200 + let times = [] + + for _ in range(5) + let g:val = 0 + call timer_start(timeout, {-> nvim_set_var('val', 1)}) + let start = reltime() + while 1 + sleep 10m + if g:val == 1 + let g:waited_in_ms = float2nr(reltimefloat(reltime(start)) * 1000) + break + endif + endwhile + call insert(times, g:waited_in_ms, 0) + endfor + + let longest = max(times) + let factor = (longest + 50.0) / timeout + + return factor +endfunction + +" Compute load factor only once. +let s:load_factor = s:load_factor() + +function! LoadAdjust(num) abort + return float2nr(ceil(a:num * s:load_factor)) +endfunction diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 253d6750ed..f1fb8e67b9 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -18,6 +18,8 @@ func Test_vim_did_enter() endfunc if has('timers') + source load.vim + func ExitInsertMode(id) call feedkeys("\") endfunc @@ -29,7 +31,7 @@ if has('timers') let g:triggered = 0 au CursorHoldI * let g:triggered += 1 set updatetime=20 - call timer_start(100, 'ExitInsertMode') + call timer_start(LoadAdjust(100), 'ExitInsertMode') call feedkeys('a', 'x!') call assert_equal(1, g:triggered) au! CursorHoldI @@ -40,7 +42,7 @@ if has('timers') let g:triggered = 0 au CursorHoldI * let g:triggered += 1 set updatetime=20 - call timer_start(100, 'ExitInsertMode') + call timer_start(LoadAdjust(100), 'ExitInsertMode') " CursorHoldI does not trigger after CTRL-X call feedkeys("a\", 'x!') call assert_equal(0, g:triggered) diff --git a/src/nvim/testdir/test_lambda.vim b/src/nvim/testdir/test_lambda.vim index 6e07c874b4..ada25da4a8 100644 --- a/src/nvim/testdir/test_lambda.vim +++ b/src/nvim/testdir/test_lambda.vim @@ -23,6 +23,8 @@ function! Test_lambda_with_timer() return endif + source load.vim + let s:n = 0 let s:timer_id = 0 function! s:Foo() @@ -31,15 +33,19 @@ function! Test_lambda_with_timer() endfunction call s:Foo() - sleep 210ms + sleep 210m " do not collect lambda call test_garbagecollect_now() - let m = s:n - sleep 230ms + let m = LoadAdjust(s:n) + sleep 230m call timer_stop(s:timer_id) + + let n = LoadAdjust(s:n) + let nine = LoadAdjust(9) + call assert_true(m > 1) - call assert_true(s:n > m + 1) - call assert_true(s:n < 9) + call assert_true(n > m + 1) + call assert_true(n < nine) endfunction function! Test_lambda_with_partial() diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index cdfdd473b9..62ddad5dce 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -5,6 +5,7 @@ if !has('timers') endif source shared.vim +source load.vim func MyHandler(timer) let g:val += 1 @@ -14,13 +15,17 @@ func MyHandlerWithLists(lists, timer) let x = string(a:lists) endfunc +func s:assert_inrange(lower, upper, actual) + return assert_inrange(a:lower, LoadAdjust(a:upper), a:actual) +endfunc + func Test_oneshot() let g:val = 0 let timer = timer_start(50, 'MyHandler') let slept = WaitFor('g:val == 1') call assert_equal(1, g:val) if has('reltime') - call assert_inrange(40, 120, slept) + call s:assert_inrange(40, 120, slept) else call assert_inrange(20, 120, slept) endif @@ -32,7 +37,7 @@ func Test_repeat_three() let slept = WaitFor('g:val == 3') call assert_equal(3, g:val) if has('reltime') - call assert_inrange(120, 250, slept) + call s:assert_inrange(120, 250, slept) else call assert_inrange(80, 200, slept) endif @@ -58,7 +63,7 @@ func Test_with_partial_callback() let slept = WaitFor('g:val == 1') call assert_equal(1, g:val) if has('reltime') - call assert_inrange(40, 130, slept) + call s:assert_inrange(40, 130, slept) else call assert_inrange(20, 100, slept) endif @@ -121,7 +126,7 @@ func Test_paused() let slept = WaitFor('g:val == 1') call assert_equal(1, g:val) if has('reltime') - call assert_inrange(0, 140, slept) + call s:assert_inrange(0, 140, slept) else call assert_inrange(0, 10, slept) endif -- cgit From f2e996b9918de2bf23523ffe5b76c3718991158f Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 16 Jan 2019 21:21:10 +0100 Subject: tests: load-adjust timer tests (functionaltest) --- test/functional/eval/timer_spec.lua | 29 ++++++++++++++------------- test/functional/helpers.lua | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index 124b9625c3..ce0e24d8d7 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -4,6 +4,7 @@ local feed, eq, eval = helpers.feed, helpers.eq, helpers.eval local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs local curbufmeths = helpers.curbufmeths +local load_adjust = helpers.load_adjust describe('timers', function() before_each(function() @@ -19,14 +20,14 @@ describe('timers', function() it('works one-shot', function() command("call timer_start(50, 'MyHandler')") eq(0,eval("g:val")) - run(nil, nil, nil, 200) + run(nil, nil, nil, load_adjust(200)) eq(1,eval("g:val")) end) it('works one-shot when repeat=0', function() command("call timer_start(50, 'MyHandler', {'repeat': 0})") eq(0,eval("g:val")) - run(nil, nil, nil, 200) + run(nil, nil, nil, load_adjust(200)) eq(1,eval("g:val")) end) @@ -34,7 +35,7 @@ describe('timers', function() it('works with repeat two', function() command("call timer_start(50, 'MyHandler', {'repeat': 2})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(2,eval("g:val")) end) @@ -42,14 +43,14 @@ describe('timers', function() command("call timer_start(50, 'MyHandler', {'repeat': 2})") nvim_async("command", "sleep 10") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(2,eval("g:val")) end) it('works with zero timeout', function() -- timer_start does still not invoke the callback immediately eq(0,eval("[timer_start(0, 'MyHandler', {'repeat': 1000}), g:val][1]")) - run(nil, nil, nil, 400) + run(nil, nil, nil, load_adjust(400)) eq(1000,eval("g:val")) end) @@ -58,18 +59,18 @@ describe('timers', function() -- this also tests that remote requests works during sleep eval("timer_start(50, 'MyHandler', {'repeat': 2})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(2,eval("g:val")) end) it('are paused when event processing is disabled', function() command("call timer_start(50, 'MyHandler', {'repeat': -1})") - run(nil, nil, nil, 100) + run(nil, nil, nil, load_adjust(100)) local count = eval("g:val") -- shows two line error message and thus invokes the return prompt. -- if we start to allow event processing here, we need to change this test. feed(':throw "fatal error"') - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) feed("") local diff = eval("g:val") - count assert(0 <= diff and diff <= 4, @@ -79,7 +80,7 @@ describe('timers', function() it('are triggered in blocking getchar() call', function() command("call timer_start(50, 'MyHandler', {'repeat': -1})") nvim_async("command", "let g:c = getchar()") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) feed("c") local count = eval("g:val") assert(count >= 3, 'expected count >= 3, got: '..tostring(count)) @@ -137,10 +138,10 @@ describe('timers', function() it('can be stopped', function() local t = eval("timer_start(50, 'MyHandler', {'repeat': -1})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) funcs.timer_stop(t) local count = eval("g:val") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) local count2 = eval("g:val") -- when count is eval:ed after timer_stop this should be non-racy eq(count, count2) @@ -161,7 +162,7 @@ describe('timers', function() ]]) command("call timer_start(50, 'MyHandler', {'repeat': -1})") eq(0,eval("g:val")) - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(3,eval("g:val")) end) @@ -174,7 +175,7 @@ describe('timers', function() ]]) command("call timer_start(20, 'MyHandler', {'repeat': 3})") command("call timer_start(40, 'MyHandler2', {'repeat': 2})") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(3,eval("g:val")) eq(2,eval("g:val2")) end) @@ -189,7 +190,7 @@ describe('timers', function() endfunc ]]) command("call timer_start(5, 'MyHandler', {'repeat': 1})") - run(nil, nil, nil, 300) + run(nil, nil, nil, load_adjust(300)) eq(1,eval("g:val")) end) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 851f3e720e..edb1580987 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -679,6 +679,44 @@ local function alter_slashes(obj) end end +local function compute_load_factor() + local timeout = 200 + local times = {} + + clear() + + for _ = 1, 5 do + source([[ + let g:val = 0 + call timer_start(200, {-> nvim_set_var('val', 1)}) + let start = reltime() + while 1 + sleep 10m + if g:val == 1 + let g:waited_in_ms = float2nr(reltimefloat(reltime(start)) * 1000) + break + endif + endwhile + ]]) + table.insert(times, nvim_eval('g:waited_in_ms')) + end + + session:close() + session = nil + + local longest = math.max(unpack(times)) + local factor = (longest + 50.0) / timeout + + return factor +end + +-- Compute load factor only once. +local load_factor = compute_load_factor() + +local function load_adjust(num) + return math.ceil(num * load_factor) +end + local module = { NIL = mpack.NIL, alter_slashes = alter_slashes, @@ -720,6 +758,7 @@ local module = { meths = meths, missing_provider = missing_provider, mkdir = lfs.mkdir, + load_adjust = load_adjust, near = near, neq = neq, new_pipename = new_pipename, -- cgit From 06785da5b611d750314caf152a5acdaa60ddf1b7 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 30 Nov 2018 03:30:11 +0100 Subject: ci: switch to Xcode 10.1 / macOS 10.13 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6b9516b6e..bcc5c11930 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,10 +70,10 @@ jobs: env: BUILD_32BIT=ON - os: osx compiler: clang - osx_image: xcode9.4 # macOS 10.13 + osx_image: xcode10.1 # macOS 10.13 - os: osx compiler: gcc - osx_image: xcode9.4 # macOS 10.13 + osx_image: xcode10.1 # macOS 10.13 - if: branch = master os: linux env: CI_TARGET=lint -- cgit