runtime(syntax-tests): simplify code and allow filetype options

The whole testdir/runtest.vim is a bit of a mess. So this is an attempt
to improving the current state. First of all, let's move most of the
code into a single RunTest() function so that it's easier to run this
manually.

Then, let's add the possibility to customize filetype specific tests by
applying filetype specific options. We will make use of it in the next
commit, where the provided java file uses tabs, which cause line
wrapping which will then cause the scrolling to miss some lines when
redrawing (see #14105)

related: #14105

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2024-02-28 21:24:25 +01:00
parent 0c98a71236
commit 56824430c0
21 changed files with 184 additions and 165 deletions

View File

@ -1,5 +1,8 @@
# Portable Makefile for running syntax tests.
# To run the test manually:
# ../../src/vim -u 'testdir/runtest.vim' --cmd 'breakadd func RunTest'
# Override this if needed, the default assumes Vim was build in the src dir.
#VIMPROG = vim
VIMPROG = ../../src/vim

View File

@ -17,4 +17,4 @@
|#+0#e000e06&| |i|n|c|l|u|d|e| |<+0#e000002&|l|i|m|i|t|s|.|h|>| +0#0000000&@54
|#+0#e000e06&|e|n|d|i|f| +0#0000000&@68
@75
|"|i|n|p|u|t|/|c|.|c|"| |1|2@1|L|,| |3|1|7|4|B| @33|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48
|F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&|I+0#e000002&|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&|U+0#e000002&|N|I|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&@30
@75
|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|i|s|o|.|d|e|f|"| |1@1|4|L|,| |2|3|1|8|B| @21|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60
@75
|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52
|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|p|i|m|.|d|e|f|"| |1@2|L|,| |2|1|9|7|B| @21|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|N+0#e000002&|I|L| +0#0000000&|F+0#e000002&|A|L|S|E| +0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60
@75
|(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52
|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|r|1|0|.|d|e|f|"| |1|4|6|L|,| |2|9|8|3|B| @21|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|i+0#af5f00255&|a|b@1|r|e|v| +0#0000000&|<+0#e000e06&|e|x|p|r|>| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&|i|f|o@1| |c|f|o@1|b|a|r| @38
@75
|u+0#af5f00255&|n|a|b@1|r|e|v| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&|f|o@1| @53
|"|i|n|p|u|t|/|v|i|m|_|e|x|_|a|b@1|r|e|v|i|a|t|e|.|v|i|m|"| |2|5|L|,| |5@1|8|B| @17|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|~| @73
|~| @73
|~| @73
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|e|x|_|b|e|h|a|v|e|.|v|i|m|"| |7|L|,| |7@1|B| @23|1|,|1| @10|A|l@1|
| +0#0000000&@56|1|,|1| @10|A|l@1|

View File

@ -17,4 +17,4 @@
|~| @73
|~| @73
|~| @73
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|e|x|_|b|e|h|a|v|e|.|v|i|m|"| |7|L|,| |7@1|B| @23|7|,|1| @10|A|l@1|
| +0#0000000&@56|7|,|1| @10|A|l@1|

View File

@ -17,4 +17,4 @@
|:|3+0#af5f00255&|m|a|t|c|h| +0#0000000&@67
|:+0#af5f00255&|a|p@1|e|n|d| +0#0000000&@67
| +0#e000002&@3|t|e|x|t| +0#0000000&@66
|"|i|n|p|u|t|/|v|i|m|_|e|x|_|c|o|m@1|a|n|d|s|.|v|i|m|"| |1@1|9|5|L|,| |1|7|3|0|1|B| @15|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
@75
|"+0#0000e05&| |:|e|c|h|o| |w|i|t|h|o|u|t| |{|e|x|p|r|}| +0#0000000&@52
|e+0#af5f00255&|c|h|o||+0#0000000&| |e+0#af5f00255&|c|h|o| +0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@58
|"|i|n|p|u|t|/|v|i|m|_|e|x|_|e|c|h|o|.|v|i|m|"| |2|0|L|,| |3|6|2|B| @23|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|o+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|i+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|l+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&@56
|"|i|n|p|u|t|/|v|i|m|_|e|x|_|m|a|p|.|v|i|m|"| |2|1|L|,| |3|1|6|B| @24|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|:|s+0#af5f00255&|m|a|g|i|c|/+0#e000e06&|f+0#0000000&|o@1|/+0#e000e06&|b+0#0000000&|a|r|/+0#e000e06&|c|e|g|i|I|n|p|#|l|r| +0#0000000&@48
@75
|c+0#af5f00255&|a|l@1| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&||| |s+0#af5f00255&|u|b|s|t|i|t|u|t|e|/+0#e000e06&|f+0#0000000&|o@1|/+0#e000e06&|b+0#0000000&|a|r|/+0#e000e06&|&| +0#0000000&@41
|"|i|n|p|u|t|/|v|i|m|_|e|x|_|s|u|b|s|t|i|t|u|t|e|.|v|i|m|"| |8|6|L|,| |1|5|1|0|B| @16|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|e+0#af5f00255&|c|h|o| +0#0000000&|$+0#e000002&|'|\|3|1|6| |\|3|1| |\|3| |\|x|1|f| |\|x|f| |\|X|1|F| |\|X|F| |\|u|0|2|a|4| |\|U|0@4|2|a|4| |\|b| |\|e| |\|f| |\|n| |\|r| |\|t| |\@1
| |\|"| |\|<|C|-|W|>|'| +0#0000000&@63
|e+0#af5f00255&|c|h|o| +0#0000000&|$+0#e000002&|"|\+0#e000e06&|3|1|6|0+0#e000002&| |-| |\+0#e000e06&|x|1|f|0+0#e000002&| |-| |\+0#e000e06&|X|1|F|0+0#e000002&| |-| |\+0#e000e06&|u|0|2|a|4|0+0#e000002&| |-| |\+0#e000e06&|U|0@4|2|a|4|0+0#e000002&|"| +0#0000000&@21
|"|i|n|p|u|t|/|v|i|m|_|e|x|p|r|.|v|i|m|"| |3|1|L|,| |1@1|6|2|B| @25|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|<+0#e000e06&|x|C|S|I|>| +0#0000000&@68
|<+0#e000e06&|B|a|r|>| +0#0000000&@69
|<+0#e000e06&|B|s|l|a|s|h|>| +0#0000000&@66
|"|i|n|p|u|t|/|v|i|m|_|k|e|y|_|n|o|t|a|t|i|o|n|.|v|i|m|"| |1|6|3|L|,| |1|3|4|6|B| @16|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|s+0#af5f00255&|c|r|i|p|t|e|n|c|o|d|i|n|g| +0#0000000&|u|t|f|-+0#af5f00255&|8+0#e000002&| +0#0000000&@54
@75
|@+0#4040ff13&@2| @71
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|k|e|y|m|a|p|.|v|i|m|"| |2|6|L|,| |3|9@1|2|B| @23|1|,|1| @10|T|o|p|
| +0#0000000&@56|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
@8|\+0#e000e06&| +0#0000000&|b+0#af5f00255&| +0#0000000&|=+0#af5f00255&| +0#0000000&|{+0#e000e06&|a+0#00e0e07&|:|b|}+0#e000e06&|,+0#0000000&| @54
| +0#0000e05&@7|"|\| |p|r|i|n|t| |c| +0#0000000&@56
@8|\+0#e000e06&| +0#0000000&|c+0#af5f00255&| +0#0000000&|=+0#af5f00255&| +0#0000000&|{+0#e000e06&|a+0#00e0e07&|:|c|}+0#e000e06&| +0#0000000&@55
|"|i|n|p|u|t|/|v|i|m|_|l|i|n|e|_|c|o|n|t|i|n|u|a|t|i|o|n|.|v|i|m|"| |4|9|L|,| |6|2|6|B| @13|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|q+0#af5f00255&|u|i|t| +0#0000000&@70
|~+0#4040ff13&| @73
|~| @73
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|n|e|w|.|v|i|m|"| |1|7|L|,| |2|0|5|B| @27|1|,|1| @10|A|l@1|
| +0#0000000&@56|1|,|1| @10|A|l@1|

View File

@ -17,4 +17,4 @@
>q+0#af5f00255&|u|i|t| +0#0000000&@70
|~+0#4040ff13&| @73
|~| @73
|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|n|e|w|.|v|i|m|"| |1|7|L|,| |2|0|5|B| @27|1|7|,|1| @9|A|l@1|
| +0#0000000&@56|1|7|,|1| @9|A|l@1|

View File

@ -17,4 +17,4 @@
@6|"+0#0000e05&|\| |c|o|n|t|a|i|n|e|d| |o|p|t|i|o|n| +0#0000000&@49
@6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d| +0#0000000&@57
@6|"+0#0000e05&|\| |c|o|n|t|a|i|n|e|d|i|n| |o|p|t|i|o|n| +0#0000000&@47
|"|i|n|p|u|t|/|v|i|m|_|s|y|n|t|a|x|.|v|i|m|"| |1|6|4|L|,| |3|7|2|9|B| @22|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -17,4 +17,4 @@
|l+0#af5f00255&|e|t| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|/+0#af5f00255&|=| +0#0000000&|e|x|p|r| @59
|l+0#af5f00255&|e|t| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|%+0#af5f00255&|=| +0#0000000&|e|x|p|r| @59
|l+0#af5f00255&|e|t| +0#0000000&|f+0#00e0e07&|o@1| +0#0000000&|.+0#af5f00255&|=| +0#0000000&|e|x|p|r| @59
|"|i|n|p|u|t|/|v|i|m|_|v|a|r|i|a|b|l|e|s|.|v|i|m|"| |1|3|8|L|,| |1|5@1|4|B| @19|1|,|1| @10|T|o|p|
@57|1|,|1| @10|T|o|p|

View File

@ -85,11 +85,12 @@ func HandleSwapExists()
endif
endfunc
let ok_count = 0
let failed_tests = []
let skipped_count = 0
let MAX_FAILED_COUNT = 5
for fname in glob('input/*.*', 1, 1)
func RunTest()
let ok_count = 0
let failed_tests = []
let skipped_count = 0
let MAX_FAILED_COUNT = 5
for fname in glob('input/*.*', 1, 1)
if fname =~ '\~$'
" backup file, skip
continue
@ -136,6 +137,14 @@ for fname in glob('input/*.*', 1, 1)
let v:swapchoice = 'e'
endif
endfunc
func LoadFiletype(type)
for file in glob("ftplugin/" .. a:type .. "*.vim", 1, 1)
exe "source " .. file
endfor
redraw!
endfunc
END
call writefile(lines, 'Xtestscript')
@ -151,6 +160,8 @@ for fname in glob('input/*.*', 1, 1)
let buf = RunVimInTerminal('-S Xtestscript', {})
" edit the file only after catching the SwapExists event
call term_sendkeys(buf, ":edit " .. fname .. "\<CR>")
" load filetype specific settings
call term_sendkeys(buf, ":call LoadFiletype('" .. filetype .. "')\<CR>")
if filetype == 'sh'
call term_sendkeys(buf, ":call ShellInfo()\<CR>")
@ -229,20 +240,25 @@ for fname in glob('input/*.*', 1, 1)
if len(failed_tests) > MAX_FAILED_COUNT
break
endif
endfor
endfor
call Message(s:test_run_message)
call Message('OK: ' .. ok_count)
call Message('FAILED: ' .. len(failed_tests) .. ': ' .. string(failed_tests))
call Message('skipped: ' .. skipped_count)
call AppendMessages('== SUMMARY ==')
call Message(s:test_run_message)
call Message('OK: ' .. ok_count)
call Message('FAILED: ' .. len(failed_tests) .. ': ' .. string(failed_tests))
call Message('skipped: ' .. skipped_count)
call AppendMessages('== SUMMARY ==')
if len(failed_tests) > 0
if len(failed_tests) > 0
" have make report an error
cquit
endif
endif
endfunc
call RunTest()
" Matching "if 1" at the start.
endif
qall!
" vim:ts=8