blob: 2dc78eca486459e6aa7d354d9a9f4143aefa6792 [file] [log] [blame]
Bram Moolenaar46acad72023-06-11 19:04:18 +01001" Runs all the syntax tests for which there is no "done/name" file.
2"
3" Current directory must be runtime/syntax.
4
Christian Brabandtde79f912024-10-24 23:03:10 +02005" needed because of line-continuation lines
6set cpo&vim
7
Bram Moolenaar46acad72023-06-11 19:04:18 +01008" Only do this with the +eval feature
9if 1
10
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010011" Remember the directory where we started. Will change to "testdir" below.
12let syntaxDir = getcwd()
13
14let s:messagesFname = fnameescape(syntaxDir .. '/testdir/messages')
15
16let s:messages = []
17
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010018" Erase the cursor line and do not advance the cursor.
19def EraseLineAndReturnCarriage(rname: string)
20 const full_width: number = winwidth(0)
21 const half_width: number = full_width - (full_width + 1) / 2
22 if (strlen(rname) + strlen('Test' .. "\x20\x20" .. 'FAILED')) > half_width
23 echon "\r" .. repeat("\x20", full_width) .. "\r"
24 else
25 echon repeat("\x20", half_width) .. "\r"
26 endif
27enddef
28
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010029" Add one message to the list of messages
30func Message(msg)
31 echomsg a:msg
32 call add(s:messages, a:msg)
33endfunc
34
35" Report a fatal message and exit
36func Fatal(msg)
37 echoerr a:msg
38 call AppendMessages(a:msg)
39 qall!
40endfunc
41
42" Append s:messages to the messages file and make it empty.
43func AppendMessages(header)
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010044 silent exe 'split ' .. s:messagesFname
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010045 call append(line('$'), '')
46 call append(line('$'), a:header)
47 call append(line('$'), s:messages)
48 let s:messages = []
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010049 silent wq
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010050endfunc
51
52" Relevant messages are written to the "messages" file.
53" If the file already exists it is appended to.
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010054silent exe 'split ' .. s:messagesFname
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010055call append(line('$'), repeat('=-', 70))
56call append(line('$'), '')
Bram Moolenaar031d6322023-06-22 22:38:54 +010057let s:test_run_message = 'Test run on ' .. strftime("%Y %b %d %H:%M:%S")
58call append(line('$'), s:test_run_message)
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010059silent wq
60echo "\n"
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010061
62if syntaxDir !~ '[/\\]runtime[/\\]syntax\>'
63 call Fatal('Current directory must be "runtime/syntax"')
Bram Moolenaar46acad72023-06-11 19:04:18 +010064endif
65if !isdirectory('testdir')
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010066 call Fatal('"testdir" directory not found')
Bram Moolenaar46acad72023-06-11 19:04:18 +010067endif
68
69" Use the script for source code screendump testing. It sources other scripts,
70" therefore we must "cd" there.
71cd ../../src/testdir
72source screendump.vim
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010073exe 'cd ' .. fnameescape(syntaxDir)
Bram Moolenaar46acad72023-06-11 19:04:18 +010074
75" For these tests we need to be able to run terminal Vim with 256 colors. On
76" MS-Windows the console only has 16 colors and the GUI can't run in a
77" terminal.
78if !CanRunVimInTerminal()
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010079 call Fatal('Cannot make screendumps, aborting')
Bram Moolenaar46acad72023-06-11 19:04:18 +010080endif
81
82cd testdir
83if !isdirectory('done')
84 call mkdir('done')
85endif
86
87set nocp
88set nowrapscan
89set report=9999
90set modeline
91set debug=throw
92set nomore
93
94au! SwapExists * call HandleSwapExists()
95func HandleSwapExists()
96 " Ignore finding a swap file for the test input, the user might be editing
97 " it and that's OK.
98 if expand('<afile>') =~ 'input[/\\].*\..*'
99 let v:swapchoice = 'e'
100 endif
101endfunc
102
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100103" Trace ruler liveness on demand.
104if !empty($VIM_SYNTAX_TEST_LOG) && filewritable($VIM_SYNTAX_TEST_LOG)
105 def s:TraceRulerLiveness(context: string, times: number, tail: string)
106 writefile([printf('%s: %4d: %s', context, times, tail)],
107 $VIM_SYNTAX_TEST_LOG,
108 'a')
109 enddef
110else
111 def s:TraceRulerLiveness(_: string, _: number, _: string)
112 enddef
113endif
114
115" See ":help 'ruler'".
116def s:CannotSeeLastLine(ruler: list<string>): bool
117 return !(get(ruler, -1, '') ==# 'All' || get(ruler, -1, '') ==# 'Bot')
118enddef
119
120def s:CannotDumpNextPage(buf: number, prev_ruler: list<string>, ruler: list<string>): bool
121 return !(ruler !=# prev_ruler &&
122 len(ruler) == 2 &&
123 ruler[1] =~# '\%(\d%\|\<Bot\)$' &&
124 get(term_getcursor(buf), 0) != 20)
125enddef
126
127def s:CannotDumpFirstPage(buf: number, _: list<string>, ruler: list<string>): bool
128 return !(len(ruler) == 2 &&
129 ruler[1] =~# '\%(\<All\|\<Top\)$' &&
130 get(term_getcursor(buf), 0) != 20)
131enddef
132
133def s:CannotDumpShellFirstPage(buf: number, _: list<string>, ruler: list<string>): bool
134 return !(len(ruler) > 3 &&
135 get(ruler, -1, '') =~# '\%(\<All\|\<Top\)$' &&
136 get(term_getcursor(buf), 0) != 20)
137enddef
138
139" Poll for updates of the cursor position in the terminal buffer occupying the
140" first window. (ALWAYS call the function or its equivalent before calling
141" "VerifyScreenDump()" *and* after calling any number of "term_sendkeys()".)
142def s:TermPollRuler(
143 CannotDumpPage: func, # (TYPE FOR LEGACY CONTEXT CALL SITES.)
144 buf: number,
145 in_name_and_out_name: string): list<string>
146 # Expect defaults from "term_util#RunVimInTerminal()".
Aliaksei Budavei84184462024-05-21 01:10:26 +0300147 if winwidth(1) != 75 || winheight(1) != 20
148 ch_log(printf('Aborting for %s: (75 x 20) != (%d x %d)',
149 in_name_and_out_name,
150 winwidth(1),
151 winheight(1)))
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100152 return ['0,0-1', 'All']
Aliaksei Budavei84184462024-05-21 01:10:26 +0300153 endif
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100154 # A two-fold role for redrawing:
155 # (*) in case the terminal buffer cannot redraw itself just yet;
156 # (*) to avoid extra "real estate" checks.
Aliaksei Budavei84184462024-05-21 01:10:26 +0300157 redraw
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100158 # The contents of "ruler".
159 var ruler: list<string> = []
160 # Attempts at most, targeting ASan-instrumented Vim builds.
161 var times: number = 2048
162 # Check "real estate" of the terminal buffer. Read and compare its ruler
163 # line and let "Xtestscript#s:AssertCursorForwardProgress()" do the rest.
164 # Note that the cursor ought to be advanced after each successive call of
165 # this function yet its relative position need not be changed (e.g. "0%").
166 while CannotDumpPage(ruler) && times > 0
167 ruler = split(term_getline(buf, 20))
168 sleep 1m
169 times -= 1
170 if times % 8 == 0
171 redraw
172 endif
173 endwhile
174 TraceRulerLiveness('P', (2048 - times), in_name_and_out_name)
175 return ruler
176enddef
177
178" Prevent "s:TermPollRuler()" from prematurely reading the cursor position,
179" which is available at ":edit", after outracing the loading of syntax etc. in
180" the terminal buffer. (Call the function before calling "VerifyScreenDump()"
181" for the first time.)
182def s:TermWaitAndPollRuler(buf: number, in_name_and_out_name: string): list<string>
183 # Expect defaults from "term_util#RunVimInTerminal()".
184 if winwidth(1) != 75 || winheight(1) != 20
185 ch_log(printf('Aborting for %s: (75 x 20) != (%d x %d)',
186 in_name_and_out_name,
187 winwidth(1),
188 winheight(1)))
189 return ['0,0-1', 'All']
190 endif
191 # The contents of "ruler".
192 var ruler: string = ''
193 # Attempts at most, targeting ASan-instrumented Vim builds.
194 var times: number = 32768
195 # Check "real estate" of the terminal buffer. Expect a known token to be
196 # rendered in the terminal buffer; its prefix must be "is_" so that buffer
197 # variables from "sh.vim" can be matched (see "Xtestscript#ShellInfo()").
198 # Verify that the whole line is available!
199 while ruler !~# '^is_.\+\s\%(All\|Top\)$' && times > 0
200 ruler = term_getline(buf, 20)
201 sleep 1m
202 times -= 1
203 if times % 16 == 0
204 redraw
205 endif
206 endwhile
207 TraceRulerLiveness('W', (32768 - times), in_name_and_out_name)
208 if strpart(ruler, 0, 8) !=# 'is_nonce'
209 # Retain any of "b:is_(bash|dash|kornshell|posix|sh)" entries and let
210 # "CannotDumpShellFirstPage()" win the cursor race.
211 return TermPollRuler(
212 function(CannotDumpShellFirstPage, [buf, []]),
213 buf,
214 in_name_and_out_name)
215 else
216 # Clear the "is_nonce" token and let "CannotDumpFirstPage()" win any
217 # race.
218 term_sendkeys(buf, ":redraw!\<CR>")
219 endif
220 return TermPollRuler(
221 function(CannotDumpFirstPage, [buf, []]),
222 buf,
223 in_name_and_out_name)
Aliaksei Budavei84184462024-05-21 01:10:26 +0300224enddef
225
Christian Brabandt56824432024-02-28 21:24:25 +0100226func RunTest()
227 let ok_count = 0
228 let failed_tests = []
229 let skipped_count = 0
230 let MAX_FAILED_COUNT = 5
Aliaksei Budaveif6069a72024-03-05 22:34:36 +0300231 " Create a map of setup configuration filenames with their basenames as keys.
232 let setup = glob('input/setup/*.vim', 1, 1)
233 \ ->reduce({d, f -> extend(d, {fnamemodify(f, ':t:r'): f})}, {})
Aliaksei Budaveiec022942024-10-06 16:57:33 +0200234 " Turn a subset of filenames etc. requested for testing into a pattern.
235 let filter = filereadable('../testdir/Xfilter')
236 \ ? readfile('../testdir/Xfilter')
Aliaksei Budavei6852e5c2025-03-07 19:12:45 +0100237 \ ->map({_, v -> '^' .. substitute(v, '_$', '', '')})
Aliaksei Budaveiec022942024-10-06 16:57:33 +0200238 \ ->join('\|')
239 \ : ''
Aliaksei Budaveif6069a72024-03-05 22:34:36 +0300240
Aliaksei Budaveiec022942024-10-06 16:57:33 +0200241 " Treat "\.self-testing$" as a string NOT as a regexp.
242 if filter ==# '\.self-testing$'
Aliaksei Budaveid2f49872024-05-24 19:14:16 +0300243 let dirpath = 'input/selftestdir/'
Aliaksei Budaveid33afe12024-08-12 18:37:15 +0200244 let fnames = readdir(dirpath, {fname -> fname !~ '^README\.txt$'})
Aliaksei Budaveid2f49872024-05-24 19:14:16 +0300245 else
246 let dirpath = 'input/'
Aliaksei Budaveiec022942024-10-06 16:57:33 +0200247 let filter ..= exists("$VIM_SYNTAX_TEST_FILTER") &&
248 \ !empty($VIM_SYNTAX_TEST_FILTER)
249 \ ? (empty(filter) ? '' : '\|') .. $VIM_SYNTAX_TEST_FILTER
250 \ : ''
251 let fnames = readdir(dirpath,
252 \ {subset -> {fname -> fname !~ '\~$' && fname =~# subset}}(
253 \ empty(filter) ? '^.\+\..\+$' : filter))
Aliaksei Budaveid2f49872024-05-24 19:14:16 +0300254 endif
Bram Moolenaar7d0dbd02023-06-24 00:56:50 +0100255
Aliaksei Budaveid2f49872024-05-24 19:14:16 +0300256 for fname in fnames
257 let root = fnamemodify(fname, ':r')
258 let fname = dirpath .. fname
Christian Brabandt56824432024-02-28 21:24:25 +0100259 let filetype = substitute(root, '\([^_.]*\)[_.].*', '\1', '')
260 let failed_root = 'failed/' .. root
Bram Moolenaar46acad72023-06-11 19:04:18 +0100261
Christian Brabandt56824432024-02-28 21:24:25 +0100262 " Execute the test if the "done" file does not exist or when the input file
263 " is newer.
264 let in_time = getftime(fname)
265 let out_time = getftime('done/' .. root)
266 if out_time < 0 || in_time > out_time
267 call ch_log('running tests for: ' .. fname)
Bram Moolenaar7d0dbd02023-06-24 00:56:50 +0100268
Christian Brabandt56824432024-02-28 21:24:25 +0100269 for dumpname in glob(failed_root .. '_\d*\.dump', 1, 1)
270 call delete(dumpname)
271 endfor
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +0100272 call delete('done/' .. root)
273
Christian Brabandt56824432024-02-28 21:24:25 +0100274 let lines =<< trim END
Aliaksei Budavei71971432024-07-05 21:30:02 +0300275 " Track the cursor progress through a syntax test file so that any
276 " degenerate input can be reported. Each file will have its own cursor.
277 let s:cursor = 1
278
Christian Brabandt56824432024-02-28 21:24:25 +0100279 " extra info for shell variables
280 func ShellInfo()
281 let msg = ''
282 for [key, val] in items(b:)
283 if key =~ '^is_'
284 let msg ..= key .. ': ' .. val .. ', '
285 endif
286 endfor
287 if msg != ''
288 echomsg msg
289 endif
290 endfunc
291
292 au! SwapExists * call HandleSwapExists()
293 func HandleSwapExists()
294 " Ignore finding a swap file for the test input, the user might be
295 " editing it and that's OK.
296 if expand('<afile>') =~ 'input[/\\].*\..*'
297 let v:swapchoice = 'e'
298 endif
299 endfunc
300
301 func LoadFiletype(type)
302 for file in glob("ftplugin/" .. a:type .. "*.vim", 1, 1)
303 exe "source " .. file
304 endfor
305 redraw!
306 endfunc
307
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300308 func SetUpVim()
309 call cursor(1, 1)
Aliaksei Budaveia2addeb2024-03-18 20:39:32 +0100310 " Defend against rogue VIM_TEST_SETUP commands.
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300311 for _ in range(20)
Aliaksei Budaveia2addeb2024-03-18 20:39:32 +0100312 let lnum = search('\C\<VIM_TEST_SETUP\>', 'eW', 20)
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300313 if lnum < 1
314 break
315 endif
Aliaksei Budaveia2addeb2024-03-18 20:39:32 +0100316 exe substitute(getline(lnum), '\C.*\<VIM_TEST_SETUP\>', '', '')
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300317 endfor
318 call cursor(1, 1)
319 " BEGIN [runtime/defaults.vim]
Aliaksei Budaveia2addeb2024-03-18 20:39:32 +0100320 " Also, disable italic highlighting to avoid issues on some terminals.
Aliaksei Budavei84184462024-05-21 01:10:26 +0300321 set display=lastline ruler scrolloff=5 t_ZH= t_ZR=
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300322 syntax on
323 " END [runtime/defaults.vim]
324 redraw!
325 endfunc
Aliaksei Budavei84184462024-05-21 01:10:26 +0300326
Aliaksei Budavei71971432024-07-05 21:30:02 +0300327 def s:AssertCursorForwardProgress(): bool
328 const curnum: number = line('.')
329 if curnum <= cursor
330 # Use "actions/upload-artifact@v4" of ci.yml for delivery.
331 writefile([printf('No cursor progress: %d <= %d (%s). Please file an issue.',
332 curnum,
333 cursor,
334 bufname('%'))],
335 'failed/00-FIXME',
336 'a')
337 bwipeout!
338 endif
339 cursor = curnum
340 return true
341 enddef
342
343 def ScrollToSecondPage(estate: number, op_wh: number, op_so: number): bool
Aliaksei Budavei84184462024-05-21 01:10:26 +0300344 if line('.') != 1 || line('w$') >= line('$')
Aliaksei Budavei71971432024-07-05 21:30:02 +0300345 return AssertCursorForwardProgress()
Aliaksei Budavei84184462024-05-21 01:10:26 +0300346 endif
347 try
348 set scrolloff=0
349 # Advance mark "c"[ursor] along with the cursor.
350 norm! Lmc
351 if foldclosed('.') < 0 &&
352 (strdisplaywidth(getline('.')) + &l:fdc * winheight(1)) >= estate
353 # Make for an exit for a screenful long line.
354 norm! j^
Aliaksei Budavei71971432024-07-05 21:30:02 +0300355 return AssertCursorForwardProgress()
Aliaksei Budavei84184462024-05-21 01:10:26 +0300356 else
357 # Place the cursor on the actually last visible line.
358 while winline() < op_wh
359 const lastnum: number = winline()
360 norm! gjmc
361 if lastnum > winline()
362 break
363 endif
364 endwhile
365 norm! zt
366 endif
367 finally
368 # COMPATIBILITY: Scroll up around "scrolloff" lines.
369 &scrolloff = max([1, op_so])
370 endtry
371 norm! ^
Aliaksei Budavei71971432024-07-05 21:30:02 +0300372 return AssertCursorForwardProgress()
Aliaksei Budavei84184462024-05-21 01:10:26 +0300373 enddef
374
Aliaksei Budavei71971432024-07-05 21:30:02 +0300375 def ScrollToNextPage(estate: number, op_wh: number, op_so: number): bool
Aliaksei Budavei84184462024-05-21 01:10:26 +0300376 if line('.') == 1 || line('w$') >= line('$')
Aliaksei Budavei71971432024-07-05 21:30:02 +0300377 return AssertCursorForwardProgress()
Aliaksei Budavei84184462024-05-21 01:10:26 +0300378 endif
379 try
380 set scrolloff=0
381 # Advance mark "c"[ursor] along with the cursor.
382 norm! Lmc
383 if foldclosed('.') < 0 &&
384 (strdisplaywidth(getline('.')) + &l:fdc * winheight(1)) >= estate
385 # Make for an exit for a screenful long line.
386 norm! j^
Aliaksei Budavei71971432024-07-05 21:30:02 +0300387 return AssertCursorForwardProgress()
Aliaksei Budavei84184462024-05-21 01:10:26 +0300388 else
389 # Place the cursor on the actually last visible line.
390 while winline() < op_wh
391 const lastnum: number = winline()
392 norm! gjmc
393 if lastnum > winline()
394 break
395 endif
396 endwhile
397 endif
398 finally
399 # COMPATIBILITY: Scroll up/down around "scrolloff" lines.
400 &scrolloff = max([1, op_so])
401 endtry
402 norm! zt
403 const marknum: number = line("'c")
404 # Eschew &smoothscroll since line("`c") is not supported.
405 # Remember that "w0" can point to the first line of a _closed_ fold
406 # whereas the last line of a _closed_ fold can be marked.
407 if line('w0') > marknum
408 while line('w0') > marknum
409 exe "norm! \<C-y>"
410 endwhile
411 if line('w0') != marknum
412 exe "norm! \<C-e>H"
413 endif
414 # Handle non-wrapped lines.
415 elseif line('w0') < marknum
416 while line('w0') < marknum
417 exe "norm! \<C-e>"
418 endwhile
419 if line('w0') != marknum
420 exe "norm! \<C-y>H"
421 endif
422 endif
423 norm! ^
Aliaksei Budavei71971432024-07-05 21:30:02 +0300424 return AssertCursorForwardProgress()
Aliaksei Budavei84184462024-05-21 01:10:26 +0300425 enddef
Christian Brabandt56824432024-02-28 21:24:25 +0100426 END
427 call writefile(lines, 'Xtestscript')
428
429 " close all but the last window
430 while winnr('$') > 1
431 close
432 endwhile
433
434 " Redraw to make sure that messages are cleared and there is enough space
435 " for the terminal window.
436 redraw
437
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300438 " Let "Xtestscript#SetUpVim()" turn the syntax on.
Aliaksei Budaveif6069a72024-03-05 22:34:36 +0300439 let prefix = '-Nu NONE -S Xtestscript'
440 let path = get(setup, root, '')
441 " Source the found setup configuration file.
442 let args = !empty(path)
443 \ ? prefix .. ' -S ' .. path
444 \ : prefix
445 let buf = RunVimInTerminal(args, {})
Christian Brabandt56824432024-02-28 21:24:25 +0100446 " edit the file only after catching the SwapExists event
447 call term_sendkeys(buf, ":edit " .. fname .. "\<CR>")
Aliaksei Budavei93edd252024-03-05 22:34:36 +0300448 " set up the testing environment
449 call term_sendkeys(buf, ":call SetUpVim()\<CR>")
Christian Brabandt56824432024-02-28 21:24:25 +0100450 " load filetype specific settings
451 call term_sendkeys(buf, ":call LoadFiletype('" .. filetype .. "')\<CR>")
452
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100453 " Make a synchronisation point between buffers by requesting to echo
454 " a known token in the terminal buffer and asserting its availability
455 " with "s:TermWaitAndPollRuler()".
Christian Brabandt56824432024-02-28 21:24:25 +0100456 if filetype == 'sh'
457 call term_sendkeys(buf, ":call ShellInfo()\<CR>")
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100458 else
459 call term_sendkeys(buf, ":echo 'is_nonce'\<CR>")
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +0100460 endif
Christian Brabandt56824432024-02-28 21:24:25 +0100461
Christian Brabandt56824432024-02-28 21:24:25 +0100462 let root_00 = root .. '_00'
Aliaksei Budavei84184462024-05-21 01:10:26 +0300463 let in_name_and_out_name = fname .. ': failed/' .. root_00 .. '.dump'
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100464 " Queue up all "term_sendkeys()"es and let them finish before returning
465 " from "s:TermWaitAndPollRuler()".
466 let ruler = s:TermWaitAndPollRuler(buf, in_name_and_out_name)
Aliaksei Budavei84184462024-05-21 01:10:26 +0300467 call ch_log('First screendump for ' .. in_name_and_out_name)
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100468 " Make a screendump at the start of the file: failed/root_00.dump
Christian Brabandt56824432024-02-28 21:24:25 +0100469 let fail = VerifyScreenDump(buf, root_00, {})
470
Aliaksei Budavei71971432024-07-05 21:30:02 +0300471 " Accommodate the next code block to "buf"'s contingency for self
472 " wipe-out.
473 try
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100474 let nr = 0
475 let keys_a = ":call ScrollToSecondPage((18 * 75 + 1), 19, 5) | redraw!\<CR>"
476 let keys_b = ":call ScrollToNextPage((18 * 75 + 1), 19, 5) | redraw!\<CR>"
477 while s:CannotSeeLastLine(ruler)
478 call term_sendkeys(buf, keys_a)
479 let keys_a = keys_b
Aliaksei Budavei84184462024-05-21 01:10:26 +0300480 let nr += 1
481 let root_next = printf('%s_%02d', root, nr)
482 let in_name_and_out_name = fname .. ': failed/' .. root_next .. '.dump'
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100483 let ruler = s:TermPollRuler(
484 \ function('s:CannotDumpNextPage', [buf, ruler]),
485 \ buf,
486 \ in_name_and_out_name)
487 call ch_log('Next screendump for ' .. in_name_and_out_name)
488 " Make a screendump of every 18 lines of the file: failed/root_NN.dump
489 let fail += VerifyScreenDump(buf, root_next, {})
490 endwhile
Aliaksei Budavei71971432024-07-05 21:30:02 +0300491 call StopVimInTerminal(buf)
492 finally
493 call delete('Xtestscript')
494 endtry
Christian Brabandt56824432024-02-28 21:24:25 +0100495
496 " redraw here to avoid the following messages to get mixed up with screen
497 " output.
498 redraw
499
500 " Add any assert errors to s:messages.
501 if len(v:errors) > 0
502 call extend(s:messages, v:errors)
503 " Echo the errors here, in case the script aborts or the "messages" file
504 " is not displayed later.
505 echomsg v:errors
506 let v:errors = []
507 let fail += 1
508 endif
509
510 if fail == 0
511 call Message("Test " .. root .. " OK")
512
513 call writefile(['OK'], 'done/' .. root)
514
515 let ok_count += 1
516 else
517 call Message("Test " .. root .. " FAILED")
518
519 call delete('done/' .. root)
520
521 eval failed_tests->add(root)
522 if len(failed_tests) > MAX_FAILED_COUNT
523 call Message('')
524 call Message('Too many errors, aborting')
525 endif
526 endif
527 else
528 call Message("Test " .. root .. " skipped")
529 let skipped_count += 1
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +0100530 endif
Christian Brabandt56824432024-02-28 21:24:25 +0100531
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100532 call EraseLineAndReturnCarriage(root)
533
Christian Brabandt56824432024-02-28 21:24:25 +0100534 " Append messages to the file "testdir/messages"
535 call AppendMessages('Input file ' .. fname .. ':')
536
537 if len(failed_tests) > MAX_FAILED_COUNT
538 break
539 endif
540 endfor
541
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100542 call EraseLineAndReturnCarriage('')
Christian Brabandt56824432024-02-28 21:24:25 +0100543 call Message(s:test_run_message)
544 call Message('OK: ' .. ok_count)
545 call Message('FAILED: ' .. len(failed_tests) .. ': ' .. string(failed_tests))
546 call Message('skipped: ' .. skipped_count)
Aliaksei Budaveid33afe12024-08-12 18:37:15 +0200547
548 if !empty(failed_tests)
549 call Message('')
550 call Message('View generated screendumps with "../../src/vim --clean -S testdir/viewdumps.vim"')
551 endif
552
Christian Brabandt203c7222024-10-29 20:21:42 +0100553 call AppendMessages('== SUMMARY SYNTAX TESTS ==')
Christian Brabandt56824432024-02-28 21:24:25 +0100554
555 if len(failed_tests) > 0
556 " have make report an error
557 cquit
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +0100558 endif
Christian Brabandt56824432024-02-28 21:24:25 +0100559endfunc
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +0100560
Christian Brabandt56824432024-02-28 21:24:25 +0100561call RunTest()
Christian Brabandt627c9502024-02-10 13:02:17 +0100562
563" Matching "if 1" at the start.
564endif
565
Bram Moolenaar46acad72023-06-11 19:04:18 +0100566qall!
Christian Brabandt56824432024-02-28 21:24:25 +0100567
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +0100568" vim:sw=2:ts=8:noet: