xref: /vim-8.2.3635/src/testdir/Makefile (revision fcfe1a9b)
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	$(RUN_VIMTEST) $(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	$(MAKE) -f Makefile $@.res
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
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
92test1.out: test1.in
93	-rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
94	$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
95	@/bin/sh -c "if test -f wrongtermsize; \
96		then echo; \
97		echo test1 FAILED - terminal size must be 80x24 or larger; \
98		echo; exit 1; \
99		elif diff test.out $*.ok; \
100		then mv -f test.out $*.out; \
101		else echo; \
102		echo test1 FAILED - Something basic is wrong; \
103		echo; exit 1; fi"
104	-rm -rf X* viminfo
105
106.in.out:
107	-rm -rf $*.failed test.ok $(RM_ON_RUN)
108	cp $*.ok test.ok
109	# Sleep a moment to avoid that the xterm title is messed up.
110	# 200 msec is sufficient, but only modern sleep supports a fraction of
111	# a second, fall back to a second if it fails.
112	@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
113	$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
114
115	# For flaky tests retry one time.  No tests at the moment.
116	#@/bin/sh -c "if test -f test.out -a $* = test61; then \
117	#	  if diff test.out $*.ok; \
118	#	  then echo flaky test ok first time; \
119	#	  else rm -rf $*.failed $(RM_ON_RUN); \
120	#		$(RUN_VIM) $*.in; \
121	#	  fi \
122	#	fi"
123
124	# Check if the test.out file matches test.ok.
125	@/bin/sh -c "if test -f test.out; then \
126		  if diff test.out $*.ok; \
127		  then mv -f test.out $*.out; \
128		  else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
129		  fi \
130		else echo $* NO OUTPUT >>test.log; \
131		fi"
132	@/bin/sh -c "if test -f valgrind; then\
133		  mv -f valgrind valgrind.$*; \
134		fi"
135	-rm -rf X* test.ok viminfo
136
137bench_re_freeze.out: bench_re_freeze.vim
138	-rm -rf benchmark.out $(RM_ON_RUN)
139	# Sleep a moment to avoid that the xterm title is messed up.
140	# 200 msec is sufficient, but only modern sleep supports a fraction of
141	# a second, fall back to a second if it fails.
142	@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
143	$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
144	@/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
145
146nolog:
147	-rm -f test.log messages
148
149
150# New style of tests uses Vim script with assert calls.  These are easier
151# to write and a lot easier to read and debug.
152# Limitation: Only works with the +eval feature.
153RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim
154
155newtests: newtestssilent
156	@/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages; fi"
157
158newtestssilent: $(NEW_TESTS_RES)
159
160
161.vim.res:
162	@echo "$(VIMPROG)" > vimcmd
163	@echo "$(RUN_VIMTEST)" >> vimcmd
164	$(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL)
165	@rm vimcmd
166
167test_gui.res: test_gui.vim
168	@echo "$(VIMPROG)" > vimcmd
169	@echo "$(RUN_GVIMTEST)" >> vimcmd
170	$(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $<
171	@rm vimcmd
172
173test_gui_init.res: test_gui_init.vim
174	@echo "$(VIMPROG)" > vimcmd
175	@echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd
176	$(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
177	@rm vimcmd
178
179opt_test.vim: ../option.c gen_opt_test.vim
180	$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c
181
182test_xxd.res:
183	XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim
184