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