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