1# 2# Makefile to run all tests for Vim 3# 4 5# Use console or GUI. 6VIMPROG = ../vim 7XXDPROG = ../xxd/xxd 8# VIMPROG = ../gvim 9 10SCRIPTSOURCE = ../../runtime 11 12# Comment out this line to see the verbose output of tests. 13# 14# Catches SwapExists to avoid hanging at the ATTENTION prompt. 15REDIR_TEST_TO_NULL = --cmd 'au SwapExists * let v:swapchoice = "e"' > /dev/null 16 17# Uncomment this line to use valgrind for memory leaks and extra warnings. 18# The output goes into a file "valgrind.testN" 19# Vim should be compiled with EXITFREE to avoid false warnings. 20# This will make testing about 10 times as slow. 21# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$* 22 23default: nongui 24 25# The list of tests is common to all systems. 26# This defines NEW_TESTS, NEW_TESTS_RES, SCRIPTS_ALL, SCRIPTS_MORE* and 27# SCRIPTS_GUI. 28include Make_all.mak 29 30 31SCRIPTS = $(SCRIPTS_ALL) \ 32 $(SCRIPTS_MORE1) \ 33 $(SCRIPTS_MORE2) \ 34 $(SCRIPTS_MORE4) 35 36# Explicit dependencies. 37test49.out: test49.vim 38 39test_options.res test_alot.res: opt_test.vim 40 41SCRIPTS_BENCH = test_bench_regexp.res 42 43.SUFFIXES: .in .out .res .vim 44 45nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report 46 47gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report 48 49benchmark: $(SCRIPTS_BENCH) 50 51report: 52 # without the +eval feature test_result.log is a copy of test.log 53 @/bin/sh -c "if test -f test.log; \ 54 then cp test.log test_result.log; \ 55 else echo No failures reported > test_result.log; \ 56 fi" 57 $(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages $(REDIR_TEST_TO_NULL) 58 @echo 59 @echo 'Test results:' 60 @cat test_result.log 61 @/bin/sh -c "if test -f test.log; \ 62 then echo TEST FAILURE; exit 1; \ 63 else echo ALL DONE; \ 64 fi" 65 66$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(VIMPROG) 67 68# Must run test1 first to create small.vim. 69$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(SCRIPTS_FIRST) 70 71 72# Execute an individual new style test, e.g.: 73# make test_largefile 74$(NEW_TESTS): 75 rm -f $@.res test.log messages 76 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE) 77 @cat messages 78 @if test -f test.log; then \ 79 exit 1; \ 80 fi 81 82# Run only tests specific for Vim9 script 83test_vim9: 84 rm -f test_vim9_*.res test.log messages 85 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $(TEST_VIM9_RES) VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE) 86 @cat messages 87 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile report VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE) 88 @if test -f test.log; then \ 89 exit 1; \ 90 fi 91 92RM_ON_RUN = test.out X* viminfo 93RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim test.ok benchmark.out 94RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in 95 96# Delete files that may interfere with running tests. This includes some files 97# that may result from working on the tests, not only from running them. 98clean: 99 -rm -rf *.out *.failed *.res *.rej *.orig XfakeHOME Xdir1 Xfind 100 -rm -f opt_test.vim test.log test_result.log messages 101 -rm -f $(RM_ON_RUN) $(RM_ON_START) 102 -rm -f valgrind.* 103 -rm -f asan.* 104 105test1.out: test1.in 106 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize 107 $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL) 108 @/bin/sh -c "if test -f wrongtermsize; \ 109 then echo; \ 110 echo test1 FAILED - terminal size must be 80x24 or larger; \ 111 echo; exit 1; \ 112 elif diff test.out $*.ok; \ 113 then mv -f test.out $*.out; \ 114 else echo; \ 115 echo test1 FAILED - Something basic is wrong; \ 116 echo; exit 1; fi" 117 -rm -rf X* viminfo 118 119.in.out: 120 -rm -rf $*.failed test.ok $(RM_ON_RUN) 121 cp $*.ok test.ok 122 # Sleep a moment to avoid that the xterm title is messed up. 123 # 200 msec is sufficient, but only modern sleep supports a fraction of 124 # a second, fall back to a second if it fails. 125 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 126 $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL) 127 128 # For flaky tests retry one time. No tests at the moment. 129 #@/bin/sh -c "if test -f test.out -a $* = test61; then \ 130 # if diff test.out $*.ok; \ 131 # then echo flaky test ok first time; \ 132 # else rm -rf $*.failed $(RM_ON_RUN); \ 133 # $(RUN_VIM) $*.in; \ 134 # fi \ 135 # fi" 136 137 # Check if the test.out file matches test.ok. 138 @/bin/sh -c "if test -f test.out; then \ 139 if diff test.out $*.ok; \ 140 then mv -f test.out $*.out; \ 141 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \ 142 fi \ 143 else echo $* NO OUTPUT >>test.log; \ 144 fi" 145 @/bin/sh -c "if test -f valgrind; then\ 146 mv -f valgrind valgrind.$*; \ 147 fi" 148 -rm -rf X* test.ok viminfo 149 150nolog: 151 -rm -f test.log messages 152 153 154# New style of tests uses Vim script with assert calls. These are easier 155# to write and a lot easier to read and debug. 156# Limitation: Only works with the +eval feature. 157RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim 158 159newtests: newtestssilent 160 @/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages; fi" 161 162newtestssilent: $(NEW_TESTS_RES) 163 164 165.vim.res: 166 @echo "$(VIMPROG)" > vimcmd 167 @echo "$(RUN_VIMTEST)" >> vimcmd 168 $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL) 169 @rm vimcmd 170 171test_gui.res: test_gui.vim 172 @echo "$(VIMPROG)" > vimcmd 173 @echo "$(RUN_GVIMTEST)" >> vimcmd 174 $(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $< 175 @rm vimcmd 176 177test_gui_init.res: test_gui_init.vim 178 @echo "$(VIMPROG)" > vimcmd 179 @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd 180 $(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< 181 @rm vimcmd 182 183opt_test.vim: ../optiondefs.h gen_opt_test.vim 184 $(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../optiondefs.h 185 186test_xxd.res: 187 XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim 188 189test_bench_regexp.res: test_bench_regexp.vim 190 -rm -rf benchmark.out $(RM_ON_RUN) 191 # Sleep a moment to avoid that the xterm title is messed up. 192 # 200 msec is sufficient, but only modern sleep supports a fraction of 193 # a second, fall back to a second if it fails. 194 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 195 $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL) 196 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi" 197