changeset 30449:55aa44dd59ef v9.0.0560

patch 9.0.0560: elapsed time since testing started is not visible Commit: https://github.com/vim/vim/commit/b9093d50098ccff3848c2a404b9d0324a074c7b7 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 23 19:42:31 2022 +0100 patch 9.0.0560: elapsed time since testing started is not visible Problem: Elapsed time since testing started is not visible. Solution: Show the elapsed time while running tests.
author Bram Moolenaar <Bram@vim.org>
date Fri, 23 Sep 2022 20:45:03 +0200
parents 48f3922a1dac
children 800b2f95f159
files src/testdir/Make_all.mak src/testdir/Make_ming.mak src/testdir/Make_mvc.mak src/testdir/Makefile src/testdir/runtest.vim src/version.c
diffstat 6 files changed, 35 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -7,6 +7,9 @@
 NO_PLUGINS = --noplugin --not-a-term
 NO_INITS = -U NONE $(NO_PLUGINS)
 
+# File to delete when testing starts
+CLEANUP_FILES = test.log messages starttime
+
 # Tests for tiny and small builds.
 SCRIPTS_TINY = \
 	test20 \
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -47,6 +47,7 @@ report:
 	@if exist test.log ( copy /y test.log test_result.log > nul ) \
 		else ( echo No failures reported > test_result.log )
 	$(VIMPROG) -u NONE $(COMMON_ARGS) -S summarize.vim messages
+	-if exist starttime del starttime
 	@echo.
 	@echo Test results:
 	@cmd /c type test_result.log
@@ -60,6 +61,7 @@ report:
 	-if exist $@.res del $@.res
 	-if exist test.log del test.log
 	-if exist messages del messages
+	-if exist starttime del starttime
 	@$(MAKE) -f Make_ming.mak $@.res VIMPROG=$(VIMPROG) --no-print-directory
 	@type messages
 	@if exist test.log exit 1
@@ -83,6 +85,7 @@ clean:
 	-@if exist test.log $(DEL) test.log
 	-@if exist test_result.log del test_result.log
 	-@if exist messages $(DEL) messages
+	-@if exist starttime $(DEL) starttime
 	-@if exist benchmark.out del benchmark.out
 	-@if exist opt_test.vim $(DEL) opt_test.vim
 	-@if exist guidialog $(DEL) guidialog
@@ -92,6 +95,7 @@ nolog:
 	-@if exist test.log $(DEL) test.log
 	-@if exist test_result.log del test_result.log
 	-@if exist messages $(DEL) messages
+	-@if exist starttime $(DEL) starttime
 
 
 # Tiny tests.  Works even without the +eval feature.
--- a/src/testdir/Make_mvc.mak
+++ b/src/testdir/Make_mvc.mak
@@ -35,6 +35,7 @@ report:
 	@if exist test.log ( copy /y test.log test_result.log > nul ) \
 		else ( echo No failures reported > test_result.log )
 	$(VIMPROG) -u NONE $(COMMON_ARGS) -S summarize.vim messages
+	-if exist starttime del starttime
 	@echo.
 	@echo Test results:
 	@cmd /c type test_result.log
@@ -48,6 +49,7 @@ report:
 	-if exist $@.res del $@.res
 	-if exist test.log del test.log
 	-if exist messages del messages
+	-if exist starttime del starttime
 	@$(MAKE) -nologo -f Make_mvc.mak $@.res VIMPROG=$(VIMPROG)
 	@type messages
 	@if exist test.log exit 1
@@ -71,6 +73,7 @@ clean:
 	-if exist test.log del test.log
 	-if exist test_result.log del test_result.log
 	-if exist messages del messages
+	-if exist starttime del starttime
 	-if exist benchmark.out del benchmark.out
 	-if exist opt_test.vim del opt_test.vim
 	-if exist guidialog del guidialog
@@ -80,6 +83,7 @@ nolog:
 	-if exist test.log del test.log
 	-if exist test_result.log del test_result.log
 	-if exist messages del messages
+	-if exist starttime del starttime
 
 
 # Tiny tests.  Works even without the +eval feature.
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -12,7 +12,7 @@ SCRIPTSOURCE = ../../runtime
 # Comment out this line to see the verbose output of tests.
 #
 # Catches SwapExists to avoid hanging at the ATTENTION prompt.
-REDIR_TEST_TO_NULL = --cmd 'au SwapExists * let v:swapchoice = "e"' | LC_ALL=C LANG=C LANGUAGE=C awk '/Executing Test_/{match($$0, "(took .*; now )?Executing Test_[^\\)]*\\)"); print substr($$0, RSTART, RLENGTH) "\r"; fflush()}'
+REDIR_TEST_TO_NULL = --cmd 'au SwapExists * let v:swapchoice = "e"' | LC_ALL=C LANG=C LANGUAGE=C awk '/Executing Test_/{match($$0, "([0-9][0-9]:[0-9][0-9] *)?Executing Test_[^\\)]*\\)"); print substr($$0, RSTART, RLENGTH) "\r"; fflush()}'
 
 # Uncomment this line to use valgrind for memory leaks and extra warnings.
 #   The output goes into a file "valgrind.testN"
@@ -49,6 +49,7 @@ report:
 		else echo No failures reported > test_result.log; \
 		fi"
 	$(VIMPROG) -u NONE $(NO_INITS) -S summarize.vim messages $(REDIR_TEST_TO_NULL)
+	@rm -f starttime
 	@echo
 	@echo 'Test results:'
 	@cat test_result.log
@@ -63,7 +64,7 @@ report:
 # Execute an individual new style test, e.g.:
 # 	make test_largefile
 $(NEW_TESTS):
-	rm -f $@.res test.log messages
+	rm -f $@.res $(CLEANUP_FILES)
 	@MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE)
 	@cat messages
 	@if test -f test.log; then \
@@ -72,9 +73,10 @@ report:
 
 # Run only tests specific for Vim9 script
 test_vim9:
-	rm -f test_vim9_*.res test.log messages
+	rm -f test_vim9_*.res $(CLEANUP_FILES)
 	@MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $(TEST_VIM9_RES) VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE)
 	@cat messages
+	@rm -f starttime
 	@MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile report VIMPROG=$(VIMPROG) XXDPROG=$(XXDPROG) SCRIPTSOURCE=$(SCRIPTSOURCE)
 	@if test -f test.log; then \
 		exit 1; \
@@ -88,7 +90,7 @@ RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE) $(V
 # that may result from working on the tests, not only from running them.
 clean:
 	-rm -rf *.out *.failed *.res *.rej *.orig XfakeHOME Xdir1 Xfind
-	-rm -f opt_test.vim test.log test_result.log messages
+	-rm -f opt_test.vim test_result.log $(CLEANUP_FILES)
 	-rm -rf $(RM_ON_RUN) $(RM_ON_START)
 	-rm -f valgrind.*
 	-rm -f asan.*
@@ -99,7 +101,7 @@ benchmarkclean:
 	rm -f $(SCRIPTS_BENCH)
 
 nolog:
-	-rm -f test.log test_result.log messages
+	-rm -f test_result.log $(CLEANUP_FILES)
 
 
 # Tiny tests.  Works even without the +eval feature.
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -74,7 +74,16 @@ if &lines < 24 || &columns < 80
 endif
 
 if has('reltime')
-  let s:start_time = reltime()
+  let s:run_start_time = reltime()
+
+  if !filereadable('starttime')
+    " first test, store the overall test starting time
+    let s:test_start_time = localtime()
+    call writefile([string(s:test_start_time)], 'starttime')
+  else
+    " second or later test, read the overall test starting time
+    let s:test_start_time = readfile('starttime')[0]->str2nr()
+  endif
 endif
 
 " Always use forward slashes.
@@ -173,12 +182,14 @@ function GetAllocId(name)
   return lnum - top - 1
 endfunc
 
-let g:func_start = reltime()
+if has('reltime')
+  let g:func_start = reltime()
+endif
 
 func RunTheTest(test)
   let prefix = ''
   if has('reltime')
-    let prefix = 'took ' .. reltimestr(reltime(g:func_start)) .. '; now '
+    let prefix = strftime('%M:%S', localtime() - s:test_start_time) .. ' '
     let g:func_start = reltime()
   endif
   echoconsole prefix .. 'Executing ' .. a:test
@@ -377,7 +388,7 @@ func FinishTesting()
   endif
   if s:done > 0 && has('reltime')
     let message = s:t_bold .. message .. repeat(' ', 40 - len(message))
-    let message ..= ' in ' .. reltimestr(reltime(s:start_time)) .. ' seconds'
+    let message ..= ' in ' .. reltimestr(reltime(s:run_start_time)) .. ' seconds'
     let message ..= s:t_normal
   endif
   echo message
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    560,
+/**/
     559,
 /**/
     558,