mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-02-09 20:26:37 +01:00
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>
118 lines
2.7 KiB
VimL
118 lines
2.7 KiB
VimL
" Tests for 'makeencoding'.
|
|
|
|
CheckFeature quickfix
|
|
let s:python = PythonProg()
|
|
if s:python == ''
|
|
throw 'Skipped: python program missing'
|
|
endif
|
|
|
|
let s:script = 'test_makeencoding.py'
|
|
|
|
let s:message_tbl = {
|
|
\ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好',
|
|
\ 'latin1': 'ÀÈÌÒÙ',
|
|
\ 'cp932': 'こんにちは',
|
|
\ 'cp936': '你好',
|
|
\}
|
|
|
|
|
|
" Tests for :cgetfile and :lgetfile.
|
|
func Test_getfile()
|
|
set errorfile=Xerror.txt
|
|
set errorformat=%f(%l)\ :\ %m
|
|
|
|
" :cgetfile
|
|
for enc in keys(s:message_tbl)
|
|
let &makeencoding = enc
|
|
exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile
|
|
cgetfile
|
|
copen
|
|
call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
|
|
\ getline('.'))
|
|
cclose
|
|
endfor
|
|
|
|
" :lgetfile
|
|
for enc in keys(s:message_tbl)
|
|
let &makeencoding = enc
|
|
exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile
|
|
lgetfile
|
|
lopen
|
|
call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
|
|
\ getline('.'))
|
|
lclose
|
|
endfor
|
|
|
|
call delete(&errorfile)
|
|
endfunc
|
|
|
|
|
|
" Tests for :grep and :lgrep.
|
|
func Test_grep()
|
|
let &grepprg = s:python
|
|
set grepformat=%f(%l)\ :\ %m
|
|
|
|
" :grep
|
|
for enc in keys(s:message_tbl)
|
|
let &makeencoding = enc
|
|
exec "silent grep! " . s:script . " " . enc
|
|
copen
|
|
call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
|
|
\ getline('.'))
|
|
cclose
|
|
endfor
|
|
|
|
" :lgrep
|
|
for enc in keys(s:message_tbl)
|
|
let &makeencoding = enc
|
|
exec "silent lgrep! " . s:script . " " . enc
|
|
lopen
|
|
call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
|
|
\ getline('.'))
|
|
lclose
|
|
endfor
|
|
endfunc
|
|
|
|
|
|
" Tests for :make and :lmake.
|
|
func Test_make()
|
|
let &makeprg = s:python
|
|
set errorformat=%f(%l)\ :\ %m
|
|
|
|
" :make
|
|
for enc in keys(s:message_tbl)
|
|
let &makeencoding = enc
|
|
exec "silent make! " . s:script . " " . enc
|
|
copen
|
|
call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
|
|
\ getline('.'))
|
|
cclose
|
|
endfor
|
|
|
|
" :lmake
|
|
for enc in keys(s:message_tbl)
|
|
let &makeencoding = enc
|
|
exec "silent lmake! " . s:script . " " . enc
|
|
lopen
|
|
call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")",
|
|
\ getline('.'))
|
|
lclose
|
|
endfor
|
|
endfunc
|
|
|
|
" Test for an error file with a long line that needs an encoding conversion
|
|
func Test_longline_conversion()
|
|
new
|
|
call setline(1, ['Xfile:10:' .. repeat("\xe0", 2000)])
|
|
write ++enc=latin1 Xerr.out
|
|
bw!
|
|
set errorformat&
|
|
set makeencoding=latin1
|
|
cfile Xerr.out
|
|
call assert_equal(repeat("\u00e0", 2000), getqflist()[0].text)
|
|
call delete('Xerr.out')
|
|
set makeencoding&
|
|
endfunc
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|