patch 7.4.944
Problem: Writing tests for Vim script is hard.
Solution: Add assertEqual(), assertFalse() and assertTrue() functions. Add
the v:errors variable. Add the runtest script. Add a first new
style test script.
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
index dba031f..03384aa 100644
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -68,15 +68,17 @@
test_utf8.out \
test_writefile.out
+NEW_TESTS = test_assert.res
+
SCRIPTS_GUI = test16.out
SCRIPTS_BENCH = bench_re_freeze.out
-.SUFFIXES: .in .out
+.SUFFIXES: .in .out .res .vim
-nongui: nolog $(SCRIPTS) report
+nongui: nolog $(SCRIPTS) newtests report
-gui: nolog $(SCRIPTS) $(SCRIPTS_GUI) report
+gui: nolog $(SCRIPTS) $(SCRIPTS_GUI) newtests report
benchmark: $(SCRIPTS_BENCH)
@@ -95,7 +97,7 @@
RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in
clean:
- -rm -rf *.out *.failed *.rej *.orig test.log $(RM_ON_RUN) $(RM_ON_START) valgrind.*
+ -rm -rf *.out *.failed *.res *.rej *.orig test.log $(RM_ON_RUN) $(RM_ON_START) valgrind.*
test1.out: test1.in
-rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize
@@ -157,3 +159,14 @@
nolog:
-rm -f test.log
+
+
+# New style of tests uses Vim script with assert calls. These are easier
+# to write and a lot easier to read and debug.
+# Limitation: Only works with the +eval feature.
+RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin
+
+newtests: $(NEW_TESTS)
+
+.vim.res:
+ $(RUN_VIMTEST) -u runtest.vim $*.vim