Mercurial > vim
annotate runtime/indent/testdir/runtest.vim @ 15069:3f82f25df8d2 v8.1.0545
patch 8.1.0545: when executing indent tests user preferences interfere
commit https://github.com/vim/vim/commit/dc2f73a6980be13c97a83047d0de50824bc0f20f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 25 04:03:09 2018 +0100
patch 8.1.0545: when executing indent tests user preferences interfere
Problem: When executing indent tests user preferences interfere.
Solution: Add "--clean".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 25 Nov 2018 04:15:05 +0100 |
parents | 19b757c6c6a7 |
children | 5c3ca8f7adea |
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 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 set nocp |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 filetype indent on |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 set nowrapscan |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 au! SwapExists * call HandleSwapExists() |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 func HandleSwapExists() |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 " 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
|
12 " editing them and that's OK. |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 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
|
14 let v:swapchoice = 'e' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 endfunc |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 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
|
19 let root = substitute(fname, '\.in', '', '') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 " 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
|
22 " newer. |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 let in_time = getftime(fname) |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 let out_time = getftime(root . '.out') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 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
|
26 call delete(root . '.fail') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 call delete(root . '.out') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 set sw& ts& filetype= |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 exe 'split ' . fname |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 let did_some = 0 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 let failed = 0 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 let end = 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 while 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 " 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
|
37 exe end |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 let start = search('\<START_INDENT\>') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 let end = search('\<END_INDENT\>') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 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
|
41 if did_some == 0 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 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
|
43 let failed = 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 break |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 else |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 let did_some = 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 " 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
|
50 let lnum = start |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 let pattern = '' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 let at = '' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 while 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 exe lnum + 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 let lnum_exe = search('\<INDENT_EXE\>') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 exe lnum + 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 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
|
58 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
|
59 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
|
60 let lnum = lnum_exe |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 let start = lnum |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 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
|
63 if pattern != '' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 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
|
65 let failed = 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 break |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 let text = getline(indent_at) |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 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
|
70 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
|
71 let lnum = indent_at |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 let start = lnum |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 else |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 break |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 endwhile |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 exe start + 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 if pattern == '' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 exe 'normal =' . (end - 1) . 'G' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 else |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 let lnum = search(pattern) |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 if lnum <= 0 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 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
|
85 let failed = 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 break |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 if at == 'AT' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 exe lnum |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 elseif at == 'NEXT' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 exe lnum + 1 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 else |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 exe lnum - 1 |
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 normal == |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 endwhile |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 if !failed |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 " 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
|
102 if getline(1, '$') != readfile(root . '.ok') |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 let failed = 1 |
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 endif |
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 exe 'write ' . root . '.fail' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 echoerr 'Test ' . fname . ' FAILED!' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 sleep 2 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 else |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 exe 'write ' . root . '.out' |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 quit! " close the indented file |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 endif |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 endfor |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 |
19b757c6c6a7
patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 qall! |