blob: ade975271c3143d131191c564be0eb8214ea4807 [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 Moolenaara6082432015-12-28 16:26:45 +010033nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report
Bram Moolenaar071d4272004-06-13 20:20:40 +000034
Bram Moolenaara6082432015-12-28 16:26:45 +010035gui: nolog $(SCRIPTS_FIRST) $(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 Moolenaara6082432015-12-28 16:26:45 +010047$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(VIMPROG)
48
49# Must run test1 first to create small.vim.
50$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
Bram Moolenaar071d4272004-06-13 20:20:40 +000051
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010052RM_ON_RUN = test.out X* viminfo
Bram Moolenaarfda37292014-11-05 14:27:36 +010053RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok benchmark.out
Bram Moolenaar3f12a242015-12-05 20:56:57 +010054RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f -u unix.vim -U NONE --noplugin -s dotest.in
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010055
Bram Moolenaar071d4272004-06-13 20:20:40 +000056clean:
Bram Moolenaar43345542015-11-29 17:35:35 +010057 -rm -rf *.out *.failed *.res *.rej *.orig test.log $(RM_ON_RUN) $(RM_ON_START) valgrind.*
Bram Moolenaar071d4272004-06-13 20:20:40 +000058
59test1.out: test1.in
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020060 -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010061 $(RUN_VIM) $*.in
Bram Moolenaarf7dc2b52014-03-12 15:50:22 +010062 @/bin/sh -c "if test -f wrongtermsize; \
Bram Moolenaar6848c8b2013-09-22 15:03:38 +020063 then echo; \
64 echo test1 FAILED - terminal size must be 80x24 or larger; \
65 echo; exit 1; \
66 elif diff test.out $*.ok; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000067 then mv -f test.out $*.out; \
68 else echo; \
69 echo test1 FAILED - Something basic is wrong; \
70 echo; exit 1; fi"
71 -rm -rf X* viminfo
72
73.in.out:
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010074 -rm -rf $*.failed test.ok $(RM_ON_RUN)
Bram Moolenaar071d4272004-06-13 20:20:40 +000075 cp $*.ok test.ok
Bram Moolenaar3f991522013-04-24 12:56:19 +020076 # Sleep a moment to avoid that the xterm title is messed up.
77 # 200 msec is sufficient, but only modern sleep supports a fraction of
78 # a second, fall back to a second if it fails.
79 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
Bram Moolenaar60ec5f32012-12-05 18:21:32 +010080 -$(RUN_VIM) $*.in
81
82 # For flaky tests retry one time.
83 @/bin/sh -c "if test -f test.out -a $* = test61; then \
84 if diff test.out $*.ok; \
85 then echo flaky test ok first time; \
86 else rm -rf $*.failed $(RM_ON_RUN); \
87 $(RUN_VIM) $*.in; \
88 fi \
89 fi"
90
91 # Check if the test.out file matches test.ok.
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020092 @/bin/sh -c "if test -f test.out; then \
Bram Moolenaar5313dcb2005-02-22 08:56:13 +000093 if diff test.out $*.ok; \
94 then mv -f test.out $*.out; \
95 else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
96 fi \
97 else echo $* NO OUTPUT >>test.log; \
Bram Moolenaar071d4272004-06-13 20:20:40 +000098 fi"
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +020099 @/bin/sh -c "if test -f valgrind; then\
100 mv -f valgrind valgrind.$*; \
101 fi"
Bram Moolenaarb35c3382012-10-06 19:10:35 +0200102 -rm -rf X* test.ok viminfo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103
Bram Moolenaarfda37292014-11-05 14:27:36 +0100104bench_re_freeze.out: bench_re_freeze.vim
105 -rm -rf benchmark.out $(RM_ON_RUN)
106 # Sleep a moment to avoid that the xterm title is messed up.
107 # 200 msec is sufficient, but only modern sleep supports a fraction of
108 # a second, fall back to a second if it fails.
109 @-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
110 -$(RUN_VIM) $*.in
111 @/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
112
Bram Moolenaar071d4272004-06-13 20:20:40 +0000113nolog:
Bram Moolenaarf2e53da2008-09-10 16:26:04 +0000114 -rm -f test.log
Bram Moolenaar43345542015-11-29 17:35:35 +0100115
116
117# New style of tests uses Vim script with assert calls. These are easier
118# to write and a lot easier to read and debug.
119# Limitation: Only works with the +eval feature.
Bram Moolenaar3f12a242015-12-05 20:56:57 +0100120RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -f -u unix.vim -U NONE --noplugin
Bram Moolenaar43345542015-11-29 17:35:35 +0100121
122newtests: $(NEW_TESTS)
123
124.vim.res:
Bram Moolenaar57d79712015-12-28 14:04:47 +0100125 $(RUN_VIMTEST) -S runtest.vim $*.vim