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