robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Jan Edmund Lazovim-patch:8.2.1525: messages from tests were not always displayed #41203cd02662ba3

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