patch 9.1.1524: tests: too many imports in the test suite

Problem:  tests: too many imports in the test suite
Solution: Clean up the imported scripts

Most tests make use of check.vim, so let's just source it once in
runtest.vim instead of having each test manually source it.

runtest.vim already sources shared.vim, which again sources
view_util.vim, so we don't need to source those two common
dependencies in all the other tests

And then check.vim sources term_util.vim already, so we can in addition
drop sourcing it explicitly in each single test script.

Note: test_expand_func.vim had to be updated to account for the changed
number of sourced files.

And finally check.vim uses line-continuation so let's also explicitly
enable line continuation via the 'cpo' option value.

related: #17677

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-07-07 20:39:29 +02:00
parent a4874d4d36
commit b0905e269d
219 changed files with 19 additions and 450 deletions

View File

@ -1,6 +1,10 @@
source shared.vim
source term_util.vim
" uses line-continuation
let s:cpo_save = &cpo
set cpo&vim
command -nargs=1 MissingFeature throw 'Skipped: ' .. <args> .. ' feature missing'
" Command to check for the presence of a feature.
@ -324,4 +328,7 @@ func CheckGithubActions()
throw "Skipped: FIXME: this test doesn't work on Github Actions CI"
endif
endfunc
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -106,6 +106,9 @@ source setup.vim
" Needed for RunningWithValgrind().
source shared.vim
" Needed for the various Check commands
source check.vim
" For consistency run all tests with 'nocompatible' set.
" This also enables use of line continuation.
set nocp viminfo+=nviminfo

View File

@ -5,9 +5,6 @@ if exists('*VerifyScreenDump')
finish
endif
source shared.vim
source term_util.vim
" Skip the rest if there is no terminal feature at all.
if !has('terminal')
finish

View File

@ -2,11 +2,8 @@
" NOTE: This just checks if the code works. If you know Arabic please add
" functional tests that check the shaping works with real text.
source check.vim
CheckFeature arabic
source view_util.vim
" Return list of Unicode characters at line lnum.
" Combining characters are treated as a single item.
func s:get_chars(lnum)

View File

@ -1,9 +1,5 @@
" Test argument list commands
source check.vim
source shared.vim
source term_util.vim
func Reset_arglist()
args a | %argd
endfunc

View File

@ -1,8 +1,5 @@
" Test that the methods used for testing work.
source check.vim
source term_util.vim
func Test_assert_false()
call assert_equal(0, assert_false(0))
call assert_equal(0, assert_false(v:false))

View File

@ -1,6 +1,5 @@
" Test 'autochdir' behavior
source check.vim
CheckOption autochdir
func Test_set_filename()

View File

@ -1,8 +1,5 @@
" Tests for autocommands
source shared.vim
source check.vim
source term_util.vim
source screendump.vim
import './vim9.vim' as v9

View File

@ -1,7 +1,5 @@
" Tests for the backup function
source check.vim
func Test_backup()
set backup backupdir=. backupskip=
new

View File

@ -1,7 +1,6 @@
" Tests for 'balloonevalterm'.
" A few tests only work in the terminal.
source check.vim
CheckNotGui
CheckFeature balloon_eval_term

View File

@ -1,6 +1,5 @@
" Tests for 'ballooneval' in the GUI.
source check.vim
CheckGui
CheckFeature balloon_eval

View File

@ -1,6 +1,5 @@
" Test for benchmarking the RE engine
source check.vim
CheckFeature reltime
func Measure(file, pattern, arg)

View File

@ -4,10 +4,8 @@
" while the test is run, the breakindent caching gets in its way.
" It helps to change the tabstop setting and force a redraw (e.g. see
" Test_breakindent08())
source check.vim
CheckOption breakindent
source view_util.vim
source screendump.vim
func SetUp()

View File

@ -1,7 +1,5 @@
" Tests for Vim buffer
source check.vim
" Test for the :bunload command with an offset
func Test_bunload_with_offset()
%bwipe!

View File

@ -1,8 +1,6 @@
" Tests for setbufline(), getbufline(), appendbufline(), deletebufline()
source shared.vim
source screendump.vim
source check.vim
func Test_setbufline_getbufline()
" similar to Test_set_get_bufline()

View File

@ -1,7 +1,5 @@
" Tests for the getbufinfo(), getwininfo() and gettabinfo() functions
source check.vim
func Test_getbufwintabinfo()
CheckFeature quickfix

View File

@ -1,8 +1,5 @@
" Test for :cd and chdir()
source shared.vim
source check.vim
func Test_cd_large_path()
" This used to crash with a heap write overflow.
call assert_fails('cd ' . repeat('x', 5000), 'E344:')

View File

@ -1,6 +1,5 @@
" Tests for the :cdo, :cfdo, :ldo and :lfdo commands
source check.vim
CheckFeature quickfix
" Create the files used by the tests

View File

@ -1,12 +1,9 @@
" Test for channel and job functions.
" When +channel is supported then +job is too, so we don't check for that.
source check.vim
CheckFeature channel
source shared.vim
source screendump.vim
source view_util.vim
let s:python = PythonProg()
if s:python == ''

View File

@ -1,6 +1,5 @@
" Tests for the +clientserver feature.
source check.vim
CheckFeature job
if !has('clientserver')

View File

@ -1,7 +1,5 @@
" Tests for clipmethod
source check.vim
source shared.vim
source window_manager.vim
CheckFeature clipboard_working

View File

@ -1,9 +1,6 @@
" Tests for editing the command line.
source check.vim
source screendump.vim
source view_util.vim
source shared.vim
import './vim9.vim' as v9
func SetUp()

View File

@ -1,6 +1,5 @@
" Tests for editing the command line.
source check.vim
source screendump.vim
func Test_getcmdwintype()

View File

@ -1,8 +1,5 @@
" Test the :compiler command
source check.vim
source shared.vim
func Test_compiler()
CheckExecutable perl
CheckFeature quickfix

View File

@ -1,10 +1,8 @@
" Tests for 'conceal'.
source check.vim
CheckFeature conceal
source screendump.vim
source view_util.vim
func Test_conceal_two_windows()
CheckScreendump

View File

@ -1,9 +1,5 @@
" Test for the various 'cpoptions' (cpo) flags
source check.vim
source shared.vim
source view_util.vim
" Test for the 'a' flag in 'cpo'. Reading a file should set the alternate
" file name.
func Test_cpo_a()

View File

@ -1,5 +1,4 @@
" Some tests, that used to crash Vim
source check.vim
source screendump.vim
CheckScreendump

View File

@ -1,7 +1,5 @@
" Tests for encryption.
source shared.vim
source check.vim
CheckFeature cryptv
" Use the xxd command from:

View File

@ -1,6 +1,5 @@
" Test for cscope commands.
source check.vim
CheckFeature cscope
CheckFeature quickfix
CheckExecutable cscope

View File

@ -1,7 +1,5 @@
" Tests for cursor() and other functions that get/set the cursor position
source check.vim
func Test_wrong_arguments()
call assert_fails('call cursor(1. 3)', 'E474:')
call assert_fails('call cursor(test_null_list())', 'E474:')

View File

@ -1,6 +1,5 @@
" Test for cursorline and cursorlineopt
source check.vim
source screendump.vim
func s:screen_attr(lnum) abort

View File

@ -1,8 +1,5 @@
" Tests for not changing curswant
source check.vim
source term_util.vim
func Test_curswant()
new
call append(0, ['1234567890', '12345'])

View File

@ -1,8 +1,6 @@
" Tests for the Vim script debug commands
source shared.vim
source screendump.vim
source check.vim
CheckRunVimInTerminal

View File

@ -1,7 +1,5 @@
" Test for delete().
source check.vim
source term_util.vim
source screendump.vim
func Test_file_delete()

View File

@ -1,9 +1,6 @@
" Tests for diff mode
source shared.vim
source screendump.vim
source check.vim
source view_util.vim
func Test_diff_fold_sync()
enew!

View File

@ -1,8 +1,6 @@
" Tests for digraphs
source check.vim
CheckFeature digraphs
source term_util.vim
func Put_Dig(chars)
exe "norm! o\<c-k>".a:chars

View File

@ -4,8 +4,6 @@ if !has('gui_running') && has('unix')
set term=ansi
endif
source view_util.vim
source check.vim
source screendump.vim
func Test_display_foldcolumn()

View File

@ -4,9 +4,7 @@ if exists("+t_kD")
let &t_kD="[3;*~"
endif
source check.vim
source screendump.vim
source view_util.vim
" Needs to come first until the bug in getchar() is
" fixed: https://groups.google.com/d/msg/vim_dev/fXL9yme4H4c/bOR-U6_bAQAJ

View File

@ -2,8 +2,6 @@
scriptencoding utf-8
source check.vim
func Test_environ()
unlet! $TESTENV
call assert_equal(0, has_key(environ(), 'TESTENV'))

View File

@ -1,8 +1,6 @@
" Test whether glob()/globpath() return correct results with certain escaped
" characters.
source check.vim
func SetUp()
" consistent sorting of file names
set nofileignorecase

View File

@ -1,6 +1,5 @@
" Tests for various eval things.
source view_util.vim
source shared.vim
import './vim9.vim' as v9

View File

@ -1,8 +1,5 @@
" Test editing line in Ex mode (see :help Q and :help gQ).
source check.vim
source shared.vim
" Helper function to test editing line in Q Ex mode
func Ex_Q(cmd)
" Is there a simpler way to test editing Ex line?

View File

@ -1,8 +1,5 @@
" Tests for various Ex commands.
source check.vim
source shared.vim
source term_util.vim
source screendump.vim
func Test_ex_delete()

View File

@ -1,9 +1,6 @@
" test execute()
source view_util.vim
source check.vim
import './vim9.vim' as v9
source term_util.vim
func NestedEval()
let nested = execute('echo "nested\nlines"')

View File

@ -1,8 +1,5 @@
" Tests for exiting Vim.
source shared.vim
source check.vim
func Test_exiting()
let after =<< trim [CODE]
au QuitPre * call writefile(["QuitPre"], "Xtestout")

View File

@ -1,8 +1,5 @@
" Test for expanding file names
source shared.vim
source check.vim
func Test_with_directories()
call mkdir('Xdir1')
call mkdir('Xdir2')

View File

@ -1,7 +1,5 @@
" Tests for expand()
source shared.vim
let s:sfile = expand('<sfile>')
let s:slnum = str2nr(expand('<slnum>'))
let s:sflnum = str2nr(expand('<sflnum>'))
@ -20,20 +18,20 @@ endfunc
" This test depends on the location in the test file, put it first.
func Test_expand_sflnum()
call assert_equal(7, s:sflnum)
call assert_equal(24, str2nr(expand('<sflnum>')))
call assert_equal(5, s:sflnum)
call assert_equal(22, str2nr(expand('<sflnum>')))
" Line-continuation
call assert_equal(
\ 27,
\ 25,
\ str2nr(expand('<sflnum>')))
" Call in script-local function
call assert_equal(18, s:expand_sflnum())
call assert_equal(16, s:expand_sflnum())
" Call in command
command Flnum echo expand('<sflnum>')
call assert_equal(36, str2nr(trim(execute('Flnum'))))
call assert_equal(34, str2nr(trim(execute('Flnum'))))
delcommand Flnum
endfunc
@ -86,7 +84,7 @@ func Test_expand_sfile_and_stack()
endfunc
func Test_expand_slnum()
call assert_equal(6, s:slnum)
call assert_equal(4, s:slnum)
call assert_equal(2, str2nr(expand('<slnum>')))
" Line-continuation

View File

@ -1,6 +1,5 @@
" Tests for expressions.
source check.vim
import './vim9.vim' as v9
func Test_equal()

View File

@ -8,8 +8,6 @@
" cksum is part of POSIX and so should be available on most Unixes.
" If it isn't available then the test will be skipped.
source check.vim
func Test_File_Size()
CheckExecutable cksum

View File

@ -1,7 +1,5 @@
" Tests for when a file was changed outside of Vim.
source check.vim
func Test_FileChangedShell_reload()
CheckUnix

View File

@ -1,8 +1,5 @@
" Test filecopy()
source check.vim
source shared.vim
func Test_copy_file_to_file()
call writefile(['foo'], 'Xcopy1')

View File

@ -1,7 +1,5 @@
" Test for 'fileformat'
source shared.vim
" Test behavior of fileformat after bwipeout of last buffer
func Test_fileformat_after_bw()
bwipeout

View File

@ -1,7 +1,5 @@
" Test the :filter command modifier
source check.vim
func Test_filter()
edit Xdoesnotmatch
edit Xwillmatch

View File

@ -1,6 +1,5 @@
" Test findfile() and finddir()
source check.vim
import './vim9.vim' as v9
let s:files = [ 'Xfinddir1/foo',

View File

@ -1,6 +1,5 @@
" test float functions
source check.vim
import './vim9.vim' as v9
func Test_abs()

View File

@ -1,7 +1,5 @@
" Test for folding
source check.vim
source view_util.vim
source screendump.vim
func PrepIndent(arg)

View File

@ -1,6 +1,5 @@
" Tests for expressions.
source check.vim
import './vim9.vim' as v9
func Test_printf_pos_misc()

View File

@ -1,8 +1,5 @@
" Tests for various functions.
source shared.vim
source check.vim
source term_util.vim
source screendump.vim
import './vim9.vim' as v9

View File

@ -1,8 +1,7 @@
source check.vim
" Test for gettext()
CheckFeature gettext
" Test for gettext()
func Test_gettext()
call assert_fails('call bindtextdomain("test")', 'E119:')
call assert_fails('call bindtextdomain("vim", "test")', 'E475:')

View File

@ -1,4 +1,3 @@
source check.vim
" This fail on CI MacOS 14 because bindtextdomain() is not available there
" (missing library?)
CheckNotMac

View File

@ -1,4 +1,3 @@
source check.vim
CheckNotMac
CheckFeature gettext

View File

@ -1,4 +1,3 @@
source check.vim
" This fail on CI MacOS 14 because bindtextdomain() is not available there
" (missing library?)
CheckNotMac

View File

@ -1,8 +1,5 @@
" Test for :global and :vglobal
source check.vim
source term_util.vim
func Test_yank_put_clipboard()
new
call setline(1, ['a', 'b', 'c'])

View File

@ -1,7 +1,5 @@
" Tests specifically for the GUI
source shared.vim
source check.vim
CheckCanRunGui
source setup_gui.vim

View File

@ -1,8 +1,6 @@
" Tests specifically for the GUI features/options that need to be set up at
" startup to take effect at runtime.
source shared.vim
source check.vim
CheckCanRunGui
source setup_gui.vim

View File

@ -1,7 +1,5 @@
" Test :hardcopy
source check.vim
func Test_printoptions()
edit test_hardcopy.vim
syn on

View File

@ -1,6 +1,5 @@
" Tests for :help
source check.vim
import './vim9.vim' as v9
func Test_help_restore_snapshot()

View File

@ -1,8 +1,6 @@
" Tests for ":highlight" and highlighting.
source view_util.vim
source screendump.vim
source check.vim
source script_util.vim
import './vim9.vim' as v9

View File

@ -1,6 +1,5 @@
" Tests for the history functions
source check.vim
CheckFeature cmdline_hist
set history=7

View File

@ -1,6 +1,5 @@
" Test for v:hlsearch
source check.vim
source screendump.vim
func Test_hlsearch()

View File

@ -1,7 +1,5 @@
" Test for 'iminsert'
source view_util.vim
source check.vim
import './vim9.vim' as v9
let s:imactivatefunc_called = 0

View File

@ -1,8 +1,5 @@
" Test for various indent options
source shared.vim
source check.vim
func Test_preserveindent()
new
" Test for autoindent copying indent from the previous line

View File

@ -1,7 +1,6 @@
" Test for insert completion
source screendump.vim
source check.vim
import './vim9.vim' as v9
" Test for insert expansion

View File

@ -2,8 +2,6 @@
" leaks under valgrind. That is because when fork/exec fails memory is not
" freed. Since the process exits right away it's not a real leak.
source check.vim
func Test_job_start_fails()
CheckFeature job
let job = job_start('axdfxsdf')

View File

@ -1,6 +1,5 @@
" Test for lambda and closure
source check.vim
import './vim9.vim' as v9
func Test_lambda_feature()

View File

@ -1,6 +1,5 @@
" tests for 'langmap'
source check.vim
CheckFeature langmap
func Test_langmap()

View File

@ -1,7 +1,5 @@
" Tests for 'listchars' display with 'list' and :list
source check.vim
source view_util.vim
source screendump.vim
func Check_listchars(expected, end_lnum, end_scol = -1, leftcol = 0)

View File

@ -3,11 +3,9 @@
set encoding=latin1
scriptencoding latin1
source check.vim
CheckOption linebreak
CheckFeature conceal
source view_util.vim
source screendump.vim
function s:screen_lines(lnum, width) abort

View File

@ -3,12 +3,10 @@
set encoding=utf-8
scriptencoding utf-8
source check.vim
CheckOption linebreak
CheckFeature conceal
CheckFeature signs
source view_util.vim
source screendump.vim
func s:screen_lines(lnum, width) abort

View File

@ -1,7 +1,5 @@
" Tests for Lua.
source check.vim
" This test also works without the lua feature.
func Test_skip_lua()
if 0

View File

@ -1,8 +1,5 @@
" Tests for 'makeencoding'.
source shared.vim
source check.vim
CheckFeature quickfix
let s:python = PythonProg()
if s:python == ''

View File

@ -1,8 +1,6 @@
" Tests for maparg(), mapcheck(), mapset(), maplist()
" Also test utf8 map with a 0x80 byte.
source shared.vim
func s:SID()
return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
endfunc

View File

@ -1,9 +1,6 @@
" Tests for mappings and abbreviations
source shared.vim
source check.vim
source screendump.vim
source term_util.vim
import './vim9.vim' as v9
func Test_abbreviation()

View File

@ -2,7 +2,6 @@
" matchaddpos(), matcharg(), matchdelete(), and setmatches().
source screendump.vim
source check.vim
function Test_match()
highlight MyGroup1 term=bold ctermbg=red guibg=red

View File

@ -1,16 +1,11 @@
" Test for matchadd() and conceal feature
source check.vim
CheckFeature conceal
if !has('gui_running') && has('unix')
set term=ansi
endif
source shared.vim
source term_util.vim
source view_util.vim
func Test_simple_matchadd()
new

View File

@ -1,6 +1,5 @@
" Test for matchadd() and conceal feature using utf-8.
source check.vim
CheckFeature conceal
if !has('gui_running') && has('unix')

View File

@ -1,9 +1,5 @@
" Tests for fuzzy matching
source shared.vim
source check.vim
source term_util.vim
" Test for matchfuzzy()
func Test_matchfuzzy()
call assert_fails('call matchfuzzy(10, "abc")', 'E686:')

View File

@ -1,6 +1,5 @@
" Tests for memory usage.
source check.vim
CheckFeature terminal
CheckNotGui
@ -8,8 +7,6 @@ CheckNotGui
" usage.
CheckNotAsan
source shared.vim
func s:pick_nr(str) abort
return substitute(a:str, '[^0-9]', '', 'g') * 1
endfunc

View File

@ -1,6 +1,5 @@
" Test that the system menu can be loaded.
source check.vim
CheckFeature menu
source screendump.vim

View File

@ -1,9 +1,5 @@
" Tests for :messages, :echomsg, :echoerr
source check.vim
source shared.vim
source term_util.vim
source view_util.vim
source screendump.vim
func Test_messages()

View File

@ -1,7 +1,5 @@
" Tests for ->method()
source check.vim
func Test_list_method()
let l = [1, 2, 3]
call assert_equal([1, 2, 3, 4], [1, 2, 3]->add(4))

View File

@ -3,12 +3,8 @@
set encoding=latin1
scriptencoding latin1
source check.vim
CheckFeature mksession
source shared.vim
source term_util.vim
" Test for storing global and local argument list in a session file
" This one must be done first.
func Test__mksession_arglocal()

View File

@ -3,7 +3,6 @@
set encoding=utf-8
scriptencoding utf-8
source check.vim
CheckFeature mksession
func Test_mksession_utf8()

View File

@ -1,11 +1,9 @@
" Test for modeless selection
" This only works for Unix in a terminal
source check.vim
CheckNotGui
CheckUnix
source shared.vim
source mouse.vim
" Test for modeless characterwise selection (single click)

View File

@ -1,7 +1,5 @@
" Tests for parsing the modeline.
source check.vim
func Test_modeline_invalid()
" This was reading allocated memory in the past.
call writefile(['vi:0', 'nothing'], 'Xmodeline', 'D')

View File

@ -1,6 +1,5 @@
" Test the ":move" command.
source check.vim
source screendump.vim
func Test_move()

View File

@ -1,7 +1,6 @@
" Test MS-Windows input event handling.
" Most of this works the same in Windows GUI as well as Windows console.
source check.vim
CheckMSWindows
source mouse.vim

View File

@ -1,6 +1,5 @@
" Test for MzScheme interface and mzeval() function
source check.vim
CheckFeature mzscheme
func MzRequire()

View File

@ -1,7 +1,5 @@
" Tests for nested functions
source check.vim
func NestedFunc()
func! Func1()
let g:text .= 'Func1 '

View File

@ -1,10 +1,7 @@
" Test the netbeans interface.
source check.vim
CheckFeature netbeans_intg
source shared.vim
let s:python = PythonProg()
if s:python == ''
throw 'Skipped: python program missing'

Some files were not shown because too many files have changed in this diff Show More