blob: cbb21712ae8716424315c7dce33a82a37cf40ea7 [file] [log] [blame]
K.Takata5bc13452022-09-09 10:52:47 +01001#
2# Makefile to run all tests for Vim, on Dos-like machines.
3#
4# Requires a set of Unix tools: echo, diff, etc.
5
6VIMPROG = ..\\vim
7
8default: nongui
9
10!include Make_all.mak
11
12# Explicit dependencies.
13test_options.res test_alot.res: opt_test.vim
14
15TEST_OUTFILES = $(SCRIPTS_TINY_OUT)
16DOSTMP = dostmp
17DOSTMP_OUTFILES = $(TEST_OUTFILES:test=dostmp\test)
18DOSTMP_INFILES = $(DOSTMP_OUTFILES:.out=.in)
19
20.SUFFIXES: .in .out .res .vim
21
22# Add --gui-dialog-file to avoid getting stuck in a dialog.
23COMMON_ARGS = $(NO_INITS) --gui-dialog-file guidialog
24
25nongui: nolog tinytests newtests report
26
27gui: nolog tinytests newtests report
28
29tiny: nolog tinytests report
30
31benchmark: $(SCRIPTS_BENCH)
32
33report:
34 @rem without the +eval feature test_result.log is a copy of test.log
35 @if exist test.log ( copy /y test.log test_result.log > nul ) \
36 else ( echo No failures reported > test_result.log )
37 $(VIMPROG) -u NONE $(COMMON_ARGS) -S summarize.vim messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010038 -if exist starttime del starttime
K.Takata5bc13452022-09-09 10:52:47 +010039 @echo.
40 @echo Test results:
41 @cmd /c type test_result.log
42 @if exist test.log ( echo TEST FAILURE & exit /b 1 ) \
43 else ( echo ALL DONE )
44
45
46# Execute an individual new style test, e.g.:
47# nmake -f Make_mvc.mak test_largefile
48$(NEW_TESTS):
49 -if exist $@.res del $@.res
50 -if exist test.log del test.log
51 -if exist messages del messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010052 -if exist starttime del starttime
K.Takata5bc13452022-09-09 10:52:47 +010053 @$(MAKE) -nologo -f Make_mvc.mak $@.res VIMPROG=$(VIMPROG)
54 @type messages
55 @if exist test.log exit 1
56
57
58# Delete files that may interfere with running tests. This includes some files
59# that may result from working on the tests, not only from running them.
60clean:
61 -if exist *.out del *.out
62 -if exist *.failed del *.failed
63 -if exist *.res del *.res
64 -if exist $(DOSTMP) rd /s /q $(DOSTMP)
65 -if exist test.in del test.in
66 -if exist test.ok del test.ok
67 -if exist Xdir1 rd /s /q Xdir1
68 -if exist Xfind rd /s /q Xfind
69 -if exist XfakeHOME rd /s /q XfakeHOME
70 -if exist X* del X*
71 -for /d %i in (X*) do @rd /s/q %i
72 -if exist viminfo del viminfo
73 -if exist test.log del test.log
74 -if exist test_result.log del test_result.log
75 -if exist messages del messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010076 -if exist starttime del starttime
K.Takata5bc13452022-09-09 10:52:47 +010077 -if exist benchmark.out del benchmark.out
78 -if exist opt_test.vim del opt_test.vim
79 -if exist guidialog del guidialog
80 -if exist guidialogfile del guidialogfile
81
82nolog:
83 -if exist test.log del test.log
84 -if exist test_result.log del test_result.log
85 -if exist messages del messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010086 -if exist starttime del starttime
K.Takata5bc13452022-09-09 10:52:47 +010087
88
89# Tiny tests. Works even without the +eval feature.
90tinytests: $(SCRIPTS_TINY_OUT)
91
92# Copy the input files to dostmp, changing the fileformat to dos.
93$(DOSTMP_INFILES): $(*B).in
94 if not exist $(DOSTMP)\NUL md $(DOSTMP)
95 if exist $@ del $@
96 $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=dos|f $@|wq" $(*B).in
97
98# For each input file dostmp/test99.in run the tests.
99# This moves test99.in to test99.in.bak temporarily.
100$(TEST_OUTFILES): $(DOSTMP)\$(*B).in
101 -@if exist test.out DEL test.out
102 -@if exist $(DOSTMP)\$(*B).out DEL $(DOSTMP)\$(*B).out
103 move $(*B).in $(*B).in.bak > nul
104 copy $(DOSTMP)\$(*B).in $(*B).in > nul
105 copy $(*B).ok test.ok > nul
106 $(VIMPROG) -u dos.vim $(COMMON_ARGS) -s dotest.in $(*B).in
107 -@if exist test.out MOVE /y test.out $(DOSTMP)\$(*B).out > nul
108 -@if exist $(*B).in.bak move /y $(*B).in.bak $(*B).in > nul
109 -@if exist test.ok del test.ok
110 -@if exist Xdir1 rd /s /q Xdir1
111 -@if exist Xfind rd /s /q Xfind
112 -@if exist XfakeHOME rd /s /q XfakeHOME
113 -@del X*
114 -@if exist viminfo del viminfo
115 $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=unix|f test.out|wq" \
116 $(DOSTMP)\$(*B).out
117 @diff test.out $*.ok & if errorlevel 1 \
118 ( move /y test.out $*.failed > nul \
119 & del $(DOSTMP)\$(*B).out \
120 & echo $* FAILED >> test.log ) \
121 else ( move /y test.out $*.out > nul )
122
123
124# New style of tests uses Vim script with assert calls. These are easier
125# to write and a lot easier to read and debug.
126# Limitation: Only works with the +eval feature.
127
128newtests: newtestssilent
129 @if exist messages type messages
130
131newtestssilent: $(NEW_TESTS_RES)
132
133.vim.res:
134 @echo $(VIMPROG) > vimcmd
135 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
136 @del vimcmd
137
138test_gui.res: test_gui.vim
139 @echo $(VIMPROG) > vimcmd
140 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
141 @del vimcmd
142
143test_gui_init.res: test_gui_init.vim
144 @echo $(VIMPROG) > vimcmd
145 $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim
146 @del vimcmd
147
148opt_test.vim: ../optiondefs.h gen_opt_test.vim
149 $(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../optiondefs.h
150
151test_bench_regexp.res: test_bench_regexp.vim
152 -if exist benchmark.out del benchmark.out
153 @echo $(VIMPROG) > vimcmd
154 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
155 @del vimcmd
156 @IF EXIST benchmark.out ( type benchmark.out )