mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:54:04 +08:00
tests: add a lame gdate-based ms-precision timer if installed
I got tired of seeing ' ... ok (0 sec)' so now with GNU date/gdate installed there is millisecond output shown. One can get rough nanoseconds from gdate.
This commit is contained in:
parent
2b7b70a64f
commit
5c06e68115
|
@ -34,12 +34,12 @@ function test_in_file
|
|||
set -l base (basename $file .in)
|
||||
|
||||
echo -n "Testing file $file ... "
|
||||
set starttime (date +%s)
|
||||
set starttime (timestamp)
|
||||
|
||||
../test/root/bin/fish <$file >$base.tmp.out 2>$base.tmp.err
|
||||
set -l exit_status $status
|
||||
set -l res ok
|
||||
set test_duration (math (date +%s) - $starttime)
|
||||
set test_duration (delta $starttime)
|
||||
|
||||
diff $base.tmp.out $base.out >/dev/null
|
||||
set -l out_status $status
|
||||
|
@ -47,7 +47,7 @@ function test_in_file
|
|||
set -l err_status $status
|
||||
|
||||
if test $out_status -eq 0 -a $err_status -eq 0 -a $exit_status -eq 0
|
||||
say green "ok ($test_duration sec)"
|
||||
say green "ok ($test_duration $unit)"
|
||||
# clean up tmp files
|
||||
rm -f $base.tmp.{err,out}
|
||||
return 0
|
||||
|
@ -74,13 +74,13 @@ set -g python (__fish_anypython)
|
|||
function test_littlecheck_file
|
||||
set -l file $argv[1]
|
||||
echo -n "Testing file $file ... "
|
||||
set starttime (date +%s)
|
||||
set starttime (timestamp)
|
||||
$python ../littlecheck.py -s fish=../test/root/bin/fish $file
|
||||
set -l exit_status $status
|
||||
set -l res ok
|
||||
set test_duration (math (date +%s) - $starttime)
|
||||
set test_duration (delta $starttime)
|
||||
if test $exit_status -eq 0
|
||||
say green "ok ($test_duration sec)"
|
||||
say green "ok ($test_duration $unit)"
|
||||
end
|
||||
return $exit_status
|
||||
end
|
||||
|
|
|
@ -133,3 +133,26 @@ function colordiff -d 'Colored diff output for unified diffs'
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# lame timer
|
||||
for program in {g,}date
|
||||
if $program --version
|
||||
set milli $program
|
||||
set unit ms
|
||||
break
|
||||
else
|
||||
set unit sec
|
||||
end
|
||||
end
|
||||
|
||||
function timestamp -V milli
|
||||
set -q milli[1]
|
||||
and $milli +%s%3N
|
||||
or date +%s
|
||||
end
|
||||
|
||||
function delta -V milli
|
||||
set -q milli[1]
|
||||
and math "( "($milli +%s%3N)" - $argv[1])"
|
||||
or math (date +%s) - $starttime
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user