Skip to content

Commit

Permalink
Run tiny tests also on nongui and gui tests, etc.
Browse files Browse the repository at this point in the history
* Add tinytests target.
* Make 3 makefiles more similar.
  - Reorder some rules.
  - Add `$(NEW_TESTS)` target to Make_dos.mak and Make_ming.mak.
  • Loading branch information
k-takata committed Aug 12, 2020
1 parent 014bbd2 commit 4d558aa
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 73 deletions.
114 changes: 67 additions & 47 deletions src/testdir/Make_dos.mak
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,24 @@ default: nongui

!include Make_all.mak

# Explicit dependencies.
test_options.res test_alot.res: opt_test.vim

TEST_OUTFILES = $(SCRIPTS_TINY_OUT)
DOSTMP = dostmp
DOSTMP_OUTFILES = $(TEST_OUTFILES:test=dostmp\test)
DOSTMP_INFILES = $(DOSTMP_OUTFILES:.out=.in)

.SUFFIXES: .in .out .res .vim

tiny: nolog $(SCRIPTS_TINY_OUT) report
nongui: nolog tinytests newtests report

nongui: nolog newtests report
gui: nolog tinytests newtests report

gui: nolog newtests report
tiny: nolog tinytests report

benchmark: $(SCRIPTS_BENCH)

# Copy the input files to dostmp, changing the fileformat to dos.
$(DOSTMP_INFILES): $(*B).in
if not exist $(DOSTMP)\NUL md $(DOSTMP)
if exist $@ del $@
$(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $(*B).in

# For each input file dostmp/test99.in run the tests.
# This moves test99.in to test99.in.bak temporarily.
$(TEST_OUTFILES): $(DOSTMP)\$(*B).in
-@if exist test.out DEL test.out
-@if exist $(DOSTMP)\$(*B).out DEL $(DOSTMP)\$(*B).out
move $(*B).in $(*B).in.bak > nul
copy $(DOSTMP)\$(*B).in $(*B).in > nul
copy $(*B).ok test.ok > nul
$(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $(*B).in
-@if exist test.out MOVE /y test.out $(DOSTMP)\$(*B).out > nul
-@if exist $(*B).in.bak move /y $(*B).in.bak $(*B).in > nul
-@if exist test.ok del test.ok
-@if exist Xdir1 rd /s /q Xdir1
-@if exist Xfind rd /s /q Xfind
-@if exist XfakeHOME rd /s /q XfakeHOME
-@del X*
-@if exist viminfo del viminfo
$(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
$(DOSTMP)\$(*B).out
@diff test.out $*.ok & if errorlevel 1 \
( move /y test.out $*.failed > nul \
& del $(DOSTMP)\$(*B).out \
& echo $* FAILED >> test.log ) \
else ( move /y test.out $*.out > nul )

report:
@rem without the +eval feature test_result.log is a copy of test.log
@if exist test.log ( copy /y test.log test_result.log > nul ) \
Expand All @@ -66,10 +38,24 @@ report:
@if exist test.log ( echo TEST FAILURE & exit /b 1 ) \
else ( echo ALL DONE )


# Execute an individual new style test, e.g.:
# nmake -f Make_dos.mak test_largefile
$(NEW_TESTS):
-if exist $@.res del $@.res
-if exist test.log del test.log
-if exist messages del messages
@$(MAKE) -nologo -f Make_dos.mak $@.res VIMPROG=$(VIMPROG)
@type messages
@if exist test.log exit 1


# Delete files that may interfere with running tests. This includes some files
# that may result from working on the tests, not only from running them.
clean:
-del *.out
-del *.failed
-del *.res
-if exist *.out $(DEL) *.out
-if exist *.failed $(DEL) *.failed
-if exist *.res $(DEL) *.res
-if exist $(DOSTMP) rd /s /q $(DOSTMP)
-if exist test.in del test.in
-if exist test.ok del test.ok
Expand All @@ -80,8 +66,8 @@ clean:
-if exist Xdir1 rd /s /q Xdir1
-if exist Xfind rd /s /q Xfind
-if exist XfakeHOME rd /s /q XfakeHOME
-del X*
-for /d %i in (X*) do @rmdir /s/q %i
-if exist X* $(DEL) X*
-for /d %i in (X*) do @rd /s/q %i
-if exist viminfo del viminfo
-if exist test.log del test.log
-if exist test_result.log del test_result.log
Expand All @@ -94,12 +80,41 @@ nolog:
-if exist test_result.log del test_result.log
-if exist messages del messages

test_bench_regexp.res: test_bench_regexp.vim
-if exist benchmark.out del benchmark.out
@echo $(VIMPROG) > vimcmd
$(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
@del vimcmd
@IF EXIST benchmark.out ( type benchmark.out )

# Tiny tests. Works even without the +eval feature.
tinytests: $(SCRIPTS_TINY_OUT)

# Copy the input files to dostmp, changing the fileformat to dos.
$(DOSTMP_INFILES): $(*B).in
if not exist $(DOSTMP)\NUL md $(DOSTMP)
if exist $@ del $@
$(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $(*B).in

# For each input file dostmp/test99.in run the tests.
# This moves test99.in to test99.in.bak temporarily.
$(TEST_OUTFILES): $(DOSTMP)\$(*B).in
-@if exist test.out DEL test.out
-@if exist $(DOSTMP)\$(*B).out DEL $(DOSTMP)\$(*B).out
move $(*B).in $(*B).in.bak > nul
copy $(DOSTMP)\$(*B).in $(*B).in > nul
copy $(*B).ok test.ok > nul
$(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $(*B).in
-@if exist test.out MOVE /y test.out $(DOSTMP)\$(*B).out > nul
-@if exist $(*B).in.bak move /y $(*B).in.bak $(*B).in > nul
-@if exist test.ok del test.ok
-@if exist Xdir1 rd /s /q Xdir1
-@if exist Xfind rd /s /q Xfind
-@if exist XfakeHOME rd /s /q XfakeHOME
-@del X*
-@if exist viminfo del viminfo
$(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=unix|f test.out|wq" \
$(DOSTMP)\$(*B).out
@diff test.out $*.ok & if errorlevel 1 \
( move /y test.out $*.failed > nul \
& del $(DOSTMP)\$(*B).out \
& echo $* FAILED >> test.log ) \
else ( move /y test.out $*.out > nul )


# New style of tests uses Vim script with assert calls. These are easier
# to write and a lot easier to read and debug.
Expand All @@ -125,7 +140,12 @@ test_gui_init.res: test_gui_init.vim
$(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $*.vim
@del vimcmd

test_options.res test_alot.res: opt_test.vim

opt_test.vim: ../optiondefs.h gen_opt_test.vim
$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../optiondefs.h

test_bench_regexp.res: test_bench_regexp.vim
-if exist benchmark.out del benchmark.out
@echo $(VIMPROG) > vimcmd
$(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
@del vimcmd
@IF EXIST benchmark.out ( type benchmark.out )
62 changes: 46 additions & 16 deletions src/testdir/Make_ming.mak
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ default: nongui

include Make_all.mak

# Explicit dependencies.
test_options.res test_alot.res: opt_test.vim

TEST_OUTFILES = $(SCRIPTS_TINY_OUT)
DOSTMP = dostmp
# Keep $(DOSTMP)/*.in
.PRECIOUS: $(patsubst %.out, $(DOSTMP)/%.in, $(TEST_OUTFILES))

.SUFFIXES: .in .out .res .vim

tiny: nolog $(SCRIPTS_TINY_OUT) report
nongui: nolog tinytests newtests report

nongui: nolog newtests report
gui: nolog tinytests newtests report

gui: nolog newtests report
tiny: nolog tinytests report

benchmark: $(SCRIPTS_BENCH)

Expand All @@ -47,10 +50,25 @@ report:
@if exist test.log ( echo TEST FAILURE & exit /b 1 ) \
else ( echo ALL DONE )


# Execute an individual new style test, e.g.:
# mingw32-make -f Make_ming.mak test_largefile
$(NEW_TESTS):
-if exist $@.res del $@.res
-if exist test.log del test.log
-if exist messages del messages
@$(MAKE) -f Make_ming.mak $@.res VIMPROG=$(VIMPROG) --no-print-directory
@type messages
@if exist test.log exit 1


# Delete files that may interfere with running tests. This includes some files
# that may result from working on the tests, not only from running them.
clean:
-@if exist *.out $(DEL) *.out
-@if exist *.failed $(DEL) *.failed
-@if exist *.res $(DEL) *.res
-@if exist $(DOSTMP) rd /s /q $(DOSTMP)
-@if exist test.in $(DEL) test.in
-@if exist test.ok $(DEL) test.ok
-@if exist small.vim $(DEL) small.vim
Expand All @@ -61,17 +79,31 @@ clean:
-@if exist Xfind $(DELDIR) Xfind
-@if exist XfakeHOME $(DELDIR) XfakeHOME
-@if exist X* $(DEL) X*
-@for /d %%i in (X*) do @rd /s/q %%i
-@if exist viminfo $(DEL) viminfo
-@if exist test.log $(DEL) test.log
-@if exist test_result.log del test_result.log
-@if exist messages $(DEL) messages
-@if exist benchmark.out del benchmark.out
-@if exist opt_test.vim $(DEL) opt_test.vim

nolog:
-@if exist test.log $(DEL) test.log
-@if exist test_result.log del test_result.log
-@if exist messages $(DEL) messages


# Tiny tests. Works even without the +eval feature.
tinytests: $(SCRIPTS_TINY_OUT)

# Copy the input files to dostmp, changing the fileformat to dos.
$(DOSTMP)/%.in : %.in
if not exist $(DOSTMP)\nul mkdir $(DOSTMP)
if not exist $@ $(DEL) $@
$(VIMPROG) -u dos.vim $(NO_INITS) "+set ff=dos|f $@|wq" $<

# For each input file dostmp/test99.in run the tests.
# This moves test99.in to test99.in.bak temporarily.
%.out : $(DOSTMP)/%.in
-@if exist test.out $(DEL) test.out
-@if exist $(DOSTMP)\$@ $(DEL) $(DOSTMP)\$@
Expand All @@ -95,22 +127,15 @@ $(DOSTMP)/%.in : %.in
& echo $(basename $@) FAILED >> test.log ) \
else ( $(MV) test.out $(basename $@).out > NUL )

nolog:
-@if exist test.log $(DEL) test.log
-@if exist messages $(DEL) messages

test_bench_regexp.res: test_bench_regexp.vim
-$(DEL) benchmark.out
@echo $(VIMPROG) > vimcmd
$(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
@$(DEL) vimcmd
$(CAT) benchmark.out

# 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.

newtests: $(NEW_TESTS_RES)
newtests: newtestssilent
@if exist messages (findstr "SKIPPED FAILED" messages > nul) && type messages

newtestssilent: $(NEW_TESTS_RES)

.vim.res:
@echo $(VIMPROG) > vimcmd
Expand All @@ -127,7 +152,12 @@ test_gui_init.res: test_gui_init.vim
$(VIMPROG) -u gui_preinit.vim -U gui_init.vim $(NO_PLUGINS) -S runtest.vim $<
@$(DEL) vimcmd

test_options.res test_alot.res: opt_test.vim

opt_test.vim: ../optiondefs.h gen_opt_test.vim
$(VIMPROG) -u NONE -S gen_opt_test.vim --noplugin --not-a-term ../optiondefs.h

test_bench_regexp.res: test_bench_regexp.vim
-$(DEL) benchmark.out
@echo $(VIMPROG) > vimcmd
$(VIMPROG) -u NONE $(NO_INITS) -S runtest.vim $*.vim
@$(DEL) vimcmd
$(CAT) benchmark.out
24 changes: 14 additions & 10 deletions src/testdir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ test_options.res test_alot.res: opt_test.vim

.SUFFIXES: .in .out .res .vim

tiny: nolog $(SCRIPTS_TINY_OUT) report
nongui: nolog tinytests newtests report

nongui: nolog newtests report
gui: nolog tinytests newtests report

gui: nolog newtests report
tiny: nolog tinytests report

benchmark: $(SCRIPTS_BENCH)

Expand All @@ -54,7 +54,7 @@ report:
else echo ALL DONE; \
fi"

$(NEW_TESTS_RES): $(VIMPROG)
$(SCRIPTS_TINY_OUT) $(NEW_TESTS_RES): $(VIMPROG)


# Execute an individual new style test, e.g.:
Expand Down Expand Up @@ -90,6 +90,13 @@ clean:
-rm -f valgrind.*
-rm -f asan.*

nolog:
-rm -f test.log test_result.log messages


# Tiny tests. Works even without the +eval feature.
tinytests: $(SCRIPTS_TINY_OUT)

.in.out:
-rm -rf $*.failed test.ok $(RM_ON_RUN)
cp $*.ok test.ok
Expand All @@ -112,9 +119,6 @@ clean:
fi"
-rm -rf X* test.ok viminfo

nolog:
-rm -f test.log messages


# New style of tests uses Vim script with assert calls. These are easier
# to write and a lot easier to read and debug.
Expand Down Expand Up @@ -153,9 +157,9 @@ test_xxd.res:

test_bench_regexp.res: test_bench_regexp.vim
-rm -rf benchmark.out $(RM_ON_RUN)
# Sleep a moment to avoid that the xterm title is messed up.
# 200 msec is sufficient, but only modern sleep supports a fraction of
# a second, fall back to a second if it fails.
@# Sleep a moment to avoid that the xterm title is messed up.
@# 200 msec is sufficient, but only modern sleep supports a fraction of
@# a second, fall back to a second if it fails.
@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
$(RUN_VIMTEST) $(NO_INITS) -S runtest.vim $*.vim $(REDIR_TEST_TO_NULL)
@/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"

0 comments on commit 4d558aa

Please sign in to comment.