annotate runtime/indent/testdir/runtest.vim @ 20299:8a6e2b44b08f v8.2.0705

patch 8.2.0705: indent tests don't run on CI for FreeBSD Commit: https://github.com/vim/vim/commit/3657686a0e8fd07428a25c2cf9efcc8b5d33f895 Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 6 22:25:05 2020 +0200 patch 8.2.0705: indent tests don't run on CI for FreeBSD Problem: Indent tests don't run on CI for FreeBSD. Solution: Set modeline. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/6048)
author Bram Moolenaar <Bram@vim.org>
date Wed, 06 May 2020 22:30:05 +0200
parents a0e0f0256d0b
children ebed259f919f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15069
3f82f25df8d2 patch 8.1.0545: when executing indent tests user preferences interfere
Bram Moolenaar <Bram@vim.org>
parents: 14970
diff changeset
1 " Runs all the indent tests for which there is no .out file.
3f82f25df8d2 patch 8.1.0545: when executing indent tests user preferences interfere
Bram Moolenaar <Bram@vim.org>
parents: 14970
diff changeset
2 "
3f82f25df8d2 patch 8.1.0545: when executing indent tests user preferences interfere
Bram Moolenaar <Bram@vim.org>
parents: 14970
diff changeset
3 " Current directory must be runtime/indent.
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4
15178
5c3ca8f7adea patch 8.1.0599: without the +eval feature the indent tests don't work
Bram Moolenaar <Bram@vim.org>
parents: 15069
diff changeset
5 " Only do this with the +eval feature
5c3ca8f7adea patch 8.1.0599: without the +eval feature the indent tests don't work
Bram Moolenaar <Bram@vim.org>
parents: 15069
diff changeset
6 if 1
5c3ca8f7adea patch 8.1.0599: without the +eval feature the indent tests don't work
Bram Moolenaar <Bram@vim.org>
parents: 15069
diff changeset
7
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 set nocp
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 filetype indent on
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15194
diff changeset
10 syn on
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 set nowrapscan
15194
8b334e4cb97f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15178
diff changeset
12 set report=9999
20299
8a6e2b44b08f patch 8.2.0705: indent tests don't run on CI for FreeBSD
Bram Moolenaar <Bram@vim.org>
parents: 18848
diff changeset
13 set modeline
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 au! SwapExists * call HandleSwapExists()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 func HandleSwapExists()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 " Ignore finding a swap file for the test input and output, the user might be
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 " editing them and that's OK.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 if expand('<afile>') =~ '.*\.\(in\|out\|fail\|ok\)'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 let v:swapchoice = 'e'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 endfunc
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
18122
0cc306ebc8fe patch 8.1.2056: "make test" for indent files doesn't cause make to fail
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
24 let failed_count = 0
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 for fname in glob('testdir/*.in', 1, 1)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 let root = substitute(fname, '\.in', '', '')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 " Execute the test if the .out file does not exist of when the .in file is
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 " newer.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 let in_time = getftime(fname)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 let out_time = getftime(root . '.out')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 if out_time < 0 || in_time > out_time
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 call delete(root . '.fail')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call delete(root . '.out')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 set sw& ts& filetype=
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 exe 'split ' . fname
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 let did_some = 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 let failed = 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 let end = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 while 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 " Indent all the lines between "START_INDENT" and "END_INDENT"
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 exe end
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let start = search('\<START_INDENT\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 let end = search('\<END_INDENT\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 if start <= 0 || end <= 0 || end <= start
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 if did_some == 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 call append(0, 'ERROR: START_INDENT and/or END_INDENT not found')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 let did_some = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 " Execute all commands marked with INDENT_EXE and find any pattern.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 let lnum = start
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 let pattern = ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 let at = ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 while 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 exe lnum + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 let lnum_exe = search('\<INDENT_EXE\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 exe lnum + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 let indent_at = search('\<INDENT_\(AT\|NEXT\|PREV\)\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 if lnum_exe > 0 && lnum_exe < end && (indent_at <= 0 || lnum_exe < indent_at)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 exe substitute(getline(lnum_exe), '.*INDENT_EXE', '', '')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 let lnum = lnum_exe
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 let start = lnum
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 elseif indent_at > 0 && indent_at < end
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 if pattern != ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 call append(indent_at, 'ERROR: duplicate pattern')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 let text = getline(indent_at)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 let pattern = substitute(text, '.*INDENT_\S*\s*', '', '')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 let at = substitute(text, '.*INDENT_\(\S*\).*', '\1', '')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 let lnum = indent_at
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 let start = lnum
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 endwhile
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 exe start + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 if pattern == ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 exe 'normal =' . (end - 1) . 'G'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 let lnum = search(pattern)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 if lnum <= 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call append(indent_at, 'ERROR: pattern not found: ' . pattern)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 if at == 'AT'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 exe lnum
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 elseif at == 'NEXT'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 exe lnum + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 exe lnum - 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 normal ==
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 endwhile
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 if !failed
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 " Check the resulting text equals the .ok file.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 if getline(1, '$') != readfile(root . '.ok')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 if failed
18122
0cc306ebc8fe patch 8.1.2056: "make test" for indent files doesn't cause make to fail
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
115 let failed_count += 1
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 exe 'write ' . root . '.fail'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 echoerr 'Test ' . fname . ' FAILED!'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 exe 'write ' . root . '.out'
18848
a0e0f0256d0b Runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 18122
diff changeset
120 echo "Test " . fname . " OK\n"
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 quit! " close the indented file
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 endfor
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126
15178
5c3ca8f7adea patch 8.1.0599: without the +eval feature the indent tests don't work
Bram Moolenaar <Bram@vim.org>
parents: 15069
diff changeset
127 " Matching "if 1" at the start.
5c3ca8f7adea patch 8.1.0599: without the +eval feature the indent tests don't work
Bram Moolenaar <Bram@vim.org>
parents: 15069
diff changeset
128 endif
5c3ca8f7adea patch 8.1.0599: without the +eval feature the indent tests don't work
Bram Moolenaar <Bram@vim.org>
parents: 15069
diff changeset
129
18122
0cc306ebc8fe patch 8.1.2056: "make test" for indent files doesn't cause make to fail
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
130 if failed_count > 0
0cc306ebc8fe patch 8.1.2056: "make test" for indent files doesn't cause make to fail
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
131 " have make report an error
0cc306ebc8fe patch 8.1.2056: "make test" for indent files doesn't cause make to fail
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
132 cquit
0cc306ebc8fe patch 8.1.2056: "make test" for indent files doesn't cause make to fail
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
133 endif
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 qall!