annotate runtime/indent/testdir/runtest.vim @ 18122:0cc306ebc8fe v8.1.2056

patch 8.1.2056: "make test" for indent files doesn't cause make to fail Commit: https://github.com/vim/vim/commit/cd67059c0c3abf1e28aa66458abdf6f338252eb2 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 18 22:14:43 2019 +0200 patch 8.1.2056: "make test" for indent files doesn't cause make to fail Problem: "make test" for indent files doesn't cause make to fail. Solution: Exit the script with ":cquit". (Daniel Hahler, closes https://github.com/vim/vim/issues/4949)
author Bram Moolenaar <Bram@vim.org>
date Wed, 18 Sep 2019 22:15:04 +0200
parents bd7461db24b3
children a0e0f0256d0b
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
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 au! SwapExists * call HandleSwapExists()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 func HandleSwapExists()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 " 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
17 " editing them and that's OK.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 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
19 let v:swapchoice = 'e'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 endfunc
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
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
23 let failed_count = 0
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 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
25 let root = substitute(fname, '\.in', '', '')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 " 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
28 " newer.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 let in_time = getftime(fname)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 let out_time = getftime(root . '.out')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 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
32 call delete(root . '.fail')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 call delete(root . '.out')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 set sw& ts& filetype=
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 exe 'split ' . fname
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 let did_some = 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 let failed = 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 let end = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 while 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 " 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
43 exe end
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 let start = search('\<START_INDENT\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let end = search('\<END_INDENT\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 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
47 if did_some == 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 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
49 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 let did_some = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 " 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
56 let lnum = start
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 let pattern = ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 let at = ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 while 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 exe lnum + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 let lnum_exe = search('\<INDENT_EXE\>')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 exe lnum + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 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
64 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
65 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
66 let lnum = lnum_exe
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 let start = lnum
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 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
69 if pattern != ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 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
71 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 let text = getline(indent_at)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 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
76 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
77 let lnum = indent_at
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 let start = lnum
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 endwhile
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 exe start + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 if pattern == ''
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 exe 'normal =' . (end - 1) . 'G'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 let lnum = search(pattern)
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 if lnum <= 0
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 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
91 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 break
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 if at == 'AT'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 exe lnum
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 elseif at == 'NEXT'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 exe lnum + 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 exe lnum - 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 normal ==
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 endif
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 endwhile
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 if !failed
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 " 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
108 if getline(1, '$') != readfile(root . '.ok')
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 let failed = 1
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 endif
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
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 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
114 let failed_count += 1
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 exe 'write ' . root . '.fail'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 echoerr 'Test ' . fname . ' FAILED!'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 else
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 exe 'write ' . root . '.out'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 quit! " close the indented file
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 endif
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 endfor
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124
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
125 " 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
126 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
127
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
128 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
129 " 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
130 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
131 endif
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 qall!