blob: d57341d226b6f715b79b96e11e8fe4f3920396df [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
5" Only do this with the +eval feature
6if 1
7
8let cwd = getcwd()
9if cwd !~ '[/\\]runtime[/\\]syntax\>'
10 echoerr 'Current directory must be "runtime/syntax"'
11 qall
12endif
13if !isdirectory('testdir')
14 echoerr '"testdir" directory not found'
15 qall
16endif
17
18" Use the script for source code screendump testing. It sources other scripts,
19" therefore we must "cd" there.
20cd ../../src/testdir
21source screendump.vim
22exe 'cd ' .. fnameescape(cwd)
23
24" For these tests we need to be able to run terminal Vim with 256 colors. On
25" MS-Windows the console only has 16 colors and the GUI can't run in a
26" terminal.
27if !CanRunVimInTerminal()
28 echomsg 'Cannot make screendumps, aborting'
29 qall
30endif
31
32cd testdir
33if !isdirectory('done')
34 call mkdir('done')
35endif
36
37set nocp
38set nowrapscan
39set report=9999
40set modeline
41set debug=throw
42set nomore
43
44au! SwapExists * call HandleSwapExists()
45func HandleSwapExists()
46 " Ignore finding a swap file for the test input, the user might be editing
47 " it and that's OK.
48 if expand('<afile>') =~ 'input[/\\].*\..*'
49 let v:swapchoice = 'e'
50 endif
51endfunc
52
53
54let failed_count = 0
55for fname in glob('input/*.*', 1, 1)
56 if fname =~ '\~$'
57 " backup file, skip
58 continue
59 endif
60
61 let linecount = readfile(fname)->len()
62 let root = substitute(fname, 'input[/\\]\(.*\)\..*', '\1', '')
63
64 " Execute the test if the "done" file does not exist of when the input file
65 " is newer.
66 let in_time = getftime(fname)
67 let out_time = getftime('done/' .. root)
68 if out_time < 0 || in_time > out_time
69 for dumpname in glob('failed/' .. root .. '_\d*\.dump', 1, 1)
70 call delete(dumpname)
71 endfor
72 call delete('done/' .. root)
73
74 let lines =<< trim END
75 syntax on
76 END
77 call writefile(lines, 'Xtestscript')
78 let buf = RunVimInTerminal('-S Xtestscript ' .. fname, {})
79
80 " Screendump at the start of the file: root_00.dump
81 let fail = VerifyScreenDump(buf, root .. '_00', {})
82
83 " Make a Screendump every 18 lines of the file: root_NN.dump
84 let topline = 1
85 let nr = 1
86 while linecount - topline > 20
87 let topline += 18
88 call term_sendkeys(buf, printf("%dGzt", topline))
89 let fail += VerifyScreenDump(buf, root .. printf('_%02d', nr), {})
90 let nr += 1
91 endwhile
92
93 " Screendump at the end of the file: root_99.dump
94 call term_sendkeys(buf, 'Gzb')
95 let fail += VerifyScreenDump(buf, root .. '_99', {})
96
97 call StopVimInTerminal(buf)
98 call delete('Xtestscript')
99
100 if fail == 0
101 call writefile(['OK'], 'done/' . root)
102 echo "Test " . root . " OK\n"
103 else
104 let failed_count += 1
105 endif
106 endif
107endfor
108
109" Matching "if 1" at the start.
110endif
111
112if failed_count > 0
113 " have make report an error
114 cquit
115endif
116qall!