Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 1 | # Portable Makefile for running syntax tests. |
| 2 | |
Christian Brabandt | 5682443 | 2024-02-28 21:24:25 +0100 | [diff] [blame] | 3 | # To run the test manually: |
| 4 | # ../../src/vim -u 'testdir/runtest.vim' --cmd 'breakadd func RunTest' |
| 5 | |
Aliaksei Budavei | 7003a5d | 2025-03-01 16:28:20 +0100 | [diff] [blame] | 6 | # Override this if needed, the default assumes Vim was built in the src dir. |
Bram Moolenaar | 1aa5f1c | 2023-06-22 21:57:51 +0100 | [diff] [blame] | 7 | #VIMPROG = vim |
| 8 | VIMPROG = ../../src/vim |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 9 | |
| 10 | # "runtime" relative to "runtime/syntax/testdir" |
| 11 | VIMRUNTIME = ../.. |
| 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 Budavei | 7003a5d | 2025-03-01 16:28:20 +0100 | [diff] [blame] | 16 | # 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 Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 20 | # ENVVARS = LC_ALL=C LANG=C LANGUAGE=C |
Christian Brabandt | 627c950 | 2024-02-10 13:02:17 +0100 | [diff] [blame] | 21 | # Run the syntax tests with a C locale |
| 22 | ENVVARS = LC_ALL=C |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 23 | |
K.Takata | d5b952a | 2023-06-13 22:44:57 +0100 | [diff] [blame] | 24 | RUN_VIMTEST = VIMRUNTIME=$(VIMRUNTIME) $(VALGRIND) $(ENVVARS) ../$(VIMPROG) -f $(GUI_FLAG) |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 25 | |
Bram Moolenaar | 1aa5f1c | 2023-06-22 21:57:51 +0100 | [diff] [blame] | 26 | # Uncomment this line for debugging |
| 27 | # DEBUGLOG = --log testlog |
| 28 | |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 29 | # Run the tests that didn't run yet or failed previously. |
| 30 | # If a test succeeds a testdir/done/{name} file will be written. |
| 31 | # If a test fails a testdir/failed/{name}.dump file will be written. |
Bram Moolenaar | 1aa5f1c | 2023-06-22 21:57:51 +0100 | [diff] [blame] | 32 | # Progress and error messages can be found in "testdir/messages". |
Yee Cheng Chin | 5881828 | 2025-02-11 20:16:11 +0100 | [diff] [blame] | 33 | # Comment out the "> /dev/null" part to see the in-progress Vim behaviors. |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 34 | test: |
| 35 | @# the "vimcmd" file is used by the screendump utils |
K.Takata | d5b952a | 2023-06-13 22:44:57 +0100 | [diff] [blame] | 36 | @echo "../$(VIMPROG)" > testdir/vimcmd |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 37 | @echo "$(RUN_VIMTEST)" >> testdir/vimcmd |
Aliaksei Budavei | 7003a5d | 2025-03-01 16:28:20 +0100 | [diff] [blame] | 38 | @# Trace ruler liveness on demand. |
| 39 | @#mkdir -p testdir/failed |
| 40 | @#touch "$(VIM_SYNTAX_TEST_LOG)" |
Yee Cheng Chin | 5881828 | 2025-02-11 20:16:11 +0100 | [diff] [blame] | 41 | VIMRUNTIME=$(VIMRUNTIME) $(ENVVARS) $(VIMPROG) --clean --not-a-term $(DEBUGLOG) -u testdir/runtest.vim > /dev/null |
Aliaksei Budavei | ec02294 | 2024-10-06 16:57:33 +0200 | [diff] [blame] | 42 | @rm -f testdir/Xfilter |
Bram Moolenaar | 10c1dbc | 2023-06-23 19:37:19 +0100 | [diff] [blame] | 43 | @# FIXME: Temporarily show the whole file to find out what goes wrong |
Dominique Pellé | 99c3849 | 2023-09-24 16:09:31 +0200 | [diff] [blame] | 44 | @#if [ -f testdir/messages ]; then tail -n 6 testdir/messages; fi |
| 45 | @if [ -f testdir/messages ]; then cat testdir/messages; fi |
Bram Moolenaar | 46acad7 | 2023-06-11 19:04:18 +0100 | [diff] [blame] | 46 | |
| 47 | |
| 48 | clean testclean: |
Aliaksei Budavei | ec02294 | 2024-10-06 16:57:33 +0200 | [diff] [blame] | 49 | rm -f testdir/failed/* testdir/done/* testdir/vimcmd testdir/messages testdir/Xtestscript testdir/Xfilter |
| 50 | |
| 51 | # All initial phony targets; these names may clash with file extensions. |
| 52 | phonies = clean test testclean |
| 53 | |
| 54 | # Collect all input filenames and their file extensions. |
| 55 | testnames != set +f; \ |
| 56 | awk 'BEGIN { \ |
| 57 | for (i = 1; i < ARGC; i++) { \ |
| 58 | split(ARGV[i], names, /\//); \ |
| 59 | split(names[3], parts, /\./); \ |
| 60 | exts[parts[2]]; \ |
| 61 | print names[3]; \ |
| 62 | } \ |
| 63 | split("$(phonies)", scratch); \ |
| 64 | for (phony in scratch) \ |
| 65 | phonies[scratch[phony]]; \ |
| 66 | for (ext in exts) \ |
| 67 | print ext ((ext in phonies) ? "_" : ""); \ |
| 68 | }' testdir/input/*.* |
| 69 | |
| 70 | .PHONY: self-testing $(testnames) |
| 71 | |
| 72 | $(testnames):: |
| 73 | @echo $@ >> testdir/Xfilter |
| 74 | |
| 75 | self-testing:: $(testnames) |
| 76 | @echo self-testing > testdir/Xfilter |