xref: /vim-8.2.3635/src/testdir/Makefile (revision b477af22)
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# Uncomment this line to use valgrind for memory leaks and extra warnings.
13#   The output goes into a file "valgrind.testN"
14#   Vim should be compiled with EXITFREE to avoid false warnings.
15#   This will make testing about 10 times as slow.
16# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$*
17
18default: nongui
19
20# The list of tests is common to all systems.
21# This defines NEW_TESTS, SCRIPTS_ALL, SCRIPTS_MORE* and SCRIPTS_GUI.
22include Make_all.mak
23
24
25SCRIPTS = $(SCRIPTS_ALL) \
26	  $(SCRIPTS_MORE1) \
27	  $(SCRIPTS_MORE2) \
28	  $(SCRIPTS_MORE4)
29
30SCRIPTS_BENCH = bench_re_freeze.out
31
32.SUFFIXES: .in .out .res .vim
33
34nongui:	nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report
35
36gui:	nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report
37
38benchmark: $(SCRIPTS_BENCH)
39
40report:
41	@echo
42	@echo 'Test results:'
43	@/bin/sh -c "if test -f test.log; \
44		then cat test.log; echo TEST FAILURE; exit 1; \
45		else echo ALL DONE; \
46		fi"
47
48$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(VIMPROG)
49
50# Must run test1 first to create small.vim.
51$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
52
53RM_ON_RUN = test.out X* viminfo
54RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim test.ok benchmark.out
55RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in
56
57clean:
58	-rm -rf *.out *.failed *.res *.rej *.orig opt_test.vim test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
59
60test1.out: test1.in
61	-rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
62	$(RUN_VIM) $*.in
63	@/bin/sh -c "if test -f wrongtermsize; \
64		then echo; \
65		echo test1 FAILED - terminal size must be 80x24 or larger; \
66		echo; exit 1; \
67		elif diff test.out $*.ok; \
68		then mv -f test.out $*.out; \
69		else echo; \
70		echo test1 FAILED - Something basic is wrong; \
71		echo; exit 1; fi"
72	-rm -rf X* viminfo
73
74.in.out:
75	-rm -rf $*.failed test.ok $(RM_ON_RUN)
76	cp $*.ok test.ok
77	# Sleep a moment to avoid that the xterm title is messed up.
78	# 200 msec is sufficient, but only modern sleep supports a fraction of
79	# a second, fall back to a second if it fails.
80	@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
81	$(RUN_VIM) $*.in
82
83	# For flaky tests retry one time.  No tests at the moment.
84	#@/bin/sh -c "if test -f test.out -a $* = test61; then \
85	#	  if diff test.out $*.ok; \
86	#	  then echo flaky test ok first time; \
87	#	  else rm -rf $*.failed $(RM_ON_RUN); \
88	#		$(RUN_VIM) $*.in; \
89	#	  fi \
90	#	fi"
91
92	# Check if the test.out file matches test.ok.
93	@/bin/sh -c "if test -f test.out; then \
94		  if diff test.out $*.ok; \
95		  then mv -f test.out $*.out; \
96		  else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
97		  fi \
98		else echo $* NO OUTPUT >>test.log; \
99		fi"
100	@/bin/sh -c "if test -f valgrind; then\
101		  mv -f valgrind valgrind.$*; \
102		fi"
103	-rm -rf X* test.ok viminfo
104
105bench_re_freeze.out: bench_re_freeze.vim
106	-rm -rf benchmark.out $(RM_ON_RUN)
107	# Sleep a moment to avoid that the xterm title is messed up.
108	# 200 msec is sufficient, but only modern sleep supports a fraction of
109	# a second, fall back to a second if it fails.
110	@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
111	$(RUN_VIM) $*.in
112	@/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
113
114nolog:
115	-rm -f test.log messages
116
117
118# New style of tests uses Vim script with assert calls.  These are easier
119# to write and a lot easier to read and debug.
120# Limitation: Only works with the +eval feature.
121RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim
122
123newtests: newtestssilent
124	@/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages && if test -f test.log; then cat test.log; fi ; fi"
125
126newtestssilent: $(NEW_TESTS)
127
128
129.vim.res: writevimcmd
130	@echo "$(VIMPROG)" > vimcmd
131	@echo "$(RUN_VIMTEST)" >> vimcmd
132	$(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim
133	@rm vimcmd
134
135test_gui.res: test_gui.vim
136	@echo "$(VIMPROG)" > vimcmd
137	@echo "$(RUN_GVIMTEST)" >> vimcmd
138	$(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $<
139	@rm vimcmd
140
141test_gui_init.res: test_gui_init.vim
142	@echo "$(VIMPROG)" > vimcmd
143	@echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd
144	$(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
145	@rm vimcmd
146
147opt_test.vim: ../option.c gen_opt_test.vim
148	$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c
149
150test_xxd.res:
151	XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim
152