xref: /vim-8.2.3635/src/testdir/Makefile (revision 577fadfc)
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	@echo
53	@echo 'Test results:'
54	@/bin/sh -c "if test -f test.log; \
55		then cat test.log; echo TEST FAILURE; exit 1; \
56		else echo ALL DONE; \
57		fi"
58
59$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(VIMPROG)
60
61# Must run test1 first to create small.vim.
62$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(SCRIPTS_FIRST)
63
64
65# Execute an individual new style test, e.g.:
66# 	make test_largefile
67$(NEW_TESTS):
68	rm -f $@.res test.log messages
69	$(MAKE) -f Makefile $@.res
70	@if test -f test.log; then \
71		cat test.log; \
72	fi
73	cat messages
74
75RM_ON_RUN = test.out X* viminfo
76RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim test.ok benchmark.out
77RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in
78
79clean:
80	-rm -rf *.out *.failed *.res *.rej *.orig opt_test.vim test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
81
82test1.out: test1.in
83	-rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
84	$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
85	@/bin/sh -c "if test -f wrongtermsize; \
86		then echo; \
87		echo test1 FAILED - terminal size must be 80x24 or larger; \
88		echo; exit 1; \
89		elif diff test.out $*.ok; \
90		then mv -f test.out $*.out; \
91		else echo; \
92		echo test1 FAILED - Something basic is wrong; \
93		echo; exit 1; fi"
94	-rm -rf X* viminfo
95
96.in.out:
97	-rm -rf $*.failed test.ok $(RM_ON_RUN)
98	cp $*.ok test.ok
99	# Sleep a moment to avoid that the xterm title is messed up.
100	# 200 msec is sufficient, but only modern sleep supports a fraction of
101	# a second, fall back to a second if it fails.
102	@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
103	$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
104
105	# For flaky tests retry one time.  No tests at the moment.
106	#@/bin/sh -c "if test -f test.out -a $* = test61; then \
107	#	  if diff test.out $*.ok; \
108	#	  then echo flaky test ok first time; \
109	#	  else rm -rf $*.failed $(RM_ON_RUN); \
110	#		$(RUN_VIM) $*.in; \
111	#	  fi \
112	#	fi"
113
114	# Check if the test.out file matches test.ok.
115	@/bin/sh -c "if test -f test.out; then \
116		  if diff test.out $*.ok; \
117		  then mv -f test.out $*.out; \
118		  else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
119		  fi \
120		else echo $* NO OUTPUT >>test.log; \
121		fi"
122	@/bin/sh -c "if test -f valgrind; then\
123		  mv -f valgrind valgrind.$*; \
124		fi"
125	-rm -rf X* test.ok viminfo
126
127bench_re_freeze.out: bench_re_freeze.vim
128	-rm -rf benchmark.out $(RM_ON_RUN)
129	# Sleep a moment to avoid that the xterm title is messed up.
130	# 200 msec is sufficient, but only modern sleep supports a fraction of
131	# a second, fall back to a second if it fails.
132	@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
133	$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
134	@/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
135
136nolog:
137	-rm -f test.log messages
138
139
140# New style of tests uses Vim script with assert calls.  These are easier
141# to write and a lot easier to read and debug.
142# Limitation: Only works with the +eval feature.
143RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim
144
145newtests: newtestssilent
146	@/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages; fi"
147
148newtestssilent: $(NEW_TESTS_RES)
149
150
151.vim.res:
152	@echo "$(VIMPROG)" > vimcmd
153	@echo "$(RUN_VIMTEST)" >> vimcmd
154	$(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL)
155	@rm vimcmd
156
157test_gui.res: test_gui.vim
158	@echo "$(VIMPROG)" > vimcmd
159	@echo "$(RUN_GVIMTEST)" >> vimcmd
160	$(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $<
161	@rm vimcmd
162
163test_gui_init.res: test_gui_init.vim
164	@echo "$(VIMPROG)" > vimcmd
165	@echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd
166	$(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
167	@rm vimcmd
168
169opt_test.vim: ../option.c gen_opt_test.vim
170	$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c
171
172test_xxd.res:
173	XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim
174