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