blob: c8ff87b3cfcd9d73563565d94e9279cc2d87effe [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 Moolenaar680eeca2010-10-20 17:44:42 +020017
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010018# The list of tests is common to all systems.
19# This defines NEW_TESTS, SCRIPTS_ALL, SCRIPTS_MORE* and SCRIPTS_GUI.
20include Make_all.mak
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
Bram Moolenaar43345542015-11-29 17:35:35 +010022
Bram Moolenaar7b6156f2015-12-28 16:01:26 +010023SCRIPTS = $(SCRIPTS_ALL) \
24 $(SCRIPTS_MORE1) \
25 $(SCRIPTS_MORE2) \
26 $(SCRIPTS_MORE3) \
27 $(SCRIPTS_MORE4)
Bram Moolenaar071d4272004-06-13 20:20:40 +000028
Bram Moolenaarfda37292014-11-05 14:27:36 +010029SCRIPTS_BENCH = bench_re_freeze.out
30
Bram Moolenaar43345542015-11-29 17:35:35 +010031.SUFFIXES: .in .out .res .vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
Bram Moolenaar43345542015-11-29 17:35:35 +010033nongui: nolog $(SCRIPTS) newtests report
Bram Moolenaar071d4272004-06-13 20:20:40 +000034
Bram Moolenaar43345542015-11-29 17:35:35 +010035gui: nolog $(SCRIPTS) $(SCRIPTS_GUI) newtests report
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000036
Bram Moolenaarfda37292014-11-05 14:27:36 +010037benchmark: $(SCRIPTS_BENCH)
38
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000039report:
Bram Moolenaar071d4272004-06-13 20:20:40 +000040 @echo
Bram Moolenaarf2e53da2008-09-10 16:26:04 +000041 @echo 'Test results:'
42 @/bin/sh -c "if test -f test.log; \
43 then cat test.log; echo TEST FAILURE; exit 1; \
44 else echo ALL DONE; \
45 fi"
Bram Moolenaar071d4272004-06-13 20:20:40 +000046
Bram Moolenaar3f12a242015-12-05 20:56:57 +010047$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(VIMPROG)
Bram Moolenaar071d4272004-06-13 20:20:40 +000048
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010049RM_ON_RUN = test.out X* viminfo
Bram Moolenaarfda37292014-11-05 14:27:36 +010050RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmark.out
Bram Moolenaar3f12a242015-12-05 20:56:57 +010051RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f -u unix.vim -U NONE --noplugin -s dotest.in
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010052
Bram Moolenaar071d4272004-06-13 20:20:40 +000053clean:
Bram Moolenaar43345542015-11-29 17:35:35 +010054 -rm -rf *.out *.failed *.res *.rej *.orig test.log $(RM_ON_RUN) $(RM_ON_START) valgrind.*
Bram Moolenaar071d4272004-06-13 20:20:40 +000055
56test1.out: test1.in
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020057 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010058 $(RUN_VIM) $*.in
Bram Moolenaarf7dc2b52014-03-12 15:50:22 +010059 @/bin/sh -c "if test -f wrongtermsize; \
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020060 then echo; \
61 echo test1 FAILED - terminal size must be 80x24 or larger; \
62 echo; exit 1; \
63 elif diff test.out $*.ok; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000064 then mv -f test.out $*.out; \
65 else echo; \
66 echo test1 FAILED - Something basic is wrong; \
67 echo; exit 1; fi"
68 -rm -rf X* viminfo
69
70.in.out:
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010071 -rm -rf $*.failed test.ok $(RM_ON_RUN)
Bram Moolenaar071d4272004-06-13 20:20:40 +000072 cp $*.ok test.ok
Bram Moolenaar3f991522013-04-24 12:56:19 +020073 # Sleep a moment to avoid that the xterm title is messed up.
74 # 200 msec is sufficient, but only modern sleep supports a fraction of
75 # a second, fall back to a second if it fails.
76 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010077 -$(RUN_VIM) $*.in
78
79 # For flaky tests retry one time.
80 @/bin/sh -c "if test -f test.out -a $* = test61; then \
81 if diff test.out $*.ok; \
82 then echo flaky test ok first time; \
83 else rm -rf $*.failed $(RM_ON_RUN); \
84 $(RUN_VIM) $*.in; \
85 fi \
86 fi"
87
88 # Check if the test.out file matches test.ok.
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020089 @/bin/sh -c "if test -f test.out; then \
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000090 if diff test.out $*.ok; \
91 then mv -f test.out $*.out; \
92 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
93 fi \
94 else echo $* NO OUTPUT >>test.log; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000095 fi"
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020096 @/bin/sh -c "if test -f valgrind; then\
97 mv -f valgrind valgrind.$*; \
98 fi"
Bram Moolenaarb35c3382012-10-06 19:10:35 +020099 -rm -rf X* test.ok viminfo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100
Bram Moolenaarfda37292014-11-05 14:27:36 +0100101bench_re_freeze.out: bench_re_freeze.vim
102 -rm -rf benchmark.out $(RM_ON_RUN)
103 # Sleep a moment to avoid that the xterm title is messed up.
104 # 200 msec is sufficient, but only modern sleep supports a fraction of
105 # a second, fall back to a second if it fails.
106 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
107 -$(RUN_VIM) $*.in
108 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
109
Bram Moolenaar071d4272004-06-13 20:20:40 +0000110nolog:
Bram Moolenaarf2e53da2008-09-10 16:26:04 +0000111 -rm -f test.log
Bram Moolenaar43345542015-11-29 17:35:35 +0100112
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.
Bram Moolenaar3f12a242015-12-05 20:56:57 +0100117RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f -u unix.vim -U NONE --noplugin
Bram Moolenaar43345542015-11-29 17:35:35 +0100118
119newtests: $(NEW_TESTS)
120
121.vim.res:
Bram Moolenaar57d79712015-12-28 14:04:47 +0100122 $(RUN_VIMTEST) -S runtest.vim $*.vim