2015-11-29 17:35:35 +01:00
|
|
|
" This script is sourced while editing the .vim file with the tests.
|
|
|
|
" When the script is successful the .res file will be created.
|
|
|
|
" Errors are appended to the test.log file.
|
|
|
|
"
|
2016-02-20 14:41:40 +01:00
|
|
|
" To execute only specific test functions, add a second argument. It will be
|
|
|
|
" matched against the names of the Test_ funtion. E.g.:
|
|
|
|
" ../vim -u NONE -S runtest.vim test_channel.vim open_delay
|
|
|
|
" The output can be found in the "messages" file.
|
|
|
|
"
|
2015-11-29 17:35:35 +01:00
|
|
|
" The test script may contain anything, only functions that start with
|
|
|
|
" "Test_" are special. These will be invoked and should contain assert
|
|
|
|
" functions. See test_assert.vim for an example.
|
|
|
|
"
|
|
|
|
" It is possible to source other files that contain "Test_" functions. This
|
|
|
|
" can speed up testing, since Vim does not need to restart. But be careful
|
|
|
|
" that the tests do not interfere with each other.
|
|
|
|
"
|
|
|
|
" If an error cannot be detected properly with an assert function add the
|
|
|
|
" error to the v:errors list:
|
|
|
|
" call add(v:errors, 'test foo failed: Cannot find xyz')
|
|
|
|
"
|
|
|
|
" If preparation for each Test_ function is needed, define a SetUp function.
|
|
|
|
" It will be called before each Test_ function.
|
|
|
|
"
|
|
|
|
" If cleanup after each Test_ function is needed, define a TearDown function.
|
|
|
|
" It will be called after each Test_ function.
|
2016-02-13 14:06:14 +01:00
|
|
|
"
|
|
|
|
" When debugging a test it can be useful to add messages to v:errors:
|
2019-01-06 15:29:57 +01:00
|
|
|
" call add(v:errors, "this happened")
|
2016-02-13 14:06:14 +01:00
|
|
|
|
2015-11-29 17:35:35 +01:00
|
|
|
|
|
|
|
" Without the +eval feature we can't run these tests, bail out.
|
2015-12-28 14:44:10 +01:00
|
|
|
so small.vim
|
2015-11-29 17:35:35 +01:00
|
|
|
|
|
|
|
" Check that the screen size is at least 24 x 80 characters.
|
|
|
|
if &lines < 24 || &columns < 80
|
|
|
|
let error = 'Screen size too small! Tests require at least 24 lines with 80 characters'
|
|
|
|
echoerr error
|
|
|
|
split test.log
|
|
|
|
$put =error
|
|
|
|
w
|
|
|
|
cquit
|
|
|
|
endif
|
|
|
|
|
2019-06-06 18:05:25 +02:00
|
|
|
if has('reltime')
|
|
|
|
let s:start_time = reltime()
|
|
|
|
endif
|
|
|
|
|
2016-07-12 22:51:22 +02:00
|
|
|
" Common with all tests on all systems.
|
|
|
|
source setup.vim
|
|
|
|
|
2015-12-30 15:49:05 +01:00
|
|
|
" For consistency run all tests with 'nocompatible' set.
|
|
|
|
" This also enables use of line continuation.
|
|
|
|
set nocp viminfo+=nviminfo
|
|
|
|
|
2019-01-24 17:59:39 +01:00
|
|
|
" Use utf-8 by default, instead of whatever the system default happens to be.
|
2019-02-22 14:38:58 +01:00
|
|
|
" Individual tests can overrule this at the top of the file and use
|
|
|
|
" g:orig_encoding if needed.
|
|
|
|
let g:orig_encoding = &encoding
|
2019-01-24 17:59:39 +01:00
|
|
|
set encoding=utf-8
|
2016-07-21 20:33:32 +02:00
|
|
|
|
2018-10-07 15:42:07 +02:00
|
|
|
" REDIR_TEST_TO_NULL has a very permissive SwapExists autocommand which is for
|
|
|
|
" the test_name.vim file itself. Replace it here with a more restrictive one,
|
|
|
|
" so we still catch mistakes.
|
|
|
|
let s:test_script_fname = expand('%')
|
|
|
|
au! SwapExists * call HandleSwapExists()
|
|
|
|
func HandleSwapExists()
|
|
|
|
" Only ignore finding a swap file for the test script (the user might be
|
|
|
|
" editing it and do ":make test_name") and the output file.
|
|
|
|
if expand('<afile>') == 'messages' || expand('<afile>') =~ s:test_script_fname
|
|
|
|
let v:swapchoice = 'e'
|
|
|
|
endif
|
|
|
|
endfunc
|
|
|
|
|
2017-02-01 23:17:36 +01:00
|
|
|
" Avoid stopping at the "hit enter" prompt
|
|
|
|
set nomore
|
|
|
|
|
2015-12-30 15:49:05 +01:00
|
|
|
" Output all messages in English.
|
|
|
|
lang mess C
|
|
|
|
|
2016-01-16 22:47:23 +01:00
|
|
|
" Always use forward slashes.
|
|
|
|
set shellslash
|
|
|
|
|
2016-01-09 22:28:33 +01:00
|
|
|
let s:srcdir = expand('%:p:h:h')
|
|
|
|
|
2016-05-25 21:23:21 +02:00
|
|
|
" Prepare for calling test_garbagecollect_now().
|
2016-04-14 12:46:51 +02:00
|
|
|
let v:testing = 1
|
|
|
|
|
2016-01-09 22:28:33 +01:00
|
|
|
" Support function: get the alloc ID by name.
|
|
|
|
function GetAllocId(name)
|
|
|
|
exe 'split ' . s:srcdir . '/alloc.h'
|
2016-01-15 20:53:38 +01:00
|
|
|
let top = search('typedef enum')
|
|
|
|
if top == 0
|
|
|
|
call add(v:errors, 'typedef not found in alloc.h')
|
|
|
|
endif
|
2016-01-09 22:28:33 +01:00
|
|
|
let lnum = search('aid_' . a:name . ',')
|
|
|
|
if lnum == 0
|
|
|
|
call add(v:errors, 'Alloc ID ' . a:name . ' not defined')
|
|
|
|
endif
|
|
|
|
close
|
2016-01-15 20:53:38 +01:00
|
|
|
return lnum - top - 1
|
2016-01-09 22:28:33 +01:00
|
|
|
endfunc
|
|
|
|
|
2017-03-18 19:42:22 +01:00
|
|
|
func RunTheTest(test)
|
2016-03-03 13:10:44 +01:00
|
|
|
echo 'Executing ' . a:test
|
2019-06-06 18:05:25 +02:00
|
|
|
if has('reltime')
|
|
|
|
let func_start = reltime()
|
|
|
|
endif
|
2017-02-01 22:31:49 +01:00
|
|
|
|
|
|
|
" Avoid stopping at the "hit enter" prompt
|
|
|
|
set nomore
|
|
|
|
|
|
|
|
" Avoid a three second wait when a message is about to be overwritten by the
|
|
|
|
" mode message.
|
|
|
|
set noshowmode
|
|
|
|
|
2017-03-09 18:20:16 +01:00
|
|
|
" Clear any overrides.
|
|
|
|
call test_override('ALL', 0)
|
|
|
|
|
2017-10-27 00:55:04 +02:00
|
|
|
" Some tests wipe out buffers. To be consistent, always wipe out all
|
|
|
|
" buffers.
|
|
|
|
%bwipe!
|
|
|
|
|
2017-11-16 21:52:51 +01:00
|
|
|
" The test may change the current directory. Save and restore the
|
|
|
|
" directory after executing the test.
|
|
|
|
let save_cwd = getcwd()
|
|
|
|
|
2016-03-03 13:10:44 +01:00
|
|
|
if exists("*SetUp")
|
2016-11-17 17:56:13 +01:00
|
|
|
try
|
|
|
|
call SetUp()
|
|
|
|
catch
|
|
|
|
call add(v:errors, 'Caught exception in SetUp() before ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
|
|
|
|
endtry
|
2016-03-03 13:10:44 +01:00
|
|
|
endif
|
|
|
|
|
2017-10-26 17:14:01 +02:00
|
|
|
if a:test =~ 'Test_nocatch_'
|
|
|
|
" Function handles errors itself. This avoids skipping commands after the
|
|
|
|
" error.
|
2016-03-03 13:10:44 +01:00
|
|
|
exe 'call ' . a:test
|
2017-10-26 17:14:01 +02:00
|
|
|
else
|
|
|
|
try
|
2018-06-12 14:58:39 +02:00
|
|
|
let s:test = a:test
|
|
|
|
au VimLeavePre * call EarlyExit(s:test)
|
2017-10-26 17:14:01 +02:00
|
|
|
exe 'call ' . a:test
|
2018-06-12 14:58:39 +02:00
|
|
|
au! VimLeavePre
|
2017-10-26 17:14:01 +02:00
|
|
|
catch /^\cskipped/
|
|
|
|
call add(s:messages, ' Skipped')
|
|
|
|
call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', ''))
|
|
|
|
catch
|
|
|
|
call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
|
|
|
|
endtry
|
|
|
|
endif
|
2016-03-03 13:10:44 +01:00
|
|
|
|
2019-01-06 15:29:57 +01:00
|
|
|
" In case 'insertmode' was set and something went wrong, make sure it is
|
|
|
|
" reset to avoid trouble with anything else.
|
|
|
|
set noinsertmode
|
|
|
|
|
2016-03-03 13:10:44 +01:00
|
|
|
if exists("*TearDown")
|
2016-11-17 17:56:13 +01:00
|
|
|
try
|
|
|
|
call TearDown()
|
|
|
|
catch
|
|
|
|
call add(v:errors, 'Caught exception in TearDown() after ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
|
|
|
|
endtry
|
2016-03-03 13:10:44 +01:00
|
|
|
endif
|
2016-08-02 23:04:49 +02:00
|
|
|
|
2017-10-27 00:55:04 +02:00
|
|
|
" Clear any autocommands
|
|
|
|
au!
|
2018-10-07 15:42:07 +02:00
|
|
|
au SwapExists * call HandleSwapExists()
|
2017-10-27 00:55:04 +02:00
|
|
|
|
2017-10-26 22:00:00 +02:00
|
|
|
" Close any extra tab pages and windows and make the current one not modified.
|
|
|
|
while tabpagenr('$') > 1
|
2017-10-27 00:55:04 +02:00
|
|
|
quit!
|
2017-10-26 22:00:00 +02:00
|
|
|
endwhile
|
|
|
|
|
2016-08-24 21:21:26 +02:00
|
|
|
while 1
|
|
|
|
let wincount = winnr('$')
|
|
|
|
if wincount == 1
|
|
|
|
break
|
|
|
|
endif
|
2016-08-02 23:04:49 +02:00
|
|
|
bwipe!
|
2016-08-24 21:21:26 +02:00
|
|
|
if wincount == winnr('$')
|
|
|
|
" Did not manage to close a window.
|
|
|
|
only!
|
|
|
|
break
|
|
|
|
endif
|
2016-08-02 23:04:49 +02:00
|
|
|
endwhile
|
2017-11-16 21:52:51 +01:00
|
|
|
|
|
|
|
exe 'cd ' . save_cwd
|
2019-06-10 17:43:46 +02:00
|
|
|
|
|
|
|
let message = 'Executed ' . a:test
|
|
|
|
if has('reltime')
|
|
|
|
let message ..= ' in ' .. reltimestr(reltime(func_start)) .. ' seconds'
|
|
|
|
endif
|
|
|
|
call add(s:messages, message)
|
|
|
|
let s:done += 1
|
2016-03-03 13:10:44 +01:00
|
|
|
endfunc
|
2016-01-09 22:28:33 +01:00
|
|
|
|
2017-03-18 19:42:22 +01:00
|
|
|
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
|
|
|
|
|
2018-06-12 14:58:39 +02:00
|
|
|
func EarlyExit(test)
|
|
|
|
" It's OK for the test we use to test the quit detection.
|
|
|
|
if a:test != 'Test_zz_quit_detected()'
|
|
|
|
call add(v:errors, 'Test caused Vim to exit: ' . a:test)
|
|
|
|
endif
|
|
|
|
|
|
|
|
call FinishTesting()
|
|
|
|
endfunc
|
|
|
|
|
2017-03-18 19:42:22 +01:00
|
|
|
" 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=
|
|
|
|
|
2017-07-29 20:39:53 +02:00
|
|
|
" Clean up files created by setup.vim
|
|
|
|
call delete('XfakeHOME', 'rf')
|
|
|
|
|
2017-03-18 19:42:22 +01:00
|
|
|
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
|
|
|
|
|
2018-04-10 19:20:31 +02:00
|
|
|
if s:done == 0
|
|
|
|
let message = 'NO tests executed'
|
|
|
|
else
|
|
|
|
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test')
|
|
|
|
endif
|
2019-06-06 18:05:25 +02:00
|
|
|
if has('reltime')
|
|
|
|
let message ..= ' in ' .. reltimestr(reltime(s:start_time)) .. ' seconds'
|
|
|
|
endif
|
2017-03-18 19:42:22 +01:00
|
|
|
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
|
|
|
|
|
2015-11-29 17:35:35 +01:00
|
|
|
" Source the test script. First grab the file name, in case the script
|
2016-02-13 14:06:14 +01:00
|
|
|
" navigates away. g:testname can be used by the tests.
|
|
|
|
let g:testname = expand('%')
|
|
|
|
let s:done = 0
|
|
|
|
let s:fail = 0
|
|
|
|
let s:errors = []
|
|
|
|
let s:messages = []
|
2016-09-03 22:35:40 +02:00
|
|
|
let s:skipped = []
|
2017-02-23 19:03:28 +01:00
|
|
|
if expand('%') =~ 'test_vimscript.vim'
|
2016-02-13 14:06:14 +01:00
|
|
|
" this test has intentional s:errors, don't use try/catch.
|
2015-12-28 14:44:10 +01:00
|
|
|
source %
|
2016-01-02 19:50:04 +01:00
|
|
|
else
|
|
|
|
try
|
|
|
|
source %
|
2019-06-06 13:38:15 +02:00
|
|
|
catch /^\cskipped/
|
|
|
|
call add(s:messages, ' Skipped')
|
|
|
|
call add(s:skipped, 'SKIPPED ' . expand('%') . ': ' . substitute(v:exception, '^\S*\s\+', '', ''))
|
2016-01-02 19:50:04 +01:00
|
|
|
catch
|
2016-02-13 14:06:14 +01:00
|
|
|
let s:fail += 1
|
|
|
|
call add(s:errors, 'Caught exception: ' . v:exception . ' @ ' . v:throwpoint)
|
2016-01-02 19:50:04 +01:00
|
|
|
endtry
|
|
|
|
endif
|
2015-11-29 17:35:35 +01:00
|
|
|
|
2016-03-03 13:10:44 +01:00
|
|
|
" Names of flaky tests.
|
2018-11-16 18:22:45 +01:00
|
|
|
let s:flaky_tests = [
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_call()',
|
|
|
|
\ 'Test_channel_handler()',
|
2017-03-18 19:42:22 +01:00
|
|
|
\ 'Test_client_server()',
|
2017-01-29 21:49:51 +01:00
|
|
|
\ 'Test_close_and_exit_cb()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_close_callback()',
|
|
|
|
\ 'Test_close_handle()',
|
|
|
|
\ 'Test_close_lambda()',
|
2018-12-15 17:46:23 +01:00
|
|
|
\ 'Test_close_output_buffer()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_close_partial()',
|
2017-02-01 18:00:13 +01:00
|
|
|
\ 'Test_collapse_buffers()',
|
|
|
|
\ 'Test_communicate()',
|
2018-03-25 17:12:58 +02:00
|
|
|
\ 'Test_cwd()',
|
2018-11-11 18:51:42 +01:00
|
|
|
\ 'Test_diff_screen()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_exit_callback()',
|
2017-03-16 22:30:37 +01:00
|
|
|
\ 'Test_exit_callback_interval()',
|
2017-02-01 18:00:13 +01:00
|
|
|
\ 'Test_nb_basic()',
|
2017-02-27 21:35:53 +01:00
|
|
|
\ 'Test_oneshot()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_open_delay()',
|
2017-12-05 14:04:27 +01:00
|
|
|
\ 'Test_out_cb()',
|
2017-12-02 16:38:12 +01:00
|
|
|
\ 'Test_paused()',
|
2016-09-25 22:27:37 +02:00
|
|
|
\ 'Test_pipe_through_sort_all()',
|
2017-02-01 20:48:13 +01:00
|
|
|
\ 'Test_pipe_through_sort_some()',
|
2018-08-19 17:04:01 +02:00
|
|
|
\ 'Test_popup_and_window_resize()',
|
2017-03-05 14:30:52 +01:00
|
|
|
\ 'Test_quoteplus()',
|
2017-03-19 20:04:22 +01:00
|
|
|
\ 'Test_quotestar()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_raw_one_time_callback()',
|
2017-02-01 18:00:13 +01:00
|
|
|
\ 'Test_reltime()',
|
2018-02-12 21:31:35 +01:00
|
|
|
\ 'Test_repeat_three()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_server_crash()',
|
|
|
|
\ 'Test_terminal_ansicolors_default()',
|
|
|
|
\ 'Test_terminal_ansicolors_func()',
|
|
|
|
\ 'Test_terminal_ansicolors_global()',
|
2017-10-26 17:14:01 +02:00
|
|
|
\ 'Test_terminal_composing_unicode()',
|
2019-02-21 18:17:14 +01:00
|
|
|
\ 'Test_terminal_does_not_truncate_last_newlines()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_terminal_env()',
|
|
|
|
\ 'Test_terminal_hide_buffer()',
|
|
|
|
\ 'Test_terminal_make_change()',
|
2019-02-10 23:04:12 +01:00
|
|
|
\ 'Test_terminal_no_cmd()',
|
2017-09-07 22:24:41 +02:00
|
|
|
\ 'Test_terminal_noblock()',
|
2017-11-04 20:46:40 +01:00
|
|
|
\ 'Test_terminal_redir_file()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_terminal_response_to_control_sequence()',
|
|
|
|
\ 'Test_terminal_scrollback()',
|
|
|
|
\ 'Test_terminal_split_quit()',
|
|
|
|
\ 'Test_terminal_termwinkey()',
|
|
|
|
\ 'Test_terminal_termwinsize_mininmum()',
|
|
|
|
\ 'Test_terminal_termwinsize_option_fixed()',
|
|
|
|
\ 'Test_terminal_termwinsize_option_zero()',
|
2017-12-02 16:38:12 +01:00
|
|
|
\ 'Test_terminal_tmap()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_terminal_wall()',
|
|
|
|
\ 'Test_terminal_wipe_buffer()',
|
|
|
|
\ 'Test_terminal_wqall()',
|
|
|
|
\ 'Test_two_channels()',
|
|
|
|
\ 'Test_unlet_handle()',
|
2017-07-30 21:37:58 +02:00
|
|
|
\ 'Test_with_partial_callback()',
|
2018-11-16 17:44:48 +01:00
|
|
|
\ 'Test_zero_reply()',
|
|
|
|
\ 'Test_zz1_terminal_in_gui()',
|
2016-09-11 16:48:50 +02:00
|
|
|
\ ]
|
2016-03-03 13:10:44 +01:00
|
|
|
|
2018-11-16 18:22:45 +01:00
|
|
|
" Pattern indicating a common flaky test failure.
|
2018-11-16 18:50:19 +01:00
|
|
|
let s:flaky_errors_re = 'StopVimInTerminal\|VerifyScreenDump'
|
2018-11-16 18:22:45 +01:00
|
|
|
|
2015-11-29 17:35:35 +01:00
|
|
|
" Locate Test_ functions and execute them.
|
|
|
|
redir @q
|
2016-02-18 22:25:47 +01:00
|
|
|
silent function /^Test_
|
2015-11-29 17:35:35 +01:00
|
|
|
redir END
|
2016-02-13 14:06:14 +01:00
|
|
|
let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
|
2015-11-29 17:35:35 +01:00
|
|
|
|
2016-02-20 14:41:40 +01:00
|
|
|
" If there is an extra argument filter the function names against it.
|
|
|
|
if argc() > 1
|
|
|
|
let s:tests = filter(s:tests, 'v:val =~ argv(1)')
|
|
|
|
endif
|
|
|
|
|
2016-01-09 20:23:00 +01:00
|
|
|
" Execute the tests in alphabetical order.
|
2016-02-18 22:25:47 +01:00
|
|
|
for s:test in sort(s:tests)
|
2017-10-12 21:29:22 +02:00
|
|
|
" Silence, please!
|
|
|
|
set belloff=all
|
2018-11-16 16:52:16 +01:00
|
|
|
let prev_error = ''
|
|
|
|
let total_errors = []
|
|
|
|
let run_nr = 1
|
2017-10-12 21:29:22 +02:00
|
|
|
|
2016-03-03 13:10:44 +01:00
|
|
|
call RunTheTest(s:test)
|
2015-11-29 17:35:35 +01:00
|
|
|
|
2018-11-16 16:52:16 +01:00
|
|
|
" Repeat a flaky test. Give up when:
|
|
|
|
" - it fails again with the same message
|
|
|
|
" - it fails five times (with a different mesage)
|
2018-11-16 18:22:45 +01:00
|
|
|
if len(v:errors) > 0
|
|
|
|
\ && (index(s:flaky_tests, s:test) >= 0
|
|
|
|
\ || v:errors[0] =~ s:flaky_errors_re)
|
2018-11-16 16:52:16 +01:00
|
|
|
while 1
|
|
|
|
call add(s:messages, 'Found errors in ' . s:test . ':')
|
|
|
|
call extend(s:messages, v:errors)
|
2017-03-18 21:22:47 +01:00
|
|
|
|
2018-11-16 16:52:16 +01:00
|
|
|
call add(total_errors, 'Run ' . run_nr . ':')
|
|
|
|
call extend(total_errors, v:errors)
|
2017-11-21 15:14:51 +01:00
|
|
|
|
2018-11-16 16:52:16 +01:00
|
|
|
if run_nr == 5 || prev_error == v:errors[0]
|
|
|
|
call add(total_errors, 'Flaky test failed too often, giving up')
|
|
|
|
let v:errors = total_errors
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
|
|
|
|
call add(s:messages, 'Flaky test failed, running it again')
|
|
|
|
|
|
|
|
" Flakiness is often caused by the system being very busy. Sleep a
|
|
|
|
" couple of seconds to have a higher chance of succeeding the second
|
|
|
|
" time.
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
let prev_error = v:errors[0]
|
|
|
|
let v:errors = []
|
|
|
|
let run_nr += 1
|
|
|
|
|
|
|
|
call RunTheTest(s:test)
|
|
|
|
|
|
|
|
if len(v:errors) == 0
|
|
|
|
" Test passed on rerun.
|
|
|
|
break
|
|
|
|
endif
|
|
|
|
endwhile
|
2016-03-03 13:10:44 +01:00
|
|
|
endif
|
2015-11-29 17:35:35 +01:00
|
|
|
|
2017-03-18 19:42:22 +01:00
|
|
|
call AfterTheTest()
|
2015-11-29 17:35:35 +01:00
|
|
|
endfor
|
|
|
|
|
2017-03-18 19:42:22 +01:00
|
|
|
call FinishTesting()
|
2016-11-17 17:56:13 +01:00
|
|
|
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|