runtime(syntax-tests): simplify code and allow filetype options

Commit: 
https://github.com/vim/vim/commit/56824430c02bd557cc41737eacd3edb2453ed4f9
Author: Christian Brabandt <[email protected]>
Date:   Wed Feb 28 21:24:25 2024 +0100

    runtime(syntax-tests): simplify code and allow filetype options
    
    The whole testdir/runtest.vim is a bit of a mess. So this is an attempt
    to improving the current state. First of all, let's move most of the
    code into a single RunTest() function so that it's easier to run this
    manually.
    
    Then, let's add the possibility to customize filetype specific tests by
    applying filetype specific options. We will make use of it in the next
    commit, where the provided java file uses tabs, which cause line
    wrapping which will then cause the scrolling to miss some lines when
    redrawing (see #14105)
    
    related: #14105
    
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/Makefile b/runtime/syntax/Makefile
index 945308fd7..bc6de0bc2 100644
--- a/runtime/syntax/Makefile
+++ b/runtime/syntax/Makefile
@@ -1,5 +1,8 @@
 # Portable Makefile for running syntax tests.
 
+# To run the test manually:
+# ../../src/vim -u 'testdir/runtest.vim' --cmd 'breakadd func RunTest'
+
 # Override this if needed, the default assumes Vim was build in the src dir.
 #VIMPROG = vim
 VIMPROG = ../../src/vim
diff --git a/runtime/syntax/testdir/dumps/c_00.dump 
b/runtime/syntax/testdir/dumps/c_00.dump
index d32cbd22f..46c42f1d6 100644
--- a/runtime/syntax/testdir/dumps/c_00.dump
+++ b/runtime/syntax/testdir/dumps/c_00.dump
@@ -17,4 +17,4 @@
 |#+0#e000e06&| |i|n|c|l|u|d|e| |<+0#e000002&|l|i|m|i|t|s|.|h|>| +0#0000000&@54
 |#+0#e000e06&|e|n|d|i|f| +0#0000000&@68
 @75
-|"|i|n|p|u|t|/|c|.|c|"| |1|2@1|L|,| |3|1|7|4|B| @33|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/modula2_iso_00.dump 
b/runtime/syntax/testdir/dumps/modula2_iso_00.dump
index 797376fc1..0c24cb860 100644
--- a/runtime/syntax/testdir/dumps/modula2_iso_00.dump
+++ b/runtime/syntax/testdir/dumps/modula2_iso_00.dump
@@ -17,4 +17,4 @@
 |(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |c|o|n|s|t|a|n|t|s| |*|)| +0#0000000&@48
 |F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| 
+0#0000000&|T+0#e000002&|R|U|E| 
+0#0000000&|I+0#e000002&|N|T|E|R@1|U|P|T|I|B|L|E| 
+0#0000000&|U+0#e000002&|N|I|N|T|E|R@1|U|P|T|I|B|L|E| +0#0000000&@30
 @75
-|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|i|s|o|.|d|e|f|"| |1@1|4|L|,| |2|3|1|8|B| 
@21|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/modula2_pim_00.dump 
b/runtime/syntax/testdir/dumps/modula2_pim_00.dump
index 5e85b7aa8..36aa0deec 100644
--- a/runtime/syntax/testdir/dumps/modula2_pim_00.dump
+++ b/runtime/syntax/testdir/dumps/modula2_pim_00.dump
@@ -17,4 +17,4 @@
 |F+0#e000002&|A|L|S|E| +0#0000000&|N+0#e000002&|I|L| 
+0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60
 @75
 |(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52
-|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|p|i|m|.|d|e|f|"| |1@2|L|,| |2|1|9|7|B| 
@21|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/modula2_r10_00.dump 
b/runtime/syntax/testdir/dumps/modula2_r10_00.dump
index ab4167abf..a2e475ef9 100644
--- a/runtime/syntax/testdir/dumps/modula2_r10_00.dump
+++ b/runtime/syntax/testdir/dumps/modula2_r10_00.dump
@@ -17,4 +17,4 @@
 |N+0#e000002&|I|L| +0#0000000&|F+0#e000002&|A|L|S|E| 
+0#0000000&|T+0#e000002&|R|U|E| +0#0000000&@60
 @75
 |(+0#0000e05&|*| |p|r|e|d|e|f|i|n|e|d| |t|y|p|e|s| |*|)| +0#0000000&@52
-|"|i|n|p|u|t|/|m|o|d|u|l|a|2|_|r|1|0|.|d|e|f|"| |1|4|6|L|,| |2|9|8|3|B| 
@21|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_abbreviate_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_abbreviate_00.dump
index 68055d8a6..5224a4f6e 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_abbreviate_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_abbreviate_00.dump
@@ -17,4 +17,4 @@
 |i+0#af5f00255&|a|b@1|r|e|v| +0#0000000&|<+0#e000e06&|e|x|p|r|>| 
+0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| +0#0000000&|i|f|o@1| |c|f|o@1|b|a|r| @38
 @75
 |u+0#af5f00255&|n|a|b@1|r|e|v| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| 
+0#0000000&|f|o@1| @53
-|"|i|n|p|u|t|/|v|i|m|_|e|x|_|a|b@1|r|e|v|i|a|t|e|.|v|i|m|"| |2|5|L|,| 
|5@1|8|B| @17|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_behave_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_behave_00.dump
index cd88b7537..b3c57de6f 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_behave_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_behave_00.dump
@@ -17,4 +17,4 @@
 |~| @73
 |~| @73
 |~| @73
-|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|e|x|_|b|e|h|a|v|e|.|v|i|m|"| |7|L|,| |7@1|B| 
@23|1|,|1| @10|A|l@1| 
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_behave_99.dump 
b/runtime/syntax/testdir/dumps/vim_ex_behave_99.dump
index a0a0e188c..c3fefebd3 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_behave_99.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_behave_99.dump
@@ -17,4 +17,4 @@
 |~| @73
 |~| @73
 |~| @73
-|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|e|x|_|b|e|h|a|v|e|.|v|i|m|"| |7|L|,| |7@1|B| 
@23|7|,|1| @10|A|l@1| 
+| +0#0000000&@56|7|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_commands_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_commands_00.dump
index f3e48c0db..863ae382c 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_commands_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_commands_00.dump
@@ -17,4 +17,4 @@
 |:|3+0#af5f00255&|m|a|t|c|h| +0#0000000&@67
 |:+0#af5f00255&|a|p@1|e|n|d| +0#0000000&@67
 | +0#e000002&@3|t|e|x|t| +0#0000000&@66
-|"|i|n|p|u|t|/|v|i|m|_|e|x|_|c|o|m@1|a|n|d|s|.|v|i|m|"| |1@1|9|5|L|,| 
|1|7|3|0|1|B| @15|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_echo_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_echo_00.dump
index 506c9e2d8..a626c7b24 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_echo_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_echo_00.dump
@@ -17,4 +17,4 @@
 @75
 |"+0#0000e05&| |:|e|c|h|o| |w|i|t|h|o|u|t| |{|e|x|p|r|}| +0#0000000&@52
 |e+0#af5f00255&|c|h|o||+0#0000000&| |e+0#af5f00255&|c|h|o| 
+0#0000000&|"+0#e000002&|F|o@1|"| +0#0000000&@58
-|"|i|n|p|u|t|/|v|i|m|_|e|x|_|e|c|h|o|.|v|i|m|"| |2|0|L|,| |3|6|2|B| @23|1|,|1| 
@10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_map_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_map_00.dump
index 032eeb416..371c1ce66 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_map_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_map_00.dump
@@ -17,4 +17,4 @@
 |o+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| 
+0#0000000&@56
 |i+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| 
+0#0000000&@56
 |l+0#af5f00255&|m|a|p|c|l|e|a|r| +0#0000000&|<+0#e000e06&|b|u|f@1|e|r|>| 
+0#0000000&@56
-|"|i|n|p|u|t|/|v|i|m|_|e|x|_|m|a|p|.|v|i|m|"| |2|1|L|,| |3|1|6|B| @24|1|,|1| 
@10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_ex_substitute_00.dump 
b/runtime/syntax/testdir/dumps/vim_ex_substitute_00.dump
index 31094c952..aea97ed4b 100644
--- a/runtime/syntax/testdir/dumps/vim_ex_substitute_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_substitute_00.dump
@@ -17,4 +17,4 @@
 
|:|s+0#af5f00255&|m|a|g|i|c|/+0#e000e06&|f+0#0000000&|o@1|/+0#e000e06&|b+0#0000000&|a|r|/+0#e000e06&|c|e|g|i|I|n|p|#|l|r|
 +0#0000000&@48
 @75
 |c+0#af5f00255&|a|l@1| +0#0000000&|F|o@1|(+0#e000e06&|)| +0#0000000&||| 
|s+0#af5f00255&|u|b|s|t|i|t|u|t|e|/+0#e000e06&|f+0#0000000&|o@1|/+0#e000e06&|b+0#0000000&|a|r|/+0#e000e06&|&|
 +0#0000000&@41
-|"|i|n|p|u|t|/|v|i|m|_|e|x|_|s|u|b|s|t|i|t|u|t|e|.|v|i|m|"| |8|6|L|,| 
|1|5|1|0|B| @16|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_expr_00.dump 
b/runtime/syntax/testdir/dumps/vim_expr_00.dump
index dd1cfa71d..899b73cd9 100644
--- a/runtime/syntax/testdir/dumps/vim_expr_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_expr_00.dump
@@ -17,4 +17,4 @@
 |e+0#af5f00255&|c|h|o| +0#0000000&|$+0#e000002&|'|\|3|1|6| |\|3|1| |\|3| 
|\|x|1|f| |\|x|f| |\|X|1|F| |\|X|F| |\|u|0|2|a|4| |\|U|0@4|2|a|4| |\|b| |\|e| 
|\|f| |\|n| |\|r| |\|t| |\@1
 | |\|"| |\|<|C|-|W|>|'| +0#0000000&@63
 |e+0#af5f00255&|c|h|o| 
+0#0000000&|$+0#e000002&|"|\+0#e000e06&|3|1|6|0+0#e000002&| |-| 
|\+0#e000e06&|x|1|f|0+0#e000002&| |-| |\+0#e000e06&|X|1|F|0+0#e000002&| |-| 
|\+0#e000e06&|u|0|2|a|4|0+0#e000002&| |-| 
|\+0#e000e06&|U|0@4|2|a|4|0+0#e000002&|"| +0#0000000&@21
-|"|i|n|p|u|t|/|v|i|m|_|e|x|p|r|.|v|i|m|"| |3|1|L|,| |1@1|6|2|B| @25|1|,|1| 
@10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_key_notation_00.dump 
b/runtime/syntax/testdir/dumps/vim_key_notation_00.dump
index 8b77cf347..ed58e2fde 100644
--- a/runtime/syntax/testdir/dumps/vim_key_notation_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_key_notation_00.dump
@@ -17,4 +17,4 @@
 |<+0#e000e06&|x|C|S|I|>| +0#0000000&@68
 |<+0#e000e06&|B|a|r|>| +0#0000000&@69
 |<+0#e000e06&|B|s|l|a|s|h|>| +0#0000000&@66
-|"|i|n|p|u|t|/|v|i|m|_|k|e|y|_|n|o|t|a|t|i|o|n|.|v|i|m|"| |1|6|3|L|,| 
|1|3|4|6|B| @16|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_keymap_00.dump 
b/runtime/syntax/testdir/dumps/vim_keymap_00.dump
index 974c5ad31..2c43e3dad 100644
--- a/runtime/syntax/testdir/dumps/vim_keymap_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_keymap_00.dump
@@ -17,4 +17,4 @@
 |s+0#af5f00255&|c|r|i|p|t|e|n|c|o|d|i|n|g| 
+0#0000000&|u|t|f|-+0#af5f00255&|8+0#e000002&| +0#0000000&@54
 @75
 |@+0#4040ff13&@2| @71
-|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|k|e|y|m|a|p|.|v|i|m|"| |2|6|L|,| |3|9@1|2|B| 
@23|1|,|1| @10|T|o|p| 
+| +0#0000000&@56|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_line_continuation_00.dump 
b/runtime/syntax/testdir/dumps/vim_line_continuation_00.dump
index 7733c0b1a..3bc4ebaa5 100644
--- a/runtime/syntax/testdir/dumps/vim_line_continuation_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_line_continuation_00.dump
@@ -17,4 +17,4 @@
 @8|\+0#e000e06&| +0#0000000&|b+0#af5f00255&| +0#0000000&|=+0#af5f00255&| 
+0#0000000&|{+0#e000e06&|a+0#00e0e07&|:|b|}+0#e000e06&|,+0#0000000&| @54
 | +0#0000e05&@7|"|\| |p|r|i|n|t| |c| +0#0000000&@56
 @8|\+0#e000e06&| +0#0000000&|c+0#af5f00255&| +0#0000000&|=+0#af5f00255&| 
+0#0000000&|{+0#e000e06&|a+0#00e0e07&|:|c|}+0#e000e06&| +0#0000000&@55
-|"|i|n|p|u|t|/|v|i|m|_|l|i|n|e|_|c|o|n|t|i|n|u|a|t|i|o|n|.|v|i|m|"| |4|9|L|,| 
|6|2|6|B| @13|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_new_00.dump 
b/runtime/syntax/testdir/dumps/vim_new_00.dump
index 6306faefa..2ff76f4ad 100644
--- a/runtime/syntax/testdir/dumps/vim_new_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_new_00.dump
@@ -17,4 +17,4 @@
 |q+0#af5f00255&|u|i|t| +0#0000000&@70
 |~+0#4040ff13&| @73
 |~| @73
-|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|n|e|w|.|v|i|m|"| |1|7|L|,| |2|0|5|B| 
@27|1|,|1| @10|A|l@1| 
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_new_99.dump 
b/runtime/syntax/testdir/dumps/vim_new_99.dump
index 50a54f280..a9fe50fad 100644
--- a/runtime/syntax/testdir/dumps/vim_new_99.dump
+++ b/runtime/syntax/testdir/dumps/vim_new_99.dump
@@ -17,4 +17,4 @@
 >q+0#af5f00255&|u|i|t| +0#0000000&@70
 |~+0#4040ff13&| @73
 |~| @73
-|"+0#0000000&|i|n|p|u|t|/|v|i|m|_|n|e|w|.|v|i|m|"| |1|7|L|,| |2|0|5|B| 
@27|1|7|,|1| @9|A|l@1| 
+| +0#0000000&@56|1|7|,|1| @9|A|l@1| 
diff --git a/runtime/syntax/testdir/dumps/vim_syntax_00.dump 
b/runtime/syntax/testdir/dumps/vim_syntax_00.dump
index 21dcc8893..916f96dc4 100644
--- a/runtime/syntax/testdir/dumps/vim_syntax_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_syntax_00.dump
@@ -17,4 +17,4 @@
 @6|"+0#0000e05&|\| |c|o|n|t|a|i|n|e|d| |o|p|t|i|o|n| +0#0000000&@49
 @6|\+0#e000e06&| +0#0000000&|c+0#e000e06&|o|n|t|a|i|n|e|d| +0#0000000&@57
 @6|"+0#0000e05&|\| |c|o|n|t|a|i|n|e|d|i|n| |o|p|t|i|o|n| +0#0000000&@47
-|"|i|n|p|u|t|/|v|i|m|_|s|y|n|t|a|x|.|v|i|m|"| |1|6|4|L|,| |3|7|2|9|B| 
@22|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/vim_variables_00.dump 
b/runtime/syntax/testdir/dumps/vim_variables_00.dump
index 979411340..da77064af 100644
--- a/runtime/syntax/testdir/dumps/vim_variables_00.dump
+++ b/runtime/syntax/testdir/dumps/vim_variables_00.dump
@@ -17,4 +17,4 @@
 |l+0#af5f00255&|e|t| +0#0000000&|f+0#00e0e07&|o@1| 
+0#0000000&|/+0#af5f00255&|=| +0#0000000&|e|x|p|r| @59
 |l+0#af5f00255&|e|t| +0#0000000&|f+0#00e0e07&|o@1| 
+0#0000000&|%+0#af5f00255&|=| +0#0000000&|e|x|p|r| @59
 |l+0#af5f00255&|e|t| +0#0000000&|f+0#00e0e07&|o@1| 
+0#0000000&|.+0#af5f00255&|=| +0#0000000&|e|x|p|r| @59
-|"|i|n|p|u|t|/|v|i|m|_|v|a|r|i|a|b|l|e|s|.|v|i|m|"| |1|3|8|L|,| |1|5@1|4|B| 
@19|1|,|1| @10|T|o|p| 
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/runtest.vim 
b/runtime/syntax/testdir/runtest.vim
index d2ce3d19f..a2cdef372 100644
--- a/runtime/syntax/testdir/runtest.vim
+++ b/runtime/syntax/testdir/runtest.vim
@@ -85,164 +85,180 @@ func HandleSwapExists()
   endif
 endfunc
 
-let ok_count = 0
-let failed_tests = []
-let skipped_count = 0
-let MAX_FAILED_COUNT = 5
-for fname in glob('input/*.*', 1, 1)
-  if fname =~ '\~$'
-    " backup file, skip
-    continue
-  endif
+func RunTest()
+  let ok_count = 0
+  let failed_tests = []
+  let skipped_count = 0
+  let MAX_FAILED_COUNT = 5
+  for fname in glob('input/*.*', 1, 1)
+    if fname =~ '\~$'
+      " backup file, skip
+      continue
+    endif
+
+    let linecount = readfile(fname)->len()
+    let root = fnamemodify(fname, ':t:r')
+    let filetype = substitute(root, '\([^_.]*\)[_.].*', ' ', '')
+    let failed_root = 'failed/' .. root
+
+    " Execute the test if the "done" file does not exist or when the input file
+    " is newer.
+    let in_time = getftime(fname)
+    let out_time = getftime('done/' .. root)
+    if out_time < 0 || in_time > out_time
+      call ch_log('running tests for: ' .. fname)
+
+      for dumpname in glob(failed_root .. '_\d*\.dump', 1, 1)
+       call delete(dumpname)
+      endfor
+      call delete('done/' .. root)
 
-  let linecount = readfile(fname)->len()
-  let root = fnamemodify(fname, ':t:r')
-  let filetype = substitute(root, '\([^_.]*\)[_.].*', ' ', '')
-  let failed_root = 'failed/' .. root
-
-  " Execute the test if the "done" file does not exist or when the input file
-  " is newer.
-  let in_time = getftime(fname)
-  let out_time = getftime('done/' .. root)
-  if out_time < 0 || in_time > out_time
-    call ch_log('running tests for: ' .. fname)
-
-    for dumpname in glob(failed_root .. '_\d*\.dump', 1, 1)
-      call delete(dumpname)
-    endfor
-    call delete('done/' .. root)
-
-    let lines =<< trim END
-      syntax on
-
-      " extra info for shell variables
-      func ShellInfo()
-       let msg = ''
-       for [key, val] in items(b:)
-         if key =~ '^is_'
-           let msg ..= key .. ': ' .. val .. ', '
+      let lines =<< trim END
+       syntax on
+
+       " extra info for shell variables
+       func ShellInfo()
+         let msg = ''
+         for [key, val] in items(b:)
+           if key =~ '^is_'
+             let msg ..= key .. ': ' .. val .. ', '
+           endif
+         endfor
+         if msg != ''
+           echomsg msg
          endif
-       endfor
-       if msg != ''
-         echomsg msg
-       endif
-      endfunc
-
-      au! SwapExists * call HandleSwapExists()
-      func HandleSwapExists()
-       " Ignore finding a swap file for the test input, the user might be
-       " editing it and that's OK.
-       if expand('<afile>') =~ 'input[/\].*\..*'
-         let v:swapchoice = 'e'
-       endif
-      endfunc
-    END
-    call writefile(lines, 'Xtestscript')
+       endfunc
+
+       au! SwapExists * call HandleSwapExists()
+       func HandleSwapExists()
+         " Ignore finding a swap file for the test input, the user might be
+         " editing it and that's OK.
+         if expand('<afile>') =~ 'input[/\].*\..*'
+           let v:swapchoice = 'e'
+         endif
+       endfunc
+
+       func LoadFiletype(type)
+         for file in glob("ftplugin/" .. a:type .. "*.vim", 1, 1)
+           exe "source " .. file
+         endfor
+         redraw!
+       endfunc
+
+      END
+      call writefile(lines, 'Xtestscript')
+
+      " close all but the last window
+      while winnr('$') > 1
+       close
+      endwhile
+
+      " Redraw to make sure that messages are cleared and there is enough space
+      " for the terminal window.
+      redraw
+
+      let buf = RunVimInTerminal('-S Xtestscript', {})
+      " edit the file only after catching the SwapExists event
+      call term_sendkeys(buf, ":edit " .. fname .. "\<CR>")
+      " load filetype specific settings
+      call term_sendkeys(buf, ":call LoadFiletype('" .. filetype .. "')\<CR>")
+
+      if filetype == 'sh'
+       call term_sendkeys(buf, ":call ShellInfo()\<CR>")
+      endif
 
-    " close all but the last window
-    while winnr('$') > 1
-      close
-    endwhile
+      " Screendump at the start of the file: failed/root_00.dump
+      let root_00 = root .. '_00'
+      call ch_log('First screendump for ' .. fname .. ': failed/' .. root_00 
.. '.dump')
+      let fail = VerifyScreenDump(buf, root_00, {})
 
-    " Redraw to make sure that messages are cleared and there is enough space
-    " for the terminal window.
-    redraw
+      " clear the shell info if there are not enough lines to cause a scroll
+      if filetype == 'sh' && linecount <= 19
+       call term_sendkeys(buf, ":redraw\<CR>")
+      endif
 
-    let buf = RunVimInTerminal('-S Xtestscript', {})
-    " edit the file only after catching the SwapExists event
-    call term_sendkeys(buf, ":edit " .. fname .. "\<CR>")
+      " Make a Screendump every 18 lines of the file: failed/root_NN.dump
+      let topline = 1
+      let nr = 1
+      while linecount - topline > 20
+       let topline += 18
+       call term_sendkeys(buf, printf("%dGzt", topline))
+       let root_next = root .. printf('_%02d', nr)
+       call ch_log('Next screendump for ' .. fname .. ': failed/' .. root_next 
.. '.dump')
+       let fail += VerifyScreenDump(buf, root_next, {})
+       let nr += 1
+      endwhile
+
+      " Screendump at the end of the file: failed/root_99.dump
+      call term_sendkeys(buf, 'Gzb')
+      let root_last = root .. '_99'
+      call ch_log('Last screendump for ' .. fname .. ': failed/' .. root_last 
.. '.dump')
+      let fail += VerifyScreenDump(buf, root_last, {})
+
+      call StopVimInTerminal(buf)
+      call delete('Xtestscript')
+
+      " redraw here to avoid the following messages to get mixed up with screen
+      " output.
+      redraw
+
+      " Add any assert errors to s:messages.
+      if len(v:errors) > 0
+       call extend(s:messages, v:errors)
+       " Echo the errors here, in case the script aborts or the "messages" file
+       " is not displayed later.
+       echomsg v:errors
+       let v:errors = []
+       let fail += 1
+      endif
 
-    if filetype == 'sh'
-      call term_sendkeys(buf, ":call ShellInfo()\<CR>")
-    endif
+      if fail == 0
+       call Message("Test " .. root .. " OK")
 
-    " Screendump at the start of the file: failed/root_00.dump
-    let root_00 = root .. '_00'
-    call ch_log('First screendump for ' .. fname .. ': failed/' .. root_00 .. 
'.dump')
-    let fail = VerifyScreenDump(buf, root_00, {})
+       call writefile(['OK'], 'done/' .. root)
 
-    " clear the shell info if there are not enough lines to cause a scroll
-    if filetype == 'sh' && linecount <= 19
-      call term_sendkeys(buf, ":redraw\<CR>")
-    endif
+       let ok_count += 1
+      else
+       call Message("Test " .. root .. " FAILED")
 
-    " Make a Screendump every 18 lines of the file: failed/root_NN.dump
-    let topline = 1
-    let nr = 1
-    while linecount - topline > 20
-      let topline += 18
-      call term_sendkeys(buf, printf("%dGzt", topline))
-      let root_next = root .. printf('_%02d', nr)
-      call ch_log('Next screendump for ' .. fname .. ': failed/' .. root_next 
.. '.dump')
-      let fail += VerifyScreenDump(buf, root_next, {})
-      let nr += 1
-    endwhile
-
-    " Screendump at the end of the file: failed/root_99.dump
-    call term_sendkeys(buf, 'Gzb')
-    let root_last = root .. '_99'
-    call ch_log('Last screendump for ' .. fname .. ': failed/' .. root_last .. 
'.dump')
-    let fail += VerifyScreenDump(buf, root_last, {})
-
-    call StopVimInTerminal(buf)
-    call delete('Xtestscript')
-
-    " redraw here to avoid the following messages to get mixed up with screen
-    " output.
-    redraw
-
-    " Add any assert errors to s:messages.
-    if len(v:errors) > 0
-      call extend(s:messages, v:errors)
-      " Echo the errors here, in case the script aborts or the "messages" file
-      " is not displayed later.
-      echomsg v:errors
-      let v:errors = []
-      let fail += 1
-    endif
+       call delete('done/' .. root)
 
-    if fail == 0
-      call Message("Test " .. root .. " OK")
-
-      call writefile(['OK'], 'done/' .. root)
-
-      let ok_count += 1
+       eval failed_tests->add(root)
+       if len(failed_tests) > MAX_FAILED_COUNT
+         call Message('')
+         call Message('Too many errors, aborting')
+       endif
+      endif
     else
-      call Message("Test " .. root .. " FAILED")
+      call Message("Test " .. root .. " skipped")
+      let skipped_count += 1
+    endif
 
-      call delete('done/' .. root)
+    " Append messages to the file "testdir/messages"
+    call AppendMessages('Input file ' .. fname .. ':')
 
-      eval failed_tests->add(root)
-      if len(failed_tests) > MAX_FAILED_COUNT
-       call Message('')
-       call Message('Too many errors, aborting')
-      endif
+    if len(failed_tests) > MAX_FAILED_COUNT
+      break
     endif
-  else
-    call Message("Test " .. root .. " skipped")
-    let skipped_count += 1
-  endif
+  endfor
 
-  " Append messages to the file "testdir/messages"
-  call AppendMessages('Input file ' .. fname .. ':')
+  call Message(s:test_run_message)
+  call Message('OK: ' .. ok_count)
+  call Message('FAILED: ' .. len(failed_tests) .. ': ' .. string(failed_tests))
+  call Message('skipped: ' .. skipped_count)
+  call AppendMessages('== SUMMARY ==')
 
-  if len(failed_tests) > MAX_FAILED_COUNT
-    break
+  if len(failed_tests) > 0
+    " have make report an error
+    cquit
   endif
-endfor
-
-call Message(s:test_run_message)
-call Message('OK: ' .. ok_count)
-call Message('FAILED: ' .. len(failed_tests) .. ': ' .. string(failed_tests))
-call Message('skipped: ' .. skipped_count)
-call AppendMessages('== SUMMARY ==')
+endfunc
 
-if len(failed_tests) > 0
-  " have make report an error
-  cquit
-endif
+call RunTest()
 
 " Matching "if 1" at the start.
 endif
 
 qall!
+
+" vim:ts=8

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rfQnc-007KTa-Sl%40256bit.org.

Raspunde prin e-mail lui