diff options
author | James McCoy <jamessan@jamessan.com> | 2017-06-05 23:17:54 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-06-06 06:15:16 -0400 |
commit | dafc14b9691dfa9af143c0372f84b9288163c30a (patch) | |
tree | d6ab31ecae0ef67b2355f529070d31c2ec24ec01 /src | |
parent | cb8efa4fefd845e6cf42c9d14384bd291327cfe8 (diff) | |
download | rneovim-dafc14b9691dfa9af143c0372f84b9288163c30a.tar.gz rneovim-dafc14b9691dfa9af143c0372f84b9288163c30a.tar.bz2 rneovim-dafc14b9691dfa9af143c0372f84b9288163c30a.zip |
vim-patch:8.0.0477
Problem: The client-server test may hang when failing.
Solution: Set a timer. Add assert_report()
https://github.com/vim/vim/commit/42205551b140bee8b419b24abe210f56bb80b35e
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 11 | ||||
-rw-r--r-- | src/nvim/eval.lua | 1 | ||||
-rw-r--r-- | src/nvim/testdir/runtest.vim | 108 |
3 files changed, 72 insertions, 48 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index be08e6a238..072adb4ebb 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6807,6 +6807,17 @@ static void f_assert_notequal(typval_T *argvars, typval_T *rettv, FunPtr fptr) assert_equal_common(argvars, ASSERT_NOTEQUAL); } +/// "assert_report(msg) +static void f_assert_report(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + garray_T ga; + + prepare_assert_error(&ga); + ga_concat(&ga, (const char_u *)tv_get_string(&argvars[0])); + assert_error(&ga); + ga_clear(&ga); +} + /// "assert_exception(string[, msg])" function static void f_assert_exception(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 334e10eb6c..30766a0734 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -33,6 +33,7 @@ return { assert_match={args={2, 3}}, assert_notequal={args={2, 3}}, assert_notmatch={args={2, 3}}, + assert_report={args=1}, assert_true={args={1, 2}}, atan={args=1, func="float_op_wrapper", data="&atan"}, atan2={args=2}, diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 9ae53c500f..fa3c0a6ad0 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -76,7 +76,7 @@ set listchars=eol:$ " Prevent Nvim log from writing to stderr. let $NVIM_LOG_FILE='Xnvim.log' -function RunTheTest(test) +func RunTheTest(test) echo 'Executing ' . a:test if exists("*SetUp") call SetUp() @@ -113,6 +113,60 @@ function RunTheTest(test) set nomodified endfunc +func AfterTheTest() + if len(v:errors) > 0 + let s:fail += 1 + call add(s:errors, 'Found errors in ' . s:test . ':') + call extend(s:errors, v:errors) + let v:errors = [] + endif +endfunc + +" This function can be called by a test if it wants to abort testing. +func FinishTesting() + call AfterTheTest() + + " Don't write viminfo on exit. + set viminfo= + + if s:fail == 0 + " Success, create the .res file so that make knows it's done. + exe 'split ' . fnamemodify(g:testname, ':r') . '.res' + write + endif + + if len(s:errors) > 0 + " Append errors to test.log + split test.log + call append(line('$'), '') + call append(line('$'), 'From ' . g:testname . ':') + call append(line('$'), s:errors) + write + endif + + let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test') + echo message + call add(s:messages, message) + if s:fail > 0 + let message = s:fail . ' FAILED:' + echo message + call add(s:messages, message) + call extend(s:messages, s:errors) + endif + + " Add SKIPPED messages + call extend(s:messages, s:skipped) + + " Append messages to the file "messages" + split messages + call append(line('$'), '') + call append(line('$'), 'From ' . g:testname . ':') + call append(line('$'), s:messages) + write + + qall! +endfunc + " Source the test script. First grab the file name, in case the script " navigates away. g:testname can be used by the tests. let g:testname = expand('%') @@ -157,56 +211,14 @@ for s:test in sort(s:tests) call RunTheTest(s:test) if len(v:errors) > 0 && index(s:flaky, s:test) >= 0 - call add(s:messages, 'Flaky test failed, running it again') - let v:errors = [] - call RunTheTest(s:test) - endif - - if len(v:errors) > 0 - let s:fail += 1 - call add(s:errors, 'Found errors in ' . s:test . ':') - call extend(s:errors, v:errors) + call add(s:messages, 'Flaky test failed, running it again') let v:errors = [] + call RunTheTest(s:test) endif + call AfterTheTest() endfor -" Don't write viminfo on exit. -set viminfo= - -if s:fail == 0 - " Success, create the .res file so that make knows it's done. - exe 'split ' . fnamemodify(g:testname, ':r') . '.res' - write -endif - -if len(s:errors) > 0 - " Append errors to test.log - split test.log - call append(line('$'), '') - call append(line('$'), 'From ' . g:testname . ':') - call append(line('$'), s:errors) - write -endif - -let message = 'Executed ' . s:done . (s:done > 1 ? ' tests': ' test') -echo message -call add(s:messages, message) -if s:fail > 0 - let message = s:fail . ' FAILED' - echo message - call add(s:messages, message) - call extend(s:messages, s:errors) -endif - -" Add SKIPPED messages -call extend(s:messages, s:skipped) - -" Append messages to the file "messages" -split messages -call append(line('$'), '') -call append(line('$'), 'From ' . g:testname . ':') -call append(line('$'), s:messages) -write +call FinishTesting() -qall! +" vim: shiftwidth=2 sts=2 expandtab |