Makefile (5044B)
1 # vim: noet ts=8 2 # Makefile to run all tests for Vim 3 # 4 5 ifeq ($(OS),Windows_NT) 6 NVIM_PRG ?= ../../../build/bin/nvim.exe 7 else 8 NVIM_PRG ?= ../../../build/bin/nvim 9 endif 10 ROOT := ../../.. 11 12 export SHELL := sh 13 export NVIM_PRG := $(NVIM_PRG) 14 export TMPDIR := $(abspath X-test-tmpdir) 15 16 ifeq ($(OS),Windows_NT) 17 FIXFF = fixff 18 else 19 FIXFF = 20 endif 21 22 # Tests using runtest.vim. 23 NEW_TESTS_ALOT := test_alot_utf8 test_alot test_alot_latin 24 NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT))) 25 # Ignored tests. 26 # test_largefile: uses too much resources to run on CI. 27 NEW_TESTS_IGNORE := \ 28 test_largefile \ 29 30 NEW_TESTS := $(sort $(basename $(notdir $(wildcard test_*.vim)))) 31 NEW_TESTS_RES := $(addsuffix .res,$(filter-out $(NEW_TESTS_ALOT) $(NEW_TESTS_IN_ALOT) $(NEW_TESTS_IGNORE),$(NEW_TESTS)) $(NEW_TESTS_ALOT)) 32 33 34 ifdef VALGRIND_GDB 35 VGDB := --vgdb=yes \ 36 --vgdb-error=0 37 endif 38 39 ifdef USE_VALGRIND 40 VALGRIND_TOOL := --tool=memcheck \ 41 --leak-check=yes \ 42 --track-origins=yes 43 # VALGRIND_TOOL := exp-sgcheck 44 TOOL := valgrind -q \ 45 -q \ 46 $(VALGRIND_TOOL) \ 47 --suppressions=../../../src/.valgrind.supp \ 48 --error-exitcode=123 \ 49 --log-file=valgrind-\%p.$* \ 50 $(VGDB) \ 51 --trace-children=yes 52 else 53 ifdef USE_GDB 54 TOOL = gdb --args 55 endif 56 endif 57 58 default: nongui 59 60 nongui: nolog $(FIXFF) newtests report 61 62 .gdbinit: 63 @echo "[OLDTEST-PREP] Setting up .gdbinit" 64 @echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit 65 66 report: 67 $(NVIM_PRG) -u NONE $(NO_INITS) -S summarize.vim messages 68 @echo 69 @echo 'Test results:' 70 @cat test_result.log 71 @/bin/sh -c "if test -f test.log; \ 72 then echo TEST FAILURE; exit 1; \ 73 else echo ALL DONE; \ 74 fi" 75 @rm -f starttime 76 77 test1.out: $(NVIM_PRG) 78 79 NO_PLUGINS = --noplugin --headless 80 # In vim, if the -u command line option is specified, compatible is turned on 81 # and viminfo is not read. Unlike vim, neovim reads viminfo and requires the 82 # -i command line option. 83 NO_INITS = -U NONE -i NONE $(NO_PLUGINS) 84 85 # TODO: find a way to avoid changing the distributed files. 86 fixff: 87 -$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \ 88 *.in *.ok 89 -$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \ 90 dotest.in 91 92 # File to delete when testing starts 93 CLEANUP_FILES = test.log messages starttime 94 95 # Execute an individual new style test, e.g.: 96 # make test_largefile 97 $(NEW_TESTS): 98 rm -f $@.res $(CLEANUP_FILES) 99 @MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res 100 @cat messages 101 @if test -f test.log; then \ 102 exit 1; \ 103 fi 104 105 RM_ON_RUN := test.out X* viminfo 106 RM_ON_START := test.ok 107 RUN_VIM := $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in 108 109 # Delete files that may interfere with running tests. This includes some files 110 # that may result from working on the tests, not only from running them. 111 CLEAN_FILES := *.out \ 112 *.failed \ 113 *.res \ 114 *.rej \ 115 *.orig \ 116 *.tlog \ 117 opt_test.vim \ 118 test_result.log \ 119 gen_opt_test.log \ 120 $(CLEANUP_FILES) \ 121 $(RM_ON_RUN) \ 122 $(RM_ON_START) \ 123 valgrind.* \ 124 .*.swp \ 125 .*.swo \ 126 .gdbinit \ 127 $(TMPDIR) \ 128 del \ 129 $(ROOT)/runtime/doc/.*.swp 130 clean: 131 $(RM) -rf $(CLEAN_FILES) 132 133 test1.out: .gdbinit test1.in 134 @echo "[OLDTEST-PREP] Running test1" 135 @rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize 136 @mkdir -p $(TMPDIR) 137 @/bin/sh runnvim.sh $(ROOT) $(NVIM_PRG) $* $(RUN_VIM) $*.in 138 @rm -f wrongtermsize 139 @rm -rf X* viminfo 140 141 nolog: 142 @echo "[OLDTEST-PREP] Removing test.log and messages" 143 @rm -f test_result.log $(CLEANUP_FILES) 144 145 146 # New style of tests uses Vim script with assert calls. These are easier 147 # to write and a lot easier to read and debug. 148 # Limitation: Only works with the +eval feature. 149 RUN_VIMTEST = $(TOOL) $(NVIM_PRG) -u unix.vim 150 151 newtests: newtestssilent 152 @/bin/sh -c "if test -f messages && grep -q 'FAILED' messages; then \ 153 cat messages && cat test.log; \ 154 fi" 155 156 newtestssilent: $(NEW_TESTS_RES) 157 158 GEN_OPT_DEPS = gen_opt_test.vim ../../../src/nvim/options.lua ../../../runtime/doc/options.txt 159 160 opt_test.vim: $(GEN_OPT_DEPS) 161 $(NVIM_PRG) -e -s -u NONE $(NO_INITS) -S $(GEN_OPT_DEPS) 162 @if test -f gen_opt_test.log; then \ 163 cat gen_opt_test.log; \ 164 exit 1; \ 165 fi 166 167 # Explicit dependencies. 168 test_options_all.res: opt_test.vim 169 170 %.res: %.vim .gdbinit 171 @echo "[OLDTEST] Running" $* 172 @rm -rf $*.failed test.ok $(RM_ON_RUN) 173 @mkdir -p $(TMPDIR) 174 @/bin/sh runnvim.sh $(ROOT) $(NVIM_PRG) $* $(RUN_VIMTEST) $(NO_INITS) -u NONE --cmd "set shortmess-=F" -S runtest.vim $*.vim