runtime(syntax-tests): Clarify the naming scheme for test files · vim/vim@92d4e9b · GitHub
Skip to content

Commit 92d4e9b

Browse files
zzzyxwvutchrisbra
authored andcommitted
runtime(syntax-tests): Clarify the naming scheme for test files
Similar to "sh.vim", there are a handful of other filetypes whose names (assigned to "b:current_syntax") are different from the base names of their syntax plugins, e.g. "python2" and "elsa". Two scripts, "testdir/tools/maketestdeps" and "testdir/runtest.vim", currently assume that the base name of a syntax plugin can be derived from the name of a syntax test. Prescribe using the base name of the syntax plugin, instead of its filetype, for a test filename prefix so that existing files are listed in Make targets ("maketestdeps") and name correspondence is kept between the syntax plugin and optional test settings for it ("runtest.vim"). Add a CI check for name verification. closes: #21414 Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent b4cdb8a commit 92d4e9b

5 files changed

Lines changed: 33 additions & 16 deletions

File tree

‎.github/actions/build_vim_on_linux/action.yml‎

Lines changed: 6 additions & 6 deletions

‎.github/workflows/ci-linux.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
extra: [nogui]
4949
- features: tiny
5050
compiler: gcc
51-
extra: [nogui, syn_test_execs]
51+
extra: [nogui, syn_test_execs_naming]
5252
- features: tiny
5353
compiler: gcc
5454
extra: [nogui]

‎runtime/syntax/Makefile‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN_VIMTEST = VIMRUNTIME=$(VIMRUNTIME) $(VALGRIND) $(ENVVARS) ../$(VIMPROG) -f $
2727
# DEBUGLOG = --log testlog
2828

2929
# All initial phony targets; these names may clash with file types.
30-
phonies = clean executables test testclean
30+
phonies = clean executables misnomers test testclean
3131
.PHONY: $(phonies)
3232

3333
# Run the tests that didn't run yet or failed previously.
@@ -56,6 +56,15 @@ testdir/testdeps.mk:
5656
executables:
5757
@! find testdir/input -type f -perm /a+x -exec echo Executable syntax test found: \{\} \; | grep :
5858

59+
misnomers:
60+
@s=true; \
61+
for n in $(testnames); \
62+
do case "$$n" in *.* | vim9) ;; \
63+
*) test -f $${n%_}.vim || { echo No such file: syntax/$${n%_}.vim; s=false; } ;; \
64+
esac; \
65+
done; \
66+
$$s
67+
5968
clean testclean:
6069
rm -f testdir/failed/* testdir/done/* testdir/vimcmd testdir/messages testdir/Xtestscript testdir/Xfilter testdir/testdeps.mk
6170

‎runtime/syntax/testdir/README.txt‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ Creating a syntax plugin test
2626
-----------------------------
2727

2828
Create a source file in the language you want to test in the "input"
29-
directory. Use the filetype name as the base and a filename extension
30-
matching the filetype. Let's use Java as an example. The file would then be
31-
"input/java.java". As another example, consider Gitignore. Since there is no
32-
established filename extension for this filetype, use the filetype name for
33-
its base AND filename extension, "input/gitignore.gitignore", as the first
34-
step.
29+
directory. Copy the base name of the source file from the base name of the
30+
syntax plugin, and use a filename extension associated with this filetype.
31+
Let's use Java as an example. Copying the base name from "syntax/java.vim",
32+
the file would then be named "input/java.java". As another example, consider
33+
Gitignore. Since there is no established filename extension for this
34+
filetype, duplicate the base name of the syntax plugin "syntax/gitignore.vim"
35+
for both the base name of the source file AND its filename extension,
36+
"input/gitignore.gitignore", as the first step. When you prefer having
37+
multiple source files for the language, use the same base name prefix and
38+
another, arbitrary name for its suffix, delimiting words with an underscore
39+
character, e.g. "input/java_module_info.java" and "input/java_numbers.java".
3540

3641
Make sure to include some interesting constructs with plenty of complicated
3742
highlighting. Optionally, pre-configure the testing environment by including
@@ -74,8 +79,8 @@ If there is no further setup required, you can now run all tests:
7479

7580
make test
7681

77-
Or you can run the tests for a filetype only by passing its name as another
78-
target, e.g. "java", before "test":
82+
Or you can run the whole test suite for one language only by passing its name
83+
as another target, e.g. "java", before "test":
7984

8085
make java test
8186

‎runtime/syntax/testdir/runtest.vim‎

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)