blob: 6a9ef0f97406017822351819f22f8e53435136ca [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001#
Bram Moolenaar6ee10162007-07-26 20:58:42 +00002# Makefile to run all tests for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +00003#
4
Bram Moolenaar3f12a242015-12-05 20:56:57 +01005# Use console or GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +00006VIMPROG = ../vim
Bram Moolenaar29f9ed22018-04-10 19:20:31 +02007XXDPROG = ../xxd/xxd
Bram Moolenaar3f12a242015-12-05 20:56:57 +01008# VIMPROG = ../gvim
9
Bram Moolenaarefa304d2014-04-01 14:08:28 +020010SCRIPTSOURCE = ../../runtime
Bram Moolenaar071d4272004-06-13 20:20:40 +000011
Bram Moolenaare76d7a62018-09-21 16:37:25 +020012# Change this to empty to see the verbose output of tests.
13REDIR_TEST_TO_NULL = > /dev/null
14
Bram Moolenaar0c77b7b2009-06-24 16:08:18 +000015# Uncomment this line to use valgrind for memory leaks and extra warnings.
16# The output goes into a file "valgrind.testN"
17# Vim should be compiled with EXITFREE to avoid false warnings.
18# This will make testing about 10 times as slow.
Bram Moolenaaraf6c12c2016-05-28 13:40:10 +020019# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind.$*
Bram Moolenaar4d2fffc2007-08-14 15:29:16 +000020
Bram Moolenaar40bbcee2015-12-28 22:24:41 +010021default: nongui
Bram Moolenaar680eeca2010-10-20 17:44:42 +020022
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010023# The list of tests is common to all systems.
24# This defines NEW_TESTS, SCRIPTS_ALL, SCRIPTS_MORE* and SCRIPTS_GUI.
25include Make_all.mak
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
Bram Moolenaar43345542015-11-29 17:35:35 +010027
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010028SCRIPTS = $(SCRIPTS_ALL) \
29 $(SCRIPTS_MORE1) \
30 $(SCRIPTS_MORE2) \
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010031 $(SCRIPTS_MORE4)
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
Bram Moolenaarfda37292014-11-05 14:27:36 +010033SCRIPTS_BENCH = bench_re_freeze.out
34
Bram Moolenaar43345542015-11-29 17:35:35 +010035.SUFFIXES: .in .out .res .vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000036
Bram Moolenaara6082432015-12-28 16:26:45 +010037nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report
Bram Moolenaar071d4272004-06-13 20:20:40 +000038
Bram Moolenaara6082432015-12-28 16:26:45 +010039gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000040
Bram Moolenaarfda37292014-11-05 14:27:36 +010041benchmark: $(SCRIPTS_BENCH)
42
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000043report:
Bram Moolenaar071d4272004-06-13 20:20:40 +000044 @echo
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000045 @echo 'Test results:'
46 @/bin/sh -c "if test -f test.log; \
47 then cat test.log; echo TEST FAILURE; exit 1; \
48 else echo ALL DONE; \
49 fi"
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
Bram Moolenaara6082432015-12-28 16:26:45 +010051$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(VIMPROG)
52
53# Must run test1 first to create small.vim.
54$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
Bram Moolenaar071d4272004-06-13 20:20:40 +000055
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010056RM_ON_RUN = test.out X* viminfo
Bram Moolenaar1ce9a152018-07-14 21:48:46 +020057RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim test.ok benchmark.out
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +010058RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim $(NO_INITS) -s dotest.in
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010059
Bram Moolenaar071d4272004-06-13 20:20:40 +000060clean:
Bram Moolenaar65408f72017-03-07 21:31:27 +010061 -rm -rf *.out *.failed *.res *.rej *.orig opt_test.vim test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
Bram Moolenaar071d4272004-06-13 20:20:40 +000062
63test1.out: test1.in
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020064 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
Bram Moolenaare76d7a62018-09-21 16:37:25 +020065 $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
Bram Moolenaarf7dc2b52014-03-12 15:50:22 +010066 @/bin/sh -c "if test -f wrongtermsize; \
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020067 then echo; \
68 echo test1 FAILED - terminal size must be 80x24 or larger; \
69 echo; exit 1; \
70 elif diff test.out $*.ok; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000071 then mv -f test.out $*.out; \
72 else echo; \
73 echo test1 FAILED - Something basic is wrong; \
74 echo; exit 1; fi"
75 -rm -rf X* viminfo
76
77.in.out:
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010078 -rm -rf $*.failed test.ok $(RM_ON_RUN)
Bram Moolenaar071d4272004-06-13 20:20:40 +000079 cp $*.ok test.ok
Bram Moolenaar3f991522013-04-24 12:56:19 +020080 # Sleep a moment to avoid that the xterm title is messed up.
81 # 200 msec is sufficient, but only modern sleep supports a fraction of
82 # a second, fall back to a second if it fails.
83 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
Bram Moolenaare76d7a62018-09-21 16:37:25 +020084 $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010085
Bram Moolenaar89eaa412016-07-31 14:17:27 +020086 # For flaky tests retry one time. No tests at the moment.
87 #@/bin/sh -c "if test -f test.out -a $* = test61; then \
88 # if diff test.out $*.ok; \
89 # then echo flaky test ok first time; \
90 # else rm -rf $*.failed $(RM_ON_RUN); \
91 # $(RUN_VIM) $*.in; \
92 # fi \
93 # fi"
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010094
95 # Check if the test.out file matches test.ok.
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020096 @/bin/sh -c "if test -f test.out; then \
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000097 if diff test.out $*.ok; \
98 then mv -f test.out $*.out; \
99 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
100 fi \
101 else echo $* NO OUTPUT >>test.log; \
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102 fi"
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +0200103 @/bin/sh -c "if test -f valgrind; then\
104 mv -f valgrind valgrind.$*; \
105 fi"
Bram Moolenaarb35c3382012-10-06 19:10:35 +0200106 -rm -rf X* test.ok viminfo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107
Bram Moolenaarfda37292014-11-05 14:27:36 +0100108bench_re_freeze.out: bench_re_freeze.vim
109 -rm -rf benchmark.out $(RM_ON_RUN)
110 # Sleep a moment to avoid that the xterm title is messed up.
111 # 200 msec is sufficient, but only modern sleep supports a fraction of
112 # a second, fall back to a second if it fails.
113 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
Bram Moolenaare76d7a62018-09-21 16:37:25 +0200114 $(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
Bram Moolenaarfda37292014-11-05 14:27:36 +0100115 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
116
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117nolog:
Bram Moolenaar096c8bb2015-12-29 14:26:57 +0100118 -rm -f test.log messages
Bram Moolenaar43345542015-11-29 17:35:35 +0100119
120
121# New style of tests uses Vim script with assert calls. These are easier
122# to write and a lot easier to read and debug.
123# Limitation: Only works with the +eval feature.
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100124RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u unix.vim
Bram Moolenaar43345542015-11-29 17:35:35 +0100125
Bram Moolenaare7893a42016-01-06 21:23:56 +0100126newtests: newtestssilent
Bram Moolenaar933bef72018-09-20 21:39:33 +0200127 @/bin/sh -c "if test -f messages && grep -q 'SKIPPED\|FAILED' messages; then cat messages; fi"
Bram Moolenaare7893a42016-01-06 21:23:56 +0100128
129newtestssilent: $(NEW_TESTS)
130
Bram Moolenaar43345542015-11-29 17:35:35 +0100131
Bram Moolenaar63182052017-10-07 20:03:23 +0200132.vim.res: writevimcmd
133 @echo "$(VIMPROG)" > vimcmd
134 @echo "$(RUN_VIMTEST)" >> vimcmd
Bram Moolenaare76d7a62018-09-21 16:37:25 +0200135 $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL)
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100136 @rm vimcmd
137
138test_gui.res: test_gui.vim
Bram Moolenaar63182052017-10-07 20:03:23 +0200139 @echo "$(VIMPROG)" > vimcmd
140 @echo "$(RUN_GVIMTEST)" >> vimcmd
Bram Moolenaar8be2fbb2017-02-23 19:32:47 +0100141 $(RUN_VIMTEST) -u NONE $(NO_INITS) -S runtest.vim $<
142 @rm vimcmd
143
144test_gui_init.res: test_gui_init.vim
Bram Moolenaar63182052017-10-07 20:03:23 +0200145 @echo "$(VIMPROG)" > vimcmd
146 @echo "$(RUN_GVIMTEST_WITH_GVIMRC)" >> vimcmd
Bram Moolenaar87748452017-03-12 17:10:33 +0100147 $(RUN_VIMTEST) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
Bram Moolenaar66459b72016-08-06 19:01:55 +0200148 @rm vimcmd
Bram Moolenaar65408f72017-03-07 21:31:27 +0100149
150opt_test.vim: ../option.c gen_opt_test.vim
Bram Moolenaarbb962262017-03-08 00:01:35 +0100151 $(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../option.c
Bram Moolenaar29f9ed22018-04-10 19:20:31 +0200152
153test_xxd.res:
154 XXD=$(XXDPROG); export XXD; $(RUN_VIMTEST) $(NO_INITS) -S runtest.vim test_xxd.vim