diff --git a/pkg/fish-spec/basic_formatter.fish b/pkg/fish-spec/basic_formatter.fish index 0632d1ee6848aa7d5e0044bd8caa1054af7cd9b3..289a4818e602f6ff4b66a1f32990ac48ba815318 100644 --- a/pkg/fish-spec/basic_formatter.fish +++ b/pkg/fish-spec/basic_formatter.fish @@ -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 set -g __current_spec_name (echo $spec | sed 's/^[0-9]*_//;s/_/ /g;s/^it/It/') set -e __current_spec_output diff --git a/pkg/fish-spec/functions/fish-spec.fish b/pkg/fish-spec/functions/fish-spec.fish index f8bdcd401953b10c8c62f92a6e118942ce7ac0ad..fc81fc926acdaadc9522af624ed52d678bad1fe9 100644 --- a/pkg/fish-spec/functions/fish-spec.fish +++ b/pkg/fish-spec/functions/fish-spec.fish @@ -1,7 +1,8 @@ function fish-spec + set -g __fish_spec_dir (dirname (dirname (status -f))) + # 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 set -e __any_spec_failed @@ -14,9 +15,13 @@ function fish-spec # Load helper file source spec/helper.fish ^/dev/null + emit all_specs_init + # Run all specs __fish-spec.run_all_specs + emit all_specs_finished + not set -q __any_spec_failed end @@ -50,3 +55,13 @@ function __fish-spec.run_suite -a suite_name functions -e before_all before_each after_each after_all 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 diff --git a/pkg/fish-spec/utils/epoch.c b/pkg/fish-spec/utils/epoch.c new file mode 100644 index 0000000000000000000000000000000000000000..4daaf2bd94119e8ac9d8b5c8cc2ebcc6b718595c --- /dev/null +++ b/pkg/fish-spec/utils/epoch.c @@ -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; +} diff --git a/pkg/fish-spec/utils/epoch.linux b/pkg/fish-spec/utils/epoch.linux new file mode 100755 index 0000000000000000000000000000000000000000..3898514e7a8c4fb0a9c12ccfbb570508a4562bc2 Binary files /dev/null and b/pkg/fish-spec/utils/epoch.linux differ diff --git a/pkg/fish-spec/utils/epoch.osx b/pkg/fish-spec/utils/epoch.osx new file mode 100755 index 0000000000000000000000000000000000000000..3d27ae9be2e6744fb1a69fd7af0e4c5147965fff Binary files /dev/null and b/pkg/fish-spec/utils/epoch.osx differ