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"' | LC_ALL=C LANG=C LANGUAGE=C awk '/Executing Test_/{match($$0, "Executing Test_[^\\)]*\\)"); print substr($$0, RSTART, RLENGTH) "\r"; fflush()}' 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 SCRIPTS_TINY_OUT, NEW_TESTS and NEW_TESTS_RES. 27include Make_all.mak 28 29# Explicit dependencies. 30test_options.res test_alot.res: opt_test.vim 31 32.SUFFIXES: .in .out .res .vim 33 34nongui: nolog tinytests newtests report 35 36gui: nolog tinytests newtests report 37 38tiny: nolog tinytests report 39 40benchmark: $(SCRIPTS_BENCH) 41 42report: 43 @# without the +eval feature test_result.log is a copy of test.log 44 @/bin/sh -c "if test -f test.log; \ 45 then cp test.log test_result.log; \ 46 else echo No failures reported > test_result.log; \ 47 fi" 48 $(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages $(REDIR_TEST_TO_NULL) 49 @echo 50 @echo 'Test results:' 51 @cat test_result.log 52 @/bin/sh -c "if test -f test.log; \ 53 then echo TEST FAILURE; exit 1; \ 54 else echo ALL DONE; \ 55 fi" 56 57$(SCRIPTS_TINY_OUT) $(NEW_TESTS_RES): $(VIMPROG) 58 59 60# Execute an individual new style test, e.g.: 61# make test_largefile 62$(NEW_TESTS): 63 rm -f $@.res test.log messages 64 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE) 65 @cat messages 66 @if test -f test.log; then \ 67 exit 1; \ 68 fi 69 70# Run only tests specific for Vim9 script 71test_vim9: 72 rm -f test_vim9_*.res test.log messages 73 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $(TEST_VIM9_RES) VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE) 74 @cat messages 75 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile report VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE) 76 @if test -f test.log; then \ 77 exit 1; \ 78 fi 79 80RM_ON_RUN = test.out X* viminfo 81RM_ON_START = test.ok benchmark.out 82RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in 83 84# Delete files that may interfere with running tests. This includes some files 85# that may result from working on the tests, not only from running them. 86clean: 87 -rm -rf *.out *.failed *.res *.rej *.orig XfakeHOME Xdir1 Xfind 88 -rm -f opt_test.vim test.log test_result.log messages 89 -rm -f $(RM_ON_RUN) $(RM_ON_START) 90 -rm -f valgrind.* 91 -rm -f asan.* 92 93nolog: 94 -rm -f test.log test_result.log messages 95 96 97# Tiny tests. Works even without the +eval feature. 98tinytests: $(SCRIPTS_TINY_OUT) 99 100.in.out: 101 -rm -rf $*.failed test.ok $(RM_ON_RUN) 102 cp $*.ok test.ok 103 @# Sleep a moment to avoid that the xterm title is messed up. 104 @# 200 msec is sufficient, but only modern sleep supports a fraction of 105 @# a second, fall back to a second if it fails. 106 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 107 $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL) 108 109 @# Check if the test.out file matches test.ok. 110 @/bin/sh -c "if test -f test.out; then \ 111 if diff test.out $*.ok; \ 112 then mv -f test.out $*.out; \ 113 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \ 114 fi \ 115 else echo $* NO OUTPUT >>test.log; \ 116 fi" 117 @/bin/sh -c "if test -f valgrind; then\ 118 mv -f valgrind valgrind.$*; \ 119 fi" 120 -rm -rf X* test.ok viminfo 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) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim 127 128newtests: newtestssilent 129 @/bin/sh -c "if test -f messages; then cat messages; fi" 130 131newtestssilent: $(NEW_TESTS_RES) 132 133 134.vim.res: 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: ../optiondefs.h gen_opt_test.vim 153 $(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../optiondefs.h 154 155test_xxd.res: 156 XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim 157 158test_bench_regexp.res: test_bench_regexp.vim 159 -rm -rf benchmark.out $(RM_ON_RUN) 160 @# Sleep a moment to avoid that the xterm title is messed up. 161 @# 200 msec is sufficient, but only modern sleep supports a fraction of 162 @# a second, fall back to a second if it fails. 163 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1" 164 $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL) 165 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi" 166