1# 2# Makefile to run all tests for Vim 3# 4 5# Use console or GUI. 6VIMPROG = ../vim 7# VIMPROG = ../gvim 8 9SCRIPTSOURCE = ../../runtime 10 11# Uncomment this line to use valgrind for memory leaks and extra warnings. 12# The output goes into a file "valgrind.testN" 13# Vim should be compiled with EXITFREE to avoid false warnings. 14# This will make testing about 10 times as slow. 15# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$* 16 17default: nongui 18 19# The list of tests is common to all systems. 20# This defines NEW_TESTS, SCRIPTS_ALL, SCRIPTS_MORE* and SCRIPTS_GUI. 21include Make_all.mak 22 23 24SCRIPTS = $(SCRIPTS_ALL) \ 25 $(SCRIPTS_MORE1) \ 26 $(SCRIPTS_MORE2) \ 27 $(SCRIPTS_MORE4) 28 29SCRIPTS_BENCH = bench_re_freeze.out 30 31.SUFFIXES: .in .out .res .vim 32 33nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report 34 35gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report 36 37benchmark: $(SCRIPTS_BENCH) 38 39report: 40 @echo 41 @echo 'Test results:' 42 @/bin/sh -c "if test -f test.log; \ 43 then cat test.log; echo TEST FAILURE; exit 1; \ 44 else echo ALL DONE; \ 45 fi" 46 47$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(VIMPROG) 48 49# Must run test1 first to create small.vim. 50$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST) 51 52RM_ON_RUN = test.out X* viminfo 53RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmark.out 54RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in 55 56clean: 57 -rm -rf *.out *.failed *.res *.rej *.orig opt_test.vim test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.* 58 59test1.out: test1.in 60 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize 61 $(RUN_VIM) $*.in 62 @/bin/sh -c "if test -f wrongtermsize; \ 63 then echo; \ 64 echo test1 FAILED - terminal size must be 80x24 or larger; \ 65 echo; exit 1; \ 66 elif diff test.out $*.ok; \ 67 then mv -f test.out $*.out; \ 68 else echo; \ 69 echo test1 FAILED - Something basic is wrong; \ 70 echo; exit 1; fi" 71 -rm -rf X* viminfo 72 73.in.out: 74 -rm -rf $*.failed test.ok $(RM_ON_RUN) 75 cp $*.ok test.ok 76 # Sleep a moment to avoid that the xterm title is messed up. 77 # 200 msec is sufficient, but only modern sleep supports a fraction of 78 # a second, fall back to a second if it fails. 79 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 80 $(RUN_VIM) $*.in 81 82 # For flaky tests retry one time. No tests at the moment. 83 #@/bin/sh -c "if test -f test.out -a $* = test61; then \ 84 # if diff test.out $*.ok; \ 85 # then echo flaky test ok first time; \ 86 # else rm -rf $*.failed $(RM_ON_RUN); \ 87 # $(RUN_VIM) $*.in; \ 88 # fi \ 89 # fi" 90 91 # Check if the test.out file matches test.ok. 92 @/bin/sh -c "if test -f test.out; then \ 93 if diff test.out $*.ok; \ 94 then mv -f test.out $*.out; \ 95 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \ 96 fi \ 97 else echo $* NO OUTPUT >>test.log; \ 98 fi" 99 @/bin/sh -c "if test -f valgrind; then\ 100 mv -f valgrind valgrind.$*; \ 101 fi" 102 -rm -rf X* test.ok viminfo 103 104bench_re_freeze.out: bench_re_freeze.vim 105 -rm -rf benchmark.out $(RM_ON_RUN) 106 # Sleep a moment to avoid that the xterm title is messed up. 107 # 200 msec is sufficient, but only modern sleep supports a fraction of 108 # a second, fall back to a second if it fails. 109 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 110 $(RUN_VIM) $*.in 111 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi" 112 113nolog: 114 -rm -f test.log messages 115 116 117# New style of tests uses Vim script with assert calls. These are easier 118# to write and a lot easier to read and debug. 119# Limitation: Only works with the +eval feature. 120RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim 121 122newtests: newtestssilent 123 @/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages && if test -f test.log; then cat test.log; fi ; fi" 124 125newtestssilent: $(NEW_TESTS) 126 127 128.vim.res: writevimcmd 129 @echo "$(VIMPROG)" > vimcmd 130 @echo "$(RUN_VIMTEST)" >> vimcmd 131 $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim 132 @rm vimcmd 133 134test_gui.res: test_gui.vim 135 @echo "$(VIMPROG)" > vimcmd 136 @echo "$(RUN_GVIMTEST)" >> vimcmd 137 $(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $< 138 @rm vimcmd 139 140test_gui_init.res: test_gui_init.vim 141 @echo "$(VIMPROG)" > vimcmd 142 @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd 143 $(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $< 144 @rm vimcmd 145 146opt_test.vim: ../option.c gen_opt_test.vim 147 $(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c 148