mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1257: code style is not check in test scripts
Problem: Code style is not check in test scripts.
Solution: Add basic code style check for test files.
94722c5107
Use Test_test_files() from latest Vim.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
f17d819330
commit
457ab65ff3
@ -48,6 +48,16 @@
|
||||
" call add(v:errors, "this happened")
|
||||
|
||||
|
||||
" Without the +eval feature we can't run these tests, bail out.
|
||||
silent! while 0
|
||||
qa!
|
||||
silent! endwhile
|
||||
|
||||
" In the GUI we can always change the screen size.
|
||||
if has('gui_running')
|
||||
set columns=80 lines=25
|
||||
endif
|
||||
|
||||
" 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, got ' .. &lines .. ' lines with ' .. &columns .. ' characters'
|
||||
|
@ -53,7 +53,7 @@ func Test_blockinsert_autoindent()
|
||||
let expected =<< trim END
|
||||
vim9script
|
||||
var d = {
|
||||
a: (): asdf => 0,
|
||||
a: (): asdf => 0,
|
||||
b: (): asdf => 0,
|
||||
c: (): asdf => 0,
|
||||
}
|
||||
|
@ -6,6 +6,45 @@ func s:ReportError(fname, lnum, msg)
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func Test_test_files()
|
||||
for fname in glob('*.vim', 0, 1)
|
||||
let g:ignoreSwapExists = 'e'
|
||||
exe 'edit ' .. fname
|
||||
|
||||
" some files intentionally have misplaced white space
|
||||
if fname =~ 'test_cindent.vim' || fname =~ 'test_join.vim'
|
||||
continue
|
||||
endif
|
||||
|
||||
" skip files that are known to have a space before a tab
|
||||
if fname !~ 'test_comments.vim'
|
||||
\ && fname !~ 'test_listchars.vim'
|
||||
\ && fname !~ 'test_visual.vim'
|
||||
call cursor(1, 1)
|
||||
let skip = 'getline(".") =~ "codestyle: ignore"'
|
||||
let lnum = search(fname =~ "test_regexp_latin" ? '[^á] \t' : ' \t', 'W', 0, 0, skip)
|
||||
call s:ReportError('testdir/' .. fname, lnum, 'space before Tab')
|
||||
endif
|
||||
|
||||
" skip files that are known to have trailing white space
|
||||
if fname !~ 'test_cmdline.vim'
|
||||
\ && fname !~ 'test_let.vim'
|
||||
\ && fname !~ 'test_tagjump.vim'
|
||||
\ && fname !~ 'test_vim9_cmd.vim'
|
||||
call cursor(1, 1)
|
||||
let lnum = search(
|
||||
\ fname =~ 'test_vim9_assign.vim' ? '[^=]\s$'
|
||||
\ : fname =~ 'test_vim9_class.vim' ? '[^)]\s$'
|
||||
\ : fname =~ 'test_vim9_script.vim' ? '[^,:3]\s$'
|
||||
\ : fname =~ 'test_visual.vim' ? '[^/]\s$'
|
||||
\ : '[^\\]\s$')
|
||||
call s:ReportError('testdir/' .. fname, lnum, 'trailing white space')
|
||||
endif
|
||||
endfor
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_help_files()
|
||||
set nowrapscan
|
||||
|
||||
|
@ -1020,52 +1020,50 @@ endfunc
|
||||
|
||||
" More tests for 'errorformat'
|
||||
func Test_efm1()
|
||||
if !has('unix')
|
||||
" The 'errorformat' setting is different on non-Unix systems.
|
||||
" This test works only on Unix-like systems.
|
||||
return
|
||||
endif
|
||||
" The 'errorformat' setting is different on non-Unix systems.
|
||||
" This test works only on Unix-like systems.
|
||||
CheckUnix
|
||||
|
||||
let l =<< trim [DATA]
|
||||
"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
|
||||
"Xtestfile", line 6 col 19; this is an error
|
||||
gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c
|
||||
Xtestfile:9: parse error before `asd'
|
||||
make: *** [src/vim/testdir/Makefile:100: test_quickfix] Error 1
|
||||
in file "Xtestfile" linenr 10: there is an error
|
||||
let l =<< trim [DATA]
|
||||
"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
|
||||
"Xtestfile", line 6 col 19; this is an error
|
||||
gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c
|
||||
Xtestfile:9: parse error before `asd'
|
||||
make: *** [src/vim/testdir/Makefile:100: test_quickfix] Error 1
|
||||
in file "Xtestfile" linenr 10: there is an error
|
||||
|
||||
2 returned
|
||||
"Xtestfile", line 11 col 1; this is an error
|
||||
"Xtestfile", line 12 col 2; this is another error
|
||||
"Xtestfile", line 14:10; this is an error in column 10
|
||||
=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time
|
||||
"Xtestfile", linenr 16: yet another problem
|
||||
Error in "Xtestfile" at line 17:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
|
||||
^
|
||||
Error in "Xtestfile" at line 18:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
|
||||
.............^
|
||||
Error in "Xtestfile" at line 19:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
|
||||
--------------^
|
||||
Error in "Xtestfile" at line 20:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
|
||||
^
|
||||
2 returned
|
||||
"Xtestfile", line 11 col 1; this is an error
|
||||
"Xtestfile", line 12 col 2; this is another error
|
||||
"Xtestfile", line 14:10; this is an error in column 10
|
||||
=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time
|
||||
"Xtestfile", linenr 16: yet another problem
|
||||
Error in "Xtestfile" at line 17:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
|
||||
^
|
||||
Error in "Xtestfile" at line 18:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
|
||||
.............^
|
||||
Error in "Xtestfile" at line 19:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
|
||||
--------------^
|
||||
Error in "Xtestfile" at line 20:
|
||||
x should be a dot
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
|
||||
^
|
||||
|
||||
Does anyone know what is the problem and how to correction it?
|
||||
"Xtestfile", line 21 col 9: What is the title of the quickfix window?
|
||||
"Xtestfile", line 22 col 9: What is the title of the quickfix window?
|
||||
[DATA]
|
||||
Does anyone know what is the problem and how to correction it?
|
||||
"Xtestfile", line 21 col 9: What is the title of the quickfix window?
|
||||
"Xtestfile", line 22 col 9: What is the title of the quickfix window?
|
||||
[DATA]
|
||||
|
||||
call writefile(l, 'Xerrorfile1')
|
||||
call writefile(l[:-2], 'Xerrorfile2')
|
||||
call writefile(l, 'Xerrorfile1')
|
||||
call writefile(l[:-2], 'Xerrorfile2')
|
||||
|
||||
let m =<< [DATA]
|
||||
let m =<< [DATA]
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4
|
||||
@ -1088,55 +1086,55 @@ func Test_efm1()
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22
|
||||
[DATA]
|
||||
call writefile(m, 'Xtestfile')
|
||||
call writefile(m, 'Xtestfile')
|
||||
|
||||
let save_efm = &efm
|
||||
set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m
|
||||
set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m
|
||||
let save_efm = &efm
|
||||
set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m
|
||||
set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m
|
||||
|
||||
exe 'cf Xerrorfile2'
|
||||
clast
|
||||
copen
|
||||
call assert_equal(':cf Xerrorfile2', w:quickfix_title)
|
||||
wincmd p
|
||||
exe 'cf Xerrorfile2'
|
||||
clast
|
||||
copen
|
||||
call assert_equal(':cf Xerrorfile2', w:quickfix_title)
|
||||
wincmd p
|
||||
|
||||
exe 'cf Xerrorfile1'
|
||||
call assert_equal([4, 12], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([6, 19], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([9, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([10, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([11, 1], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([12, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([14, 10], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')])
|
||||
cn
|
||||
call assert_equal([16, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([17, 6], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([18, 7], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([19, 8], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([20, 9], [line('.'), col('.')])
|
||||
clast
|
||||
cprev
|
||||
cprev
|
||||
wincmd w
|
||||
call assert_equal(':cf Xerrorfile1', w:quickfix_title)
|
||||
wincmd p
|
||||
exe 'cf Xerrorfile1'
|
||||
call assert_equal([4, 12], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([6, 19], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([9, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([10, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([11, 1], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([12, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([14, 10], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')])
|
||||
cn
|
||||
call assert_equal([16, 2], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([17, 6], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([18, 7], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([19, 8], [line('.'), col('.')])
|
||||
cn
|
||||
call assert_equal([20, 9], [line('.'), col('.')])
|
||||
clast
|
||||
cprev
|
||||
cprev
|
||||
wincmd w
|
||||
call assert_equal(':cf Xerrorfile1', w:quickfix_title)
|
||||
wincmd p
|
||||
|
||||
let &efm = save_efm
|
||||
call delete('Xerrorfile1')
|
||||
call delete('Xerrorfile2')
|
||||
call delete('Xtestfile')
|
||||
let &efm = save_efm
|
||||
call delete('Xerrorfile1')
|
||||
call delete('Xerrorfile2')
|
||||
call delete('Xtestfile')
|
||||
endfunc
|
||||
|
||||
" Test for quickfix directory stack support
|
||||
|
@ -1808,10 +1808,10 @@ func Test_sign_cursor_position()
|
||||
let lines =<< trim END
|
||||
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
|
||||
call cursor(2,1)
|
||||
sign define s1 texthl=Search text==>
|
||||
sign define s2 linehl=Pmenu
|
||||
sign define s1 texthl=Search text==>
|
||||
sign define s2 linehl=Pmenu
|
||||
redraw
|
||||
sign place 10 line=2 name=s1
|
||||
sign place 10 line=2 name=s1
|
||||
END
|
||||
call writefile(lines, 'XtestSigncolumn', 'D')
|
||||
let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
|
||||
|
@ -89,7 +89,7 @@ func Test_tagfunc()
|
||||
return v:null
|
||||
endfunc
|
||||
set tags= tfu=NullTagFunc
|
||||
call assert_fails('tag nothing', 'E433')
|
||||
call assert_fails('tag nothing', 'E433:')
|
||||
delf NullTagFunc
|
||||
|
||||
bwipe!
|
||||
|
@ -348,8 +348,15 @@ endfunc
|
||||
" Test that the garbage collector isn't triggered if a timer callback invokes
|
||||
" vgetc().
|
||||
func Test_nocatch_timer_garbage_collect()
|
||||
" skipped: Nvim does not support test_garbagecollect_soon(), test_override()
|
||||
return
|
||||
" FIXME: why does this fail only on MacOS M1?
|
||||
try
|
||||
CheckNotMacM1
|
||||
throw 'Skipped: Nvim does not support test_garbagecollect_soon(), test_override()'
|
||||
catch /Skipped/
|
||||
let g:skipped_reason = v:exception
|
||||
return
|
||||
endtry
|
||||
|
||||
" 'uptimetime. must be bigger than the timer timeout
|
||||
set ut=200
|
||||
call test_garbagecollect_soon()
|
||||
|
@ -117,7 +117,6 @@ func Test_true_false_arg()
|
||||
endfunc
|
||||
|
||||
function Try_arg_non_zero(expr, false_val, true_val)
|
||||
CheckFeature float
|
||||
for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
|
||||
let r = eval(substitute(a:expr, '%v%', v, ''))
|
||||
call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r)
|
||||
|
Loading…
Reference in New Issue
Block a user