annotate runtime/indent/testdir/README.txt @ 14970:19b757c6c6a7 v8.1.0496

patch 8.1.0496: no tests for indent files commit https://github.com/vim/vim/commit/c0fe4978f2311be9a0221d4c2369251c719b399a Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 25 16:53:19 2018 +0200 patch 8.1.0496: no tests for indent files Problem: No tests for indent files. Solution: Add a mechanism for running indent file tests. Add a first test for Vim indenting.
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Oct 2018 17:00:07 +0200
parents
children 2b30a2b4bde2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14970
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 TESTING INDENT SCRIPTS
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 We'll use FILETYPE for the filetype name here.
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
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 FORMAT OF THE FILETYPE.IN FILE
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 First of all, create a FILETYPE.in file. It should contain:
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 - A modeline setting the 'filetype' and any other option values.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 This must work like a comment for FILETYPE. E.g. for vim:
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 " vim: set ft=vim sw=4 :
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 - At least one block of lines to indent, prefixed with START_INDENT and
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 followed by END_INDENT. These lines must also look like a comment for your
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 FILETYPE. You would normally leave out all indent, so that the effect of
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 the indent command results in adding indent. Example:
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 " START_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 func Some()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 let x = 1
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 " END_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 - Optionally, a line with INDENT_EXE, followed by a Vim command. This will be
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 executed before indenting the lines. Example:
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 " START_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 " INDENT_EXE let g:vim_indent_cont = 6
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 let cmd =
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 \ 'some '
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 \ 'string'
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 " END_INDENT
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 Note that the command is not undone, you may need to reverse the effect for
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 the next block of lines.
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 - Alternatively to indenting all the lines between START_INDENT and
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 END_INDENT, use a INDENT_AT line, which specifies a pattern to find the line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 to indent. Example:
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 " START_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 " INDENT_AT this-line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 func Some()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let f = x " this-line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 endfunc
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 " END_INDENT
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 Alternatively you can use INDENT_NEXT to indent the line below the matching
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 pattern:
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 " START_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 " INDENT_NEXT next-line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 func Some()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 " next-line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 let f = x
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 endfunc
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 " END_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 Or use INDENT_PREV to indent the line above the matching pattern:
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 " START_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 " INDENT_PREV prev-line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 func Some()
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 let f = x
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 " prev-line
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 endfunc
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 " END_INDENT
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 It's best to keep the whole file valid for FILETYPE, so that syntax
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 highlighting works normally, and any indenting that depends on the syntax
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 highlighting also works.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 RUNNING THE TEST
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 Before running the test, create a FILETYPE.ok file. You can leave it empty at
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 first.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 Now run "make test". After Vim has done the indenting you will see a
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 FILETYPE.fail file. This contains the actual result of indenting, and it's
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 different from the FILETYPE.ok file.
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 Check the contents of the FILETYPE.fail file. If it is perfectly OK, then
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 rename it to overwrite the FILETYPE.ok file. If you now run "make test" again,
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 the test will pass and create a FILETYPE.out file, which is identical to the
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 FILETYPE.ok file.
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 If you try to run "make test" again you will notice that nothing happens,
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 because the FILETYPE.out file already exists. Delete it, or do "make clean",
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 so that the text runs again. If you edit the FILETYPE.in file, so that it's
19b757c6c6a7 patch 8.1.0496: no tests for indent files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 newer than the FILETYPE.out file, the test will also run.