summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/testdir/README.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/syntax/testdir/README.txt')
-rw-r--r--runtime/syntax/testdir/README.txt45
1 files changed, 38 insertions, 7 deletions
diff --git a/runtime/syntax/testdir/README.txt b/runtime/syntax/testdir/README.txt
index 22b6084..9c12648 100644
--- a/runtime/syntax/testdir/README.txt
+++ b/runtime/syntax/testdir/README.txt
@@ -26,14 +26,43 @@ Creating a syntax plugin test
-----------------------------
Create a source file in the language you want to test in the "input"
-directory. Make sure to include some interesting constructs with complicated
-highlighting.
-
-Use the filetype name as the base and a file name extension matching the
-filetype. Let's use Java as an example. The file would then be
+directory. Use the filetype name as the base and a file name extension
+matching the filetype. Let's use Java as an example. The file would then be
"input/java.java".
+Make sure to include some interesting constructs with plenty of complicated
+highlighting. Optionally, pre-configure the testing environment by including
+setup commands at the top of the input file. The format for these lines is:
+
+ VIM_TEST_SETUP {command}
+
+where {command} is any valid Ex command, which extends to the end of the line.
+The first 20 lines of the input file are ALWAYS scanned for setup commands and
+these will be executed before the syntax highlighting is enabled. Typically,
+these lines would be included as comments so as not to introduce any syntax
+errors in the input file but this is not required.
+
+Continuing the Java example:
+
+ // VIM_TEST_SETUP let g:java_space_errors = 1
+ // VIM_TEST_SETUP let g:java_minlines = 5
+ class Test { }
+
+As an alternative, setup commands can be included in an external Vim script
+file in the "input/setup" directory. This script file must have the same base
+name as the input file.
+
+So, the equivalent example configuration using this method would be to create
+an "input/setup/java.vim" script file with the following lines:
+
+ let g:java_space_errors = 1
+ let g:java_minlines = 5
+
+Both inline setup commands and setup scripts may be used at the same time, the
+script file will be sourced before any VIM_TEST_SETUP commands are executed.
+
If there is no further setup required, you can now run the tests:
+
make test
The first time this will fail with an error for a missing screendump. The
@@ -69,8 +98,10 @@ are covered by the test. You can follow these steps:
pass, but if you fixed syntax highlighting that was already visible in the
input file, carefully check that the changes in the screendump are
intentional:
+
let fname = '{name}_99.dump'
call term_dumpdiff('failed/' .. fname, 'dumps/' .. fname)
+
Fix the syntax plugin until the result is good.
2. Edit the input file for your language to add the items you have improved.
(TODO: how to add another screendump?).
@@ -82,6 +113,7 @@ are covered by the test. You can follow these steps:
test" should succeed.
3. Prepare a pull request with the modified files:
- syntax plugin: syntax/{name}.vim
+ - Vim setup file: syntax/testdir/input/setup/{name}.vim (if any)
- test input file: syntax/testdir/input/{name}.{ext}
- test dump files: syntax/testdir/dumps/{name}_99.dump
@@ -91,7 +123,6 @@ test.
-TODO: run test for one specific filetype
-TODO: testing with various option values
+TODO: run test for one specific filetype
TODO: test syncing by jumping around