blob: 5e17963c5e8ea5f8bae926d72190b863b5811bd9 [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.
25test_options.res test_alot.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 Moolenaarb96a32e2020-08-13 18:59:55 +020034nongui: nolog tinytests newtests report
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000035
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020036gui: nolog tinytests newtests report
37
38tiny: nolog tinytests report
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000039
Bram Moolenaarfda37292014-11-05 14:27:36 +010040benchmark: $(SCRIPTS_BENCH)
41
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020042report:
43 @rem without the +eval feature test_result.log is a copy of test.log
44 @if exist test.log ( copy /y test.log test_result.log > nul ) \
45 else ( echo No failures reported > test_result.log )
46 $(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages
47 @echo.
48 @echo Test results:
49 @cmd /c type test_result.log
50 @if exist test.log ( echo TEST FAILURE & exit /b 1 ) \
51 else ( echo ALL DONE )
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000052
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000053
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020054# Execute an individual new style test, e.g.:
55# mingw32-make -f Make_ming.mak test_largefile
56$(NEW_TESTS):
57 -if exist $@.res del $@.res
58 -if exist test.log del test.log
59 -if exist messages del messages
60 @$(MAKE) -f Make_ming.mak $@.res VIMPROG=$(VIMPROG) --no-print-directory
61 @type messages
62 @if exist test.log exit 1
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000063
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000064
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020065# Delete files that may interfere with running tests. This includes some files
66# that may result from working on the tests, not only from running them.
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000067clean:
Bram Moolenaar9bd31862016-06-13 22:58:39 +020068 -@if exist *.out $(DEL) *.out
69 -@if exist *.failed $(DEL) *.failed
70 -@if exist *.res $(DEL) *.res
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020071 -@if exist $(DOSTMP) rd /s /q $(DOSTMP)
Bram Moolenaar9bd31862016-06-13 22:58:39 +020072 -@if exist test.in $(DEL) test.in
73 -@if exist test.ok $(DEL) test.ok
Bram Moolenaar9bd31862016-06-13 22:58:39 +020074 -@if exist Xdir1 $(DELDIR) Xdir1
75 -@if exist Xfind $(DELDIR) Xfind
Bram Moolenaar30fe8862017-07-29 23:01:57 +020076 -@if exist XfakeHOME $(DELDIR) XfakeHOME
Bram Moolenaar9bd31862016-06-13 22:58:39 +020077 -@if exist X* $(DEL) X*
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020078 -@for /d %%i in (X*) do @rd /s/q %%i
Bram Moolenaar9bd31862016-06-13 22:58:39 +020079 -@if exist viminfo $(DEL) viminfo
80 -@if exist test.log $(DEL) test.log
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020081 -@if exist test_result.log del test_result.log
Bram Moolenaar9bd31862016-06-13 22:58:39 +020082 -@if exist messages $(DEL) messages
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020083 -@if exist benchmark.out del benchmark.out
Bram Moolenaar65408f72017-03-07 21:31:27 +010084 -@if exist opt_test.vim $(DEL) opt_test.vim
Bram Moolenaar34b6cb12008-09-20 14:27:03 +000085
Bram Moolenaar9bd31862016-06-13 22:58:39 +020086nolog:
87 -@if exist test.log $(DEL) test.log
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020088 -@if exist test_result.log del test_result.log
Bram Moolenaar9bd31862016-06-13 22:58:39 +020089 -@if exist messages $(DEL) messages
Bram Moolenaarfda37292014-11-05 14:27:36 +010090
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020091
92# Tiny tests. Works even without the +eval feature.
93tinytests: $(SCRIPTS_TINY_OUT)
94
95# Copy the input files to dostmp, changing the fileformat to dos.
96$(DOSTMP)/%.in : %.in
97 if not exist $(DOSTMP)\nul mkdir $(DOSTMP)
Bram Moolenaar05c1acd2020-09-13 21:01:22 +020098 if exist $(DOSTMP)\$< $(DEL) $(DOSTMP)\$<
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020099 $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $<
100
101# For each input file dostmp/test99.in run the tests.
102# This moves test99.in to test99.in.bak temporarily.
103%.out : $(DOSTMP)/%.in
104 -@if exist test.out $(DEL) test.out
105 -@if exist $(DOSTMP)\$@ $(DEL) $(DOSTMP)\$@
106 $(MV) $(notdir $<) $(notdir $<).bak > NUL
107 $(CP) $(DOSTMP)\$(notdir $<) $(notdir $<) > NUL
108 $(CP) $(basename $@).ok test.ok > NUL
109 $(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $(notdir $<)
110 -@if exist test.out $(MV) test.out $(DOSTMP)\$@ > NUL
111 -@if exist $(notdir $<).bak $(MV) $(notdir $<).bak $(notdir $<) > NUL
112 -@if exist test.ok $(DEL) test.ok
113 -@if exist Xdir1 $(DELDIR) /s /q Xdir1
114 -@if exist Xfind $(DELDIR) Xfind
115 -@if exist XfakeHOME $(DELDIR) XfakeHOME
116 -@del X*
117 -@if exist viminfo del viminfo
118 $(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
119 $(DOSTMP)\$@
120 @diff test.out $(basename $@).ok & if errorlevel 1 \
121 ( $(MV) test.out $(basename $@).failed > NUL \
122 & del $(DOSTMP)\$@ \
123 & echo $(basename $@) FAILED >> test.log ) \
124 else ( $(MV) test.out $(basename $@).out > NUL )
125
Bram Moolenaar9bd31862016-06-13 22:58:39 +0200126
127# New style of tests uses Vim script with assert calls. These are easier
128# to write and a lot easier to read and debug.
129# Limitation: Only works with the +eval feature.
130
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200131newtests: newtestssilent
Bram Moolenaar6e3aeec2020-08-26 22:29:57 +0200132 @if exist messages type messages
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200133
134newtestssilent: $(NEW_TESTS_RES)
Bram Moolenaar9bd31862016-06-13 22:58:39 +0200135
136.vim.res:
Bram Moolenaar4635e112017-10-07 21:05:18 +0200137 @echo $(VIMPROG) > vimcmd
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100138 $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
139 @$(DEL) vimcmd
140
141test_gui.res: test_gui.vim
Bram Moolenaar4635e112017-10-07 21:05:18 +0200142 @echo $(VIMPROG) > vimcmd
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100143 $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $<
144 @$(DEL) vimcmd
145
146test_gui_init.res: test_gui_init.vim
Bram Moolenaar4635e112017-10-07 21:05:18 +0200147 @echo $(VIMPROG) > vimcmd
Bram Moolenaar84be8b62017-03-13 22:41:42 +0100148 $(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
Bram Moolenaar5b4a3762016-08-06 20:36:34 +0200149 @$(DEL) vimcmd
Bram Moolenaar9bd31862016-06-13 22:58:39 +0200150
Bram Moolenaard9b0d832019-09-14 15:46:32 +0200151opt_test.vim: ../optiondefs.h gen_opt_test.vim
152 $(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../optiondefs.h
Bram Moolenaarb96a32e2020-08-13 18:59:55 +0200153
154test_bench_regexp.res: test_bench_regexp.vim
155 -$(DEL) benchmark.out
156 @echo $(VIMPROG) > vimcmd
157 $(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
158 @$(DEL) vimcmd
159 $(CAT) benchmark.out