blob: 6cc928c7f6b762d8695bef45bc67c24a15d8fb54 [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 Moolenaar3f12a242015-12-05 20:56:57 +01007# VIMPROG = ../gvim
8
Bram Moolenaarefa304d2014-04-01 14:08:28 +02009SCRIPTSOURCE = ../../runtime
Bram Moolenaar071d4272004-06-13 20:20:40 +000010
Bram Moolenaar0c77b7b2009-06-24 16:08:18 +000011# Uncomment this line to use valgrind for memory leaks and extra warnings.
12# The output goes into a file "valgrind.testN"
13# Vim should be compiled with EXITFREE to avoid false warnings.
14# This will make testing about 10 times as slow.
15# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$*
Bram Moolenaar4d2fffc2007-08-14 15:29:16 +000016
Bram Moolenaar40bbcee2015-12-28 22:24:41 +010017default: nongui
Bram Moolenaar680eeca2010-10-20 17:44:42 +020018
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010019# The list of tests is common to all systems.
20# This defines NEW_TESTS, SCRIPTS_ALL, SCRIPTS_MORE* and SCRIPTS_GUI.
21include Make_all.mak
Bram Moolenaar071d4272004-06-13 20:20:40 +000022
Bram Moolenaar43345542015-11-29 17:35:35 +010023
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010024SCRIPTS = $(SCRIPTS_ALL) \
25 $(SCRIPTS_MORE1) \
26 $(SCRIPTS_MORE2) \
27 $(SCRIPTS_MORE3) \
28 $(SCRIPTS_MORE4)
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
Bram Moolenaarfda37292014-11-05 14:27:36 +010030SCRIPTS_BENCH = bench_re_freeze.out
31
Bram Moolenaar43345542015-11-29 17:35:35 +010032.SUFFIXES: .in .out .res .vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000033
Bram Moolenaara6082432015-12-28 16:26:45 +010034nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report
Bram Moolenaar071d4272004-06-13 20:20:40 +000035
Bram Moolenaara6082432015-12-28 16:26:45 +010036gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000037
Bram Moolenaarfda37292014-11-05 14:27:36 +010038benchmark: $(SCRIPTS_BENCH)
39
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000040report:
Bram Moolenaar071d4272004-06-13 20:20:40 +000041 @echo
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000042 @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"
Bram Moolenaar071d4272004-06-13 20:20:40 +000047
Bram Moolenaara6082432015-12-28 16:26:45 +010048$(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)
Bram Moolenaar071d4272004-06-13 20:20:40 +000052
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010053RM_ON_RUN = test.out X* viminfo
Bram Moolenaarfda37292014-11-05 14:27:36 +010054RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmark.out
Bram Moolenaar3f12a242015-12-05 20:56:57 +010055RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f -u unix.vim -U NONE --noplugin -s dotest.in
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010056
Bram Moolenaar071d4272004-06-13 20:20:40 +000057clean:
Bram Moolenaar096c8bb2015-12-29 14:26:57 +010058 -rm -rf *.out *.failed *.res *.rej *.orig test.log messages $(RM_ON_RUN) $(RM_ON_START) valgrind.*
Bram Moolenaar071d4272004-06-13 20:20:40 +000059
60test1.out: test1.in
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020061 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010062 $(RUN_VIM) $*.in
Bram Moolenaarf7dc2b52014-03-12 15:50:22 +010063 @/bin/sh -c "if test -f wrongtermsize; \
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020064 then echo; \
65 echo test1 FAILED - terminal size must be 80x24 or larger; \
66 echo; exit 1; \
67 elif diff test.out $*.ok; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000068 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:
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010075 -rm -rf $*.failed test.ok $(RM_ON_RUN)
Bram Moolenaar071d4272004-06-13 20:20:40 +000076 cp $*.ok test.ok
Bram Moolenaar3f991522013-04-24 12:56:19 +020077 # 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"
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010081 -$(RUN_VIM) $*.in
82
83 # For flaky tests retry one time.
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.
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020093 @/bin/sh -c "if test -f test.out; then \
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000094 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; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000099 fi"
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +0200100 @/bin/sh -c "if test -f valgrind; then\
101 mv -f valgrind valgrind.$*; \
102 fi"
Bram Moolenaarb35c3382012-10-06 19:10:35 +0200103 -rm -rf X* test.ok viminfo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104
Bram Moolenaarfda37292014-11-05 14:27:36 +0100105bench_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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114nolog:
Bram Moolenaar096c8bb2015-12-29 14:26:57 +0100115 -rm -f test.log messages
Bram Moolenaar43345542015-11-29 17:35:35 +0100116
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.
Bram Moolenaar3f12a242015-12-05 20:56:57 +0100121RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f -u unix.vim -U NONE --noplugin
Bram Moolenaar43345542015-11-29 17:35:35 +0100122
123newtests: $(NEW_TESTS)
124
125.vim.res:
Bram Moolenaar096c8bb2015-12-29 14:26:57 +0100126 $(RUN_VIMTEST) -u NONE -S runtest.vim $*.vim