mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-01-23 00:01:02 +08:00
Report duration of tests
OSX `date` does not support milliseconds output, so @derekstavis created this `C` code to generate the time with milliseconds.
This commit is contained in:
parent
8fac0ca484
commit
148ce423ea
|
@ -1,3 +1,16 @@
|
||||||
|
function __fish-spec.all_specs_init -e all_specs_init -a spec
|
||||||
|
set -g __fish_spec_start_time (__fish-spec.current_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
function __fish-spec.all_specs_finished -e all_specs_finished -a spec
|
||||||
|
set -l __fish_spec_end_time (__fish-spec.current_time)
|
||||||
|
set -l diff (math "scale=3;($__fish_spec_end_time - $__fish_spec_start_time) / 1000")
|
||||||
|
|
||||||
|
echo -en '\n\nFinished in '
|
||||||
|
printf '%g' $diff
|
||||||
|
echo ' seconds'
|
||||||
|
end
|
||||||
|
|
||||||
function __fish-spec.spec_init -e spec_init -a spec
|
function __fish-spec.spec_init -e spec_init -a spec
|
||||||
set -g __current_spec_name (echo $spec | sed 's/^[0-9]*_//;s/_/ /g;s/^it/It/')
|
set -g __current_spec_name (echo $spec | sed 's/^[0-9]*_//;s/_/ /g;s/^it/It/')
|
||||||
set -e __current_spec_output
|
set -e __current_spec_output
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
function fish-spec
|
function fish-spec
|
||||||
|
set -g __fish_spec_dir (dirname (dirname (status -f)))
|
||||||
|
|
||||||
# Source formatter
|
# Source formatter
|
||||||
set -l fish_spec_dir (dirname (dirname (status -f)))
|
source $__fish_spec_dir/basic_formatter.fish
|
||||||
source $fish_spec_dir/basic_formatter.fish
|
|
||||||
|
|
||||||
# Reset internal variables
|
# Reset internal variables
|
||||||
set -e __any_spec_failed
|
set -e __any_spec_failed
|
||||||
|
@ -14,9 +15,13 @@ function fish-spec
|
||||||
# Load helper file
|
# Load helper file
|
||||||
source spec/helper.fish ^/dev/null
|
source spec/helper.fish ^/dev/null
|
||||||
|
|
||||||
|
emit all_specs_init
|
||||||
|
|
||||||
# Run all specs
|
# Run all specs
|
||||||
__fish-spec.run_all_specs
|
__fish-spec.run_all_specs
|
||||||
|
|
||||||
|
emit all_specs_finished
|
||||||
|
|
||||||
not set -q __any_spec_failed
|
not set -q __any_spec_failed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,3 +55,13 @@ function __fish-spec.run_suite -a suite_name
|
||||||
|
|
||||||
functions -e before_all before_each after_each after_all
|
functions -e before_all before_each after_each after_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function __fish-spec.current_time
|
||||||
|
if test (uname) = 'Darwin'
|
||||||
|
set filename 'epoch.osx'
|
||||||
|
else
|
||||||
|
set filename 'epoch.linux'
|
||||||
|
end
|
||||||
|
|
||||||
|
eval $__fish_spec_dir/utils/$filename
|
||||||
|
end
|
||||||
|
|
10
pkg/fish-spec/utils/epoch.c
Normal file
10
pkg/fish-spec/utils/epoch.c
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
struct timeval time_struct;
|
||||||
|
gettimeofday(&time_struct, 0);
|
||||||
|
printf("%lld", (time_struct.tv_sec * 1000ll) + (time_struct.tv_usec / 1000ll));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
pkg/fish-spec/utils/epoch.linux
Executable file
BIN
pkg/fish-spec/utils/epoch.linux
Executable file
Binary file not shown.
BIN
pkg/fish-spec/utils/epoch.osx
Executable file
BIN
pkg/fish-spec/utils/epoch.osx
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user