Bram Moolenaar | 6839272 | 2010-07-30 22:04:17 +0200 | [diff] [blame] | 1 | # |
| 2 | # Makefile to run all tests for Vim, on Dos-like machines |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 3 | # with sh.exe or zsh.exe in the path or not. |
| 4 | # |
| 5 | # Author: Bill McCarthy |
| 6 | # |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 7 | # Requires a set of Unix tools: echo, diff, etc. |
| 8 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 9 | # Don't use unix-like shell. |
| 10 | SHELL = cmd.exe |
| 11 | |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 12 | DEL = del |
Bram Moolenaar | acf92d2 | 2016-01-02 16:00:20 +0100 | [diff] [blame] | 13 | DELDIR = rd /s /q |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 14 | MV = move /y |
| 15 | CP = copy /y |
Bram Moolenaar | fda3729 | 2014-11-05 14:27:36 +0100 | [diff] [blame] | 16 | CAT = type |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 17 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 18 | VIMPROG = ..\\vim |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 19 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 20 | default: nongui |
Bram Moolenaar | 40bbcee | 2015-12-28 22:24:41 +0100 | [diff] [blame] | 21 | |
Bram Moolenaar | 7b6156f | 2015-12-28 16:01:26 +0100 | [diff] [blame] | 22 | include Make_all.mak |
| 23 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 24 | # Explicit dependencies. |
Milly | 6eca04e | 2024-10-21 22:20:51 +0200 | [diff] [blame] | 25 | test_options_all.res: opt_test.vim |
Bram Moolenaar | fda3729 | 2014-11-05 14:27:36 +0100 | [diff] [blame] | 26 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 27 | TEST_OUTFILES = $(SCRIPTS_TINY_OUT) |
| 28 | DOSTMP = dostmp |
| 29 | # Keep $(DOSTMP)/*.in |
| 30 | .PRECIOUS: $(patsubst %.out, $(DOSTMP)/%.in, $(TEST_OUTFILES)) |
Bram Moolenaar | a608243 | 2015-12-28 16:26:45 +0100 | [diff] [blame] | 31 | |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 32 | .SUFFIXES: .in .out .res .vim |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 33 | |
Bram Moolenaar | 2d12c25 | 2022-06-13 21:42:45 +0100 | [diff] [blame] | 34 | # Add --gui-dialog-file to avoid getting stuck in a dialog. |
| 35 | COMMON_ARGS = $(NO_INITS) --gui-dialog-file guidialog |
| 36 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 37 | nongui: nolog tinytests newtests report |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 38 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 39 | gui: nolog tinytests newtests report |
| 40 | |
| 41 | tiny: nolog tinytests report |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 42 | |
Bram Moolenaar | fda3729 | 2014-11-05 14:27:36 +0100 | [diff] [blame] | 43 | benchmark: $(SCRIPTS_BENCH) |
| 44 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 45 | report: |
| 46 | @rem without the +eval feature test_result.log is a copy of test.log |
| 47 | @if exist test.log ( copy /y test.log test_result.log > nul ) \ |
| 48 | else ( echo No failures reported > test_result.log ) |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 49 | $(VIMPROG) -u NONE $(COMMON_ARGS) -S util\summarize.vim messages |
Bram Moolenaar | b9093d5 | 2022-09-23 19:42:31 +0100 | [diff] [blame] | 50 | -if exist starttime del starttime |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 51 | @echo. |
| 52 | @echo Test results: |
| 53 | @cmd /c type test_result.log |
| 54 | @if exist test.log ( echo TEST FAILURE & exit /b 1 ) \ |
| 55 | else ( echo ALL DONE ) |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 56 | |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 57 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 58 | # Execute an individual new style test, e.g.: |
| 59 | # mingw32-make -f Make_ming.mak test_largefile |
| 60 | $(NEW_TESTS): |
| 61 | -if exist $@.res del $@.res |
| 62 | -if exist test.log del test.log |
| 63 | -if exist messages del messages |
Bram Moolenaar | b9093d5 | 2022-09-23 19:42:31 +0100 | [diff] [blame] | 64 | -if exist starttime del starttime |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 65 | @$(MAKE) -f Make_ming.mak $@.res VIMPROG=$(VIMPROG) --no-print-directory |
| 66 | @type messages |
| 67 | @if exist test.log exit 1 |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 68 | |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 69 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 70 | # Delete files that may interfere with running tests. This includes some files |
| 71 | # that may result from working on the tests, not only from running them. |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 72 | clean: |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 73 | -@if exist *.out $(DEL) *.out |
| 74 | -@if exist *.failed $(DEL) *.failed |
| 75 | -@if exist *.res $(DEL) *.res |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 76 | -@if exist $(DOSTMP) rd /s /q $(DOSTMP) |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 77 | -@if exist test.in $(DEL) test.in |
| 78 | -@if exist test.ok $(DEL) test.ok |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 79 | -@if exist Xdir1 $(DELDIR) Xdir1 |
| 80 | -@if exist Xfind $(DELDIR) Xfind |
Bram Moolenaar | 30fe886 | 2017-07-29 23:01:57 +0200 | [diff] [blame] | 81 | -@if exist XfakeHOME $(DELDIR) XfakeHOME |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 82 | -@if exist X* $(DEL) X* |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 83 | -@for /d %%i in (X*) do @rd /s/q %%i |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 84 | -@if exist viminfo $(DEL) viminfo |
| 85 | -@if exist test.log $(DEL) test.log |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 86 | -@if exist test_result.log del test_result.log |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 87 | -@if exist messages $(DEL) messages |
Bram Moolenaar | b9093d5 | 2022-09-23 19:42:31 +0100 | [diff] [blame] | 88 | -@if exist starttime $(DEL) starttime |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 89 | -@if exist benchmark.out del benchmark.out |
Bram Moolenaar | 65408f7 | 2017-03-07 21:31:27 +0100 | [diff] [blame] | 90 | -@if exist opt_test.vim $(DEL) opt_test.vim |
Bram Moolenaar | 2d12c25 | 2022-06-13 21:42:45 +0100 | [diff] [blame] | 91 | -@if exist guidialog $(DEL) guidialog |
| 92 | -@if exist guidialogfile $(DEL) guidialogfile |
Bram Moolenaar | 34b6cb1 | 2008-09-20 14:27:03 +0000 | [diff] [blame] | 93 | |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 94 | nolog: |
| 95 | -@if exist test.log $(DEL) test.log |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 96 | -@if exist test_result.log del test_result.log |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 97 | -@if exist messages $(DEL) messages |
Bram Moolenaar | b9093d5 | 2022-09-23 19:42:31 +0100 | [diff] [blame] | 98 | -@if exist starttime $(DEL) starttime |
Bram Moolenaar | fda3729 | 2014-11-05 14:27:36 +0100 | [diff] [blame] | 99 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 100 | |
| 101 | # Tiny tests. Works even without the +eval feature. |
| 102 | tinytests: $(SCRIPTS_TINY_OUT) |
| 103 | |
| 104 | # Copy the input files to dostmp, changing the fileformat to dos. |
| 105 | $(DOSTMP)/%.in : %.in |
| 106 | if not exist $(DOSTMP)\nul mkdir $(DOSTMP) |
Bram Moolenaar | 05c1acd | 2020-09-13 21:01:22 +0200 | [diff] [blame] | 107 | if exist $(DOSTMP)\$< $(DEL) $(DOSTMP)\$< |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 108 | $(VIMPROG) -u util\dos.vim $(COMMON_ARGS) "+set ff=dos|f $@|wq" $< |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 109 | |
| 110 | # For each input file dostmp/test99.in run the tests. |
| 111 | # This moves test99.in to test99.in.bak temporarily. |
| 112 | %.out : $(DOSTMP)/%.in |
| 113 | -@if exist test.out $(DEL) test.out |
| 114 | -@if exist $(DOSTMP)\$@ $(DEL) $(DOSTMP)\$@ |
| 115 | $(MV) $(notdir $<) $(notdir $<).bak > NUL |
| 116 | $(CP) $(DOSTMP)\$(notdir $<) $(notdir $<) > NUL |
| 117 | $(CP) $(basename $@).ok test.ok > NUL |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 118 | $(VIMPROG) -u util\dos.vim $(COMMON_ARGS) -s dotest.in $(notdir $<) |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 119 | -@if exist test.out $(MV) test.out $(DOSTMP)\$@ > NUL |
| 120 | -@if exist $(notdir $<).bak $(MV) $(notdir $<).bak $(notdir $<) > NUL |
| 121 | -@if exist test.ok $(DEL) test.ok |
| 122 | -@if exist Xdir1 $(DELDIR) /s /q Xdir1 |
| 123 | -@if exist Xfind $(DELDIR) Xfind |
| 124 | -@if exist XfakeHOME $(DELDIR) XfakeHOME |
| 125 | -@del X* |
| 126 | -@if exist viminfo del viminfo |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 127 | $(VIMPROG) -u util\dos.vim $(COMMON_ARGS) "+set ff=unix|f test.out|wq" \ |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 128 | $(DOSTMP)\$@ |
| 129 | @diff test.out $(basename $@).ok & if errorlevel 1 \ |
| 130 | ( $(MV) test.out $(basename $@).failed > NUL \ |
| 131 | & del $(DOSTMP)\$@ \ |
| 132 | & echo $(basename $@) FAILED >> test.log ) \ |
| 133 | else ( $(MV) test.out $(basename $@).out > NUL ) |
| 134 | |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 135 | |
| 136 | # New style of tests uses Vim script with assert calls. These are easier |
| 137 | # to write and a lot easier to read and debug. |
| 138 | # Limitation: Only works with the +eval feature. |
| 139 | |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 140 | newtests: newtestssilent |
Bram Moolenaar | 6e3aeec | 2020-08-26 22:29:57 +0200 | [diff] [blame] | 141 | @if exist messages type messages |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 142 | |
| 143 | newtestssilent: $(NEW_TESTS_RES) |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 144 | |
| 145 | .vim.res: |
Bram Moolenaar | 4635e11 | 2017-10-07 21:05:18 +0200 | [diff] [blame] | 146 | @echo $(VIMPROG) > vimcmd |
Bram Moolenaar | 2d12c25 | 2022-06-13 21:42:45 +0100 | [diff] [blame] | 147 | $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim |
Bram Moolenaar | 8be2fbb | 2017-02-23 19:32:47 +0100 | [diff] [blame] | 148 | @$(DEL) vimcmd |
| 149 | |
| 150 | test_gui.res: test_gui.vim |
Bram Moolenaar | 4635e11 | 2017-10-07 21:05:18 +0200 | [diff] [blame] | 151 | @echo $(VIMPROG) > vimcmd |
Bram Moolenaar | 2d12c25 | 2022-06-13 21:42:45 +0100 | [diff] [blame] | 152 | $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $< |
Bram Moolenaar | 8be2fbb | 2017-02-23 19:32:47 +0100 | [diff] [blame] | 153 | @$(DEL) vimcmd |
| 154 | |
| 155 | test_gui_init.res: test_gui_init.vim |
Bram Moolenaar | 4635e11 | 2017-10-07 21:05:18 +0200 | [diff] [blame] | 156 | @echo $(VIMPROG) > vimcmd |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 157 | $(VIMPROG) -u util\gui_preinit.vim -U util\gui_init.vim $(NO_PLUGINS) -S runtest.vim $< |
Bram Moolenaar | 5b4a376 | 2016-08-06 20:36:34 +0200 | [diff] [blame] | 158 | @$(DEL) vimcmd |
Bram Moolenaar | 9bd3186 | 2016-06-13 22:58:39 +0200 | [diff] [blame] | 159 | |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 160 | opt_test.vim: util/gen_opt_test.vim ../optiondefs.h ../../runtime/doc/options.txt |
Milly | b498c44 | 2024-10-17 21:05:31 +0200 | [diff] [blame] | 161 | $(VIMPROG) -e -s -u NONE $(COMMON_ARGS) --nofork -S $^ |
| 162 | @if test -f test.log; then \ |
| 163 | cat test.log; \ |
| 164 | exit 1; \ |
| 165 | fi |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 166 | |
| 167 | test_bench_regexp.res: test_bench_regexp.vim |
| 168 | -$(DEL) benchmark.out |
| 169 | @echo $(VIMPROG) > vimcmd |
Bram Moolenaar | 2d12c25 | 2022-06-13 21:42:45 +0100 | [diff] [blame] | 170 | $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim |
Bram Moolenaar | b96a32e | 2020-08-13 18:59:55 +0200 | [diff] [blame] | 171 | @$(DEL) vimcmd |
| 172 | $(CAT) benchmark.out |