blob: b11d2ea8efe9615bc6894bd5e39b54fd9edf28fb [file] [log] [blame]
Bram Moolenaar68392722010-07-30 22:04:17 +02001#
2# Makefile to run all tests for Vim, on Dos-like machines
Bram Moolenaar34b6cb12008-09-20 14:27:03 +00003# with sh.exe or zsh.exe in the path or not.
4#
5# Author: Bill McCarthy
6#
Bram Moolenaar34b6cb12008-09-20 14:27:03 +00007# Requires a set of Unix tools: echo, diff, etc.
8
Bram Moolenaarb96a32e2020-08-13 18:59:55 +02009# Don't use unix-like shell.
10SHELL = cmd.exe
11
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000012DEL = del
Bram Moolenaaracf92d22016-01-02 16:00:20 +010013DELDIR = rd /s /q
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020014MV = move /y
15CP = copy /y
Bram Moolenaarfda37292014-11-05 14:27:36 +010016CAT = type
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000017
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020018VIMPROG = ..\\vim
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000019
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020020default: nongui
Bram Moolenaar40bbcee2015-12-28 22:24:41 +010021
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010022include Make_all.mak
23
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020024# Explicit dependencies.
Milly6eca04e2024-10-21 22:20:51 +020025test_options_all.res: opt_test.vim
Bram Moolenaarfda37292014-11-05 14:27:36 +010026
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020027TEST_OUTFILES = $(SCRIPTS_TINY_OUT)
28DOSTMP = dostmp
29# Keep $(DOSTMP)/*.in
30.PRECIOUS: $(patsubst %.out, $(DOSTMP)/%.in, $(TEST_OUTFILES))
Bram Moolenaara6082432015-12-28 16:26:45 +010031
Bram Moolenaar9bd31862016-06-13 22:58:39 +020032.SUFFIXES: .in .out .res .vim
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000033
Bram Moolenaar2d12c252022-06-13 21:42:45 +010034# Add --gui-dialog-file to avoid getting stuck in a dialog.
35COMMON_ARGS = $(NO_INITS) --gui-dialog-file guidialog
36
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020037nongui: nolog tinytests newtests report
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000038
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020039gui: nolog tinytests newtests report
40
41tiny: nolog tinytests report
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000042
Bram Moolenaarfda37292014-11-05 14:27:36 +010043benchmark: $(SCRIPTS_BENCH)
44
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020045report:
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 Brabandteb380b92025-07-07 20:53:55 +020049 $(VIMPROG) -u NONE $(COMMON_ARGS) -S util\summarize.vim messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010050 -if exist starttime del starttime
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020051 @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 Moolenaar34b6cb12008-09-20 14:27:03 +000056
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000057
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020058# 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 Moolenaarb9093d52022-09-23 19:42:31 +010064 -if exist starttime del starttime
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020065 @$(MAKE) -f Make_ming.mak $@.res VIMPROG=$(VIMPROG) --no-print-directory
66 @type messages
67 @if exist test.log exit 1
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000068
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000069
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020070# 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 Moolenaar34b6cb12008-09-20 14:27:03 +000072clean:
Bram Moolenaar9bd31862016-06-13 22:58:39 +020073 -@if exist *.out $(DEL) *.out
74 -@if exist *.failed $(DEL) *.failed
75 -@if exist *.res $(DEL) *.res
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020076 -@if exist $(DOSTMP) rd /s /q $(DOSTMP)
Bram Moolenaar9bd31862016-06-13 22:58:39 +020077 -@if exist test.in $(DEL) test.in
78 -@if exist test.ok $(DEL) test.ok
Bram Moolenaar9bd31862016-06-13 22:58:39 +020079 -@if exist Xdir1 $(DELDIR) Xdir1
80 -@if exist Xfind $(DELDIR) Xfind
Bram Moolenaar30fe8862017-07-29 23:01:57 +020081 -@if exist XfakeHOME $(DELDIR) XfakeHOME
Bram Moolenaar9bd31862016-06-13 22:58:39 +020082 -@if exist X* $(DEL) X*
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020083 -@for /d %%i in (X*) do @rd /s/q %%i
Bram Moolenaar9bd31862016-06-13 22:58:39 +020084 -@if exist viminfo $(DEL) viminfo
85 -@if exist test.log $(DEL) test.log
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020086 -@if exist test_result.log del test_result.log
Bram Moolenaar9bd31862016-06-13 22:58:39 +020087 -@if exist messages $(DEL) messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010088 -@if exist starttime $(DEL) starttime
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020089 -@if exist benchmark.out del benchmark.out
Bram Moolenaar65408f72017-03-07 21:31:27 +010090 -@if exist opt_test.vim $(DEL) opt_test.vim
Bram Moolenaar2d12c252022-06-13 21:42:45 +010091 -@if exist guidialog $(DEL) guidialog
92 -@if exist guidialogfile $(DEL) guidialogfile
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000093
Bram Moolenaar9bd31862016-06-13 22:58:39 +020094nolog:
95 -@if exist test.log $(DEL) test.log
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020096 -@if exist test_result.log del test_result.log
Bram Moolenaar9bd31862016-06-13 22:58:39 +020097 -@if exist messages $(DEL) messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010098 -@if exist starttime $(DEL) starttime
Bram Moolenaarfda37292014-11-05 14:27:36 +010099
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200100
101# Tiny tests. Works even without the +eval feature.
102tinytests: $(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 Moolenaar05c1acd2020-09-13 21:01:22 +0200107 if exist $(DOSTMP)\$< $(DEL) $(DOSTMP)\$<
Christian Brabandteb380b92025-07-07 20:53:55 +0200108 $(VIMPROG) -u util\dos.vim $(COMMON_ARGS) "+set ff=dos|f $@|wq" $<
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200109
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 Brabandteb380b92025-07-07 20:53:55 +0200118 $(VIMPROG) -u util\dos.vim $(COMMON_ARGS) -s dotest.in $(notdir $<)
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200119 -@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 Brabandteb380b92025-07-07 20:53:55 +0200127 $(VIMPROG) -u util\dos.vim $(COMMON_ARGS) "+set ff=unix|f test.out|wq" \
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200128 $(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 Moolenaar9bd31862016-06-13 22:58:39 +0200135
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 Moolenaarb96a32e2020-08-13 18:59:55 +0200140newtests: newtestssilent
Bram Moolenaar6e3aeec2020-08-26 22:29:57 +0200141 @if exist messages type messages
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200142
143newtestssilent: $(NEW_TESTS_RES)
Bram Moolenaar9bd31862016-06-13 22:58:39 +0200144
145.vim.res:
Bram Moolenaar4635e112017-10-07 21:05:18 +0200146 @echo $(VIMPROG) > vimcmd
Bram Moolenaar2d12c252022-06-13 21:42:45 +0100147 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100148 @$(DEL) vimcmd
149
150test_gui.res: test_gui.vim
Bram Moolenaar4635e112017-10-07 21:05:18 +0200151 @echo $(VIMPROG) > vimcmd
Bram Moolenaar2d12c252022-06-13 21:42:45 +0100152 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $<
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100153 @$(DEL) vimcmd
154
155test_gui_init.res: test_gui_init.vim
Bram Moolenaar4635e112017-10-07 21:05:18 +0200156 @echo $(VIMPROG) > vimcmd
Christian Brabandteb380b92025-07-07 20:53:55 +0200157 $(VIMPROG) -u util\gui_preinit.vim -U util\gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
Bram Moolenaar5b4a3762016-08-06 20:36:34 +0200158 @$(DEL) vimcmd
Bram Moolenaar9bd31862016-06-13 22:58:39 +0200159
Christian Brabandteb380b92025-07-07 20:53:55 +0200160opt_test.vim: util/gen_opt_test.vim ../optiondefs.h ../../runtime/doc/options.txt
Millyb498c442024-10-17 21:05:31 +0200161 $(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 Moolenaarb96a32e2020-08-13 18:59:55 +0200166
167test_bench_regexp.res: test_bench_regexp.vim
168 -$(DEL) benchmark.out
169 @echo $(VIMPROG) > vimcmd
Bram Moolenaar2d12c252022-06-13 21:42:45 +0100170 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200171 @$(DEL) vimcmd
172 $(CAT) benchmark.out