blob: 1a54823e52c593e3c18cacd47a1022232fa38ace [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
Christopher Plewright0b228cd2022-11-24 12:19:50 +00006# Testing may be done with a debug build
7!IF EXIST(..\\vimd.exe) && !EXIST(..\\vim.exe)
RestorerZcd33faf2024-07-04 17:47:16 +02008VIMPROG = ..\\vimd.exe
Christopher Plewright0b228cd2022-11-24 12:19:50 +00009!ELSE
RestorerZcd33faf2024-07-04 17:47:16 +020010VIMPROG = ..\\vim.exe
Christopher Plewright0b228cd2022-11-24 12:19:50 +000011!ENDIF
12
K.Takata5bc13452022-09-09 10:52:47 +010013
14default: nongui
15
16!include Make_all.mak
17
18# Explicit dependencies.
Milly6eca04e2024-10-21 22:20:51 +020019test_options_all.res: opt_test.vim
K.Takata5bc13452022-09-09 10:52:47 +010020
21TEST_OUTFILES = $(SCRIPTS_TINY_OUT)
22DOSTMP = dostmp
23DOSTMP_OUTFILES = $(TEST_OUTFILES:test=dostmp\test)
24DOSTMP_INFILES = $(DOSTMP_OUTFILES:.out=.in)
25
26.SUFFIXES: .in .out .res .vim
27
28# Add --gui-dialog-file to avoid getting stuck in a dialog.
29COMMON_ARGS = $(NO_INITS) --gui-dialog-file guidialog
30
31nongui: nolog tinytests newtests report
32
33gui: nolog tinytests newtests report
34
35tiny: nolog tinytests report
36
37benchmark: $(SCRIPTS_BENCH)
38
39report:
40 @rem without the +eval feature test_result.log is a copy of test.log
41 @if exist test.log ( copy /y test.log test_result.log > nul ) \
42 else ( echo No failures reported > test_result.log )
43 $(VIMPROG) -u NONE $(COMMON_ARGS) -S summarize.vim messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010044 -if exist starttime del starttime
RestorerZ96509102024-07-11 21:14:15 +020045 @echo:
K.Takata5bc13452022-09-09 10:52:47 +010046 @echo Test results:
47 @cmd /c type test_result.log
48 @if exist test.log ( echo TEST FAILURE & exit /b 1 ) \
49 else ( echo ALL DONE )
50
51
52# Execute an individual new style test, e.g.:
53# nmake -f Make_mvc.mak test_largefile
54$(NEW_TESTS):
55 -if exist $@.res del $@.res
56 -if exist test.log del test.log
57 -if exist messages del messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010058 -if exist starttime del starttime
RestorerZ96509102024-07-11 21:14:15 +020059 @$(MAKE) -nologo -f Make_mvc.mak VIMPROG=$(VIMPROG) $@.res
K.Takata5bc13452022-09-09 10:52:47 +010060 @type messages
61 @if exist test.log exit 1
62
63
64# Delete files that may interfere with running tests. This includes some files
65# that may result from working on the tests, not only from running them.
66clean:
67 -if exist *.out del *.out
68 -if exist *.failed del *.failed
69 -if exist *.res del *.res
70 -if exist $(DOSTMP) rd /s /q $(DOSTMP)
71 -if exist test.in del test.in
72 -if exist test.ok del test.ok
73 -if exist Xdir1 rd /s /q Xdir1
74 -if exist Xfind rd /s /q Xfind
75 -if exist XfakeHOME rd /s /q XfakeHOME
76 -if exist X* del X*
77 -for /d %i in (X*) do @rd /s/q %i
78 -if exist viminfo del viminfo
79 -if exist test.log del test.log
80 -if exist test_result.log del test_result.log
81 -if exist messages del messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010082 -if exist starttime del starttime
K.Takata5bc13452022-09-09 10:52:47 +010083 -if exist benchmark.out del benchmark.out
84 -if exist opt_test.vim del opt_test.vim
85 -if exist guidialog del guidialog
86 -if exist guidialogfile del guidialogfile
87
88nolog:
89 -if exist test.log del test.log
90 -if exist test_result.log del test_result.log
91 -if exist messages del messages
Bram Moolenaarb9093d52022-09-23 19:42:31 +010092 -if exist starttime del starttime
K.Takata5bc13452022-09-09 10:52:47 +010093
94
95# Tiny tests. Works even without the +eval feature.
96tinytests: $(SCRIPTS_TINY_OUT)
97
98# Copy the input files to dostmp, changing the fileformat to dos.
99$(DOSTMP_INFILES): $(*B).in
100 if not exist $(DOSTMP)\NUL md $(DOSTMP)
101 if exist $@ del $@
102 $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=dos|f $@|wq" $(*B).in
103
104# For each input file dostmp/test99.in run the tests.
105# This moves test99.in to test99.in.bak temporarily.
106$(TEST_OUTFILES): $(DOSTMP)\$(*B).in
107 -@if exist test.out DEL test.out
108 -@if exist $(DOSTMP)\$(*B).out DEL $(DOSTMP)\$(*B).out
109 move $(*B).in $(*B).in.bak > nul
110 copy $(DOSTMP)\$(*B).in $(*B).in > nul
111 copy $(*B).ok test.ok > nul
112 $(VIMPROG) -u dos.vim $(COMMON_ARGS) -s dotest.in $(*B).in
113 -@if exist test.out MOVE /y test.out $(DOSTMP)\$(*B).out > nul
114 -@if exist $(*B).in.bak move /y $(*B).in.bak $(*B).in > nul
115 -@if exist test.ok del test.ok
116 -@if exist Xdir1 rd /s /q Xdir1
117 -@if exist Xfind rd /s /q Xfind
118 -@if exist XfakeHOME rd /s /q XfakeHOME
119 -@del X*
120 -@if exist viminfo del viminfo
121 $(VIMPROG) -u dos.vim $(COMMON_ARGS) "+set ff=unix|f test.out|wq" \
122 $(DOSTMP)\$(*B).out
123 @diff test.out $*.ok & if errorlevel 1 \
124 ( move /y test.out $*.failed > nul \
125 & del $(DOSTMP)\$(*B).out \
126 & echo $* FAILED >> test.log ) \
127 else ( move /y test.out $*.out > nul )
128
129
130# New style of tests uses Vim script with assert calls. These are easier
131# to write and a lot easier to read and debug.
132# Limitation: Only works with the +eval feature.
133
134newtests: newtestssilent
135 @if exist messages type messages
136
137newtestssilent: $(NEW_TESTS_RES)
138
139.vim.res:
140 @echo $(VIMPROG) > vimcmd
141 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
142 @del vimcmd
143
144test_gui.res: test_gui.vim
145 @echo $(VIMPROG) > vimcmd
146 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
147 @del vimcmd
148
149test_gui_init.res: test_gui_init.vim
150 @echo $(VIMPROG) > vimcmd
151 $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim
152 @del vimcmd
153
Milly6eca04e2024-10-21 22:20:51 +0200154opt_test.vim: gen_opt_test.vim ../optiondefs.h ../../runtime/doc/options.txt
Millyb498c442024-10-17 21:05:31 +0200155 $(VIMPROG) -e -s -u NONE $(COMMON_ARGS) --nofork -S $**
156 @if exist test.log ( type test.log & exit /b 1 )
K.Takata5bc13452022-09-09 10:52:47 +0100157
158test_bench_regexp.res: test_bench_regexp.vim
159 -if exist benchmark.out del benchmark.out
160 @echo $(VIMPROG) > vimcmd
161 $(VIMPROG) -u NONE $(COMMON_ARGS) -S runtest.vim $*.vim
162 @del vimcmd
163 @IF EXIST benchmark.out ( type benchmark.out )