Skip to content

Commit

Permalink
vim-patch:9.0.0560: elapsed time since testing started is not visible
Browse files Browse the repository at this point in the history
Problem:    Elapsed time since testing started is not visible.
Solution:   Show the elapsed time while running tests.

vim/vim@b9093d5

Co-authored-by: Bram Moolenaar <Bram@vim.org>
  • Loading branch information
zeertzjq and brammool committed Apr 19, 2023
1 parent 7592540 commit 63432c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ compile_commands.json
/test/old/testdir/test*.res
/test/old/testdir/test*.log
/test/old/testdir/messages
/test/old/testdir/starttime
/test/old/testdir/viminfo
/test/old/testdir/test.ok
/test/old/testdir/*.failed
Expand Down
11 changes: 7 additions & 4 deletions test/old/testdir/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ report:
then echo TEST FAILURE; exit 1; \
else echo ALL DONE; \
fi"
@rm -f starttime

test1.out: $(NVIM_PRG)

Expand All @@ -86,10 +87,13 @@ fixff:
-$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \
dotest.in

# File to delete when testing starts
CLEANUP_FILES = test.log messages starttime

# 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
@cat messages
@if test -f test.log; then \
Expand All @@ -108,9 +112,8 @@ CLEAN_FILES := *.out \
*.rej \
*.orig \
*.tlog \
test.log \
test_result.log \
messages \
$(CLEANUP_FILES) \
$(RM_ON_RUN) \
$(RM_ON_START) \
valgrind.* \
Expand All @@ -132,7 +135,7 @@ test1.out: .gdbinit test1.in

nolog:
@echo "[OLDTEST-PREP] Removing test.log and messages"
@rm -f test.log messages
@rm -f test_result.log $(CLEANUP_FILES)


# New style of tests uses Vim script with assert calls. These are easier
Expand Down
19 changes: 15 additions & 4 deletions test/old/testdir/runtest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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.
Expand Down Expand Up @@ -139,12 +148,14 @@ func 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
echo prefix .. 'Executing ' .. a:test
Expand Down Expand Up @@ -328,7 +339,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
Expand Down

0 comments on commit 63432c8

Please sign in to comment.