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_MORE3) \ 28 $(SCRIPTS_MORE4) 29 30SCRIPTS_BENCH = bench_re_freeze.out 31 32.SUFFIXES: .in .out .res .vim 33 34nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report 35 36gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report 37 38benchmark: $(SCRIPTS_BENCH) 39 40report: 41 @echo 42 @echo 'Test results:' 43 @/bin/sh -c "if test -f test.log; \ 44 then cat test.log; echo TEST FAILURE; exit 1; \ 45 else echo ALL DONE; \ 46 fi" 47 48$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(VIMPROG) 49 50# Must run test1 first to create small.vim. 51$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST) 52 53RM_ON_RUN = test.out X* viminfo 54RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmark.out 55RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_PLUGIN) -s dotest.in 56 57clean: 58 -rm -rf *.out *.failed *.res *.rej *.orig test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.* 59 60test1.out: test1.in 61 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize 62 $(RUN_VIM) $*.in 63 @/bin/sh -c "if test -f wrongtermsize; \ 64 then echo; \ 65 echo test1 FAILED - terminal size must be 80x24 or larger; \ 66 echo; exit 1; \ 67 elif diff test.out $*.ok; \ 68 then mv -f test.out $*.out; \ 69 else echo; \ 70 echo test1 FAILED - Something basic is wrong; \ 71 echo; exit 1; fi" 72 -rm -rf X* viminfo 73 74.in.out: 75 -rm -rf $*.failed test.ok $(RM_ON_RUN) 76 cp $*.ok test.ok 77 # Sleep a moment to avoid that the xterm title is messed up. 78 # 200 msec is sufficient, but only modern sleep supports a fraction of 79 # a second, fall back to a second if it fails. 80 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 81 -$(RUN_VIM) $*.in 82 83 # For flaky tests retry one time. No tests at the moment. 84 #@/bin/sh -c "if test -f test.out -a $* = test61; then \ 85 # if diff test.out $*.ok; \ 86 # then echo flaky test ok first time; \ 87 # else rm -rf $*.failed $(RM_ON_RUN); \ 88 # $(RUN_VIM) $*.in; \ 89 # fi \ 90 # fi" 91 92 # Check if the test.out file matches test.ok. 93 @/bin/sh -c "if test -f test.out; then \ 94 if diff test.out $*.ok; \ 95 then mv -f test.out $*.out; \ 96 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \ 97 fi \ 98 else echo $* NO OUTPUT >>test.log; \ 99 fi" 100 @/bin/sh -c "if test -f valgrind; then\ 101 mv -f valgrind valgrind.$*; \ 102 fi" 103 -rm -rf X* test.ok viminfo 104 105bench_re_freeze.out: bench_re_freeze.vim 106 -rm -rf benchmark.out $(RM_ON_RUN) 107 # Sleep a moment to avoid that the xterm title is messed up. 108 # 200 msec is sufficient, but only modern sleep supports a fraction of 109 # a second, fall back to a second if it fails. 110 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 111 -$(RUN_VIM) $*.in 112 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi" 113 114nolog: 115 -rm -f test.log messages 116 117 118# New style of tests uses Vim script with assert calls. These are easier 119# to write and a lot easier to read and debug. 120# Limitation: Only works with the +eval feature. 121RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_PLUGIN) 122 123newtests: newtestssilent 124 @/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" 125 126newtestssilent: $(NEW_TESTS) 127 128 129.vim.res: 130 @echo "$(RUN_VIMTEST)" > vimcmd 131 $(RUN_VIMTEST) -U NONE -S runtest.vim $*.vim 132 @rm vimcmd 133