blob: 9392b8dc98c189377904015e0b35ef0d9758795a [file] [log] [blame]
Bram Moolenaar46acad72023-06-11 19:04:18 +01001# Portable Makefile for running syntax tests.
2
Christian Brabandt56824432024-02-28 21:24:25 +01003# To run the test manually:
4# ../../src/vim -u 'testdir/runtest.vim' --cmd 'breakadd func RunTest'
5
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +01006# Override this if needed, the default assumes Vim was built in the src dir.
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +01007#VIMPROG = vim
8VIMPROG = ../../src/vim
Bram Moolenaar46acad72023-06-11 19:04:18 +01009
10# "runtime" relative to "runtime/syntax/testdir"
11VIMRUNTIME = ../..
12
13# Uncomment this line to use valgrind for memory leaks and extra warnings.
14# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=45 --log-file=valgrind.$*
15
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010016# Trace ruler liveness on demand.
17# VIM_SYNTAX_TEST_LOG = `pwd`/testdir/failed/00-TRACE_LOG
18
19# ENVVARS = LC_ALL=C VIM_SYNTAX_TEST_LOG="$(VIM_SYNTAX_TEST_LOG)"
Bram Moolenaar46acad72023-06-11 19:04:18 +010020# ENVVARS = LC_ALL=C LANG=C LANGUAGE=C
Christian Brabandt627c9502024-02-10 13:02:17 +010021# Run the syntax tests with a C locale
22ENVVARS = LC_ALL=C
Bram Moolenaar46acad72023-06-11 19:04:18 +010023
K.Takatad5b952a2023-06-13 22:44:57 +010024RUN_VIMTEST = VIMRUNTIME=$(VIMRUNTIME) $(VALGRIND) $(ENVVARS) ../$(VIMPROG) -f $(GUI_FLAG)
Bram Moolenaar46acad72023-06-11 19:04:18 +010025
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010026# Uncomment this line for debugging
27# DEBUGLOG = --log testlog
28
Aliaksei Budavei6852e5c2025-03-07 19:12:45 +010029# All initial phony targets; these names may clash with file types.
30phonies = clean test testclean
31.PHONY: $(phonies)
32
Bram Moolenaar46acad72023-06-11 19:04:18 +010033# Run the tests that didn't run yet or failed previously.
34# If a test succeeds a testdir/done/{name} file will be written.
35# If a test fails a testdir/failed/{name}.dump file will be written.
Bram Moolenaar1aa5f1c2023-06-22 21:57:51 +010036# Progress and error messages can be found in "testdir/messages".
Yee Cheng Chin58818282025-02-11 20:16:11 +010037# Comment out the "> /dev/null" part to see the in-progress Vim behaviors.
Bram Moolenaar46acad72023-06-11 19:04:18 +010038test:
39 @# the "vimcmd" file is used by the screendump utils
K.Takatad5b952a2023-06-13 22:44:57 +010040 @echo "../$(VIMPROG)" > testdir/vimcmd
Bram Moolenaar46acad72023-06-11 19:04:18 +010041 @echo "$(RUN_VIMTEST)" >> testdir/vimcmd
Aliaksei Budavei7003a5d2025-03-01 16:28:20 +010042 @# Trace ruler liveness on demand.
43 @#mkdir -p testdir/failed
44 @#touch "$(VIM_SYNTAX_TEST_LOG)"
Eisuke Kawashima2e18fac2025-03-05 21:15:45 +010045 VIMRUNTIME=$(VIMRUNTIME) $(ENVVARS) $(VIMPROG) --clean --not-a-term $(DEBUGLOG) -u testdir/runtest.vim > /dev/null
Bram Moolenaar10c1dbc2023-06-23 19:37:19 +010046 @# FIXME: Temporarily show the whole file to find out what goes wrong
Dominique Pellé99c38492023-09-24 16:09:31 +020047 @#if [ -f testdir/messages ]; then tail -n 6 testdir/messages; fi
48 @if [ -f testdir/messages ]; then cat testdir/messages; fi
Bram Moolenaar46acad72023-06-11 19:04:18 +010049
Eisuke Kawashima2e18fac2025-03-05 21:15:45 +010050# add dependence on syntax files
51testdir/testdeps.mk:
Aliaksei Budavei6852e5c2025-03-07 19:12:45 +010052 ./testdir/tools/maketestdeps $(phonies) > $@
Eisuke Kawashima2e18fac2025-03-05 21:15:45 +010053
54-include testdir/testdeps.mk
Bram Moolenaar46acad72023-06-11 19:04:18 +010055
56clean testclean:
Eisuke Kawashima2e18fac2025-03-05 21:15:45 +010057 rm -f testdir/failed/* testdir/done/* testdir/vimcmd testdir/messages testdir/Xtestscript testdir/Xfilter testdir/testdeps.mk
Aliaksei Budaveiec022942024-10-06 16:57:33 +020058
Eisuke Kawashima2e18fac2025-03-05 21:15:45 +010059# Collect all input filenames and their file types.
Aliaksei Budaveiec022942024-10-06 16:57:33 +020060testnames != set +f; \
61awk 'BEGIN { \
Aliaksei Budavei6852e5c2025-03-07 19:12:45 +010062 for (i = 1; i < ARGC; i++) { \
63 split(ARGV[i], names, /\//); \
64 split(names[3], parts, /[._]/); \
65 types[parts[1]]; \
66 print names[3]; \
67 } \
68 delete types["vim9"]; \
69 split("$(phonies)", scratch); \
70 for (phony in scratch) \
71 phonies[scratch[phony]]; \
72 for (type in types) \
73 print type ((type in phonies) ? "_" : ""); \
Aliaksei Budaveiec022942024-10-06 16:57:33 +020074}' testdir/input/*.*
75
76.PHONY: self-testing $(testnames)
77
78$(testnames)::
79 @echo $@ >> testdir/Xfilter
80
81self-testing:: $(testnames)
82 @echo self-testing > testdir/Xfilter