From 148ce423ea104daa005e67e48c714c553618cc67 Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Sat, 19 Dec 2015 12:26:51 +0000 Subject: [PATCH] Report duration of tests OSX `date` does not support milliseconds output, so @derekstavis created this `C` code to generate the time with milliseconds. --- pkg/fish-spec/basic_formatter.fish | 13 +++++++++++++ pkg/fish-spec/functions/fish-spec.fish | 19 +++++++++++++++++-- pkg/fish-spec/utils/epoch.c | 10 ++++++++++ pkg/fish-spec/utils/epoch.linux | Bin 0 -> 6832 bytes pkg/fish-spec/utils/epoch.osx | Bin 0 -> 8496 bytes 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 pkg/fish-spec/utils/epoch.c create mode 100755 pkg/fish-spec/utils/epoch.linux create mode 100755 pkg/fish-spec/utils/epoch.osx diff --git a/pkg/fish-spec/basic_formatter.fish b/pkg/fish-spec/basic_formatter.fish index 0632d1e..289a481 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 f8bdcd4..fc81fc9 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 0000000..4daaf2b --- /dev/null +++ b/pkg/fish-spec/utils/epoch.c @@ -0,0 +1,10 @@ +#include +#include + +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 GIT binary patch literal 6832 zcmcIoU2I%e5uV-kUw*n?r%e-*psXN4NmOr~#Btmf$Xz>|T!&3!92-K5bG`Piy<6>{ z_9u0!Rv4L9tV$pVRKXK@K(v*3$O9GSg(Rd(phCitC@&ObN-H@np$@G|BuLCR=bqWU zd%Z@L5VN{>&U|NP&YZdDcfS^i9`<@XB;=*f6H7*up&`Ntt2AhV)sSZX%nsS-&sIc?@p)2d%Ab0k9ZD;6Xgg2>qMj z?(|T;kjj=OX(~}Fr80@!WIT43EQ{-{VkuTAS(#WW3uG#j%WA};Bhi7rers=NZ)iVU zd)1HI@Teb=m-at_s-^8|yxX@LD6yR6%A4~`pzY%8XW9Ma9pN*-dFL%Deo@}64*l^dtc%3J2_+lzz41J^GHTMROQA z|GRQ<<(>}?%*vv9W#ORdxn|zDS6W~7wnn_QZ-pPb{h80b+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mSi5mvV)o6)R5@cBOne zQA)%^Jr8$x!E*y8i}y!+x3jQ=70!~qKgP?M3}09slEuN+sV4HdiKL48@KE?z#EKk0 zgrMynNV(1^PS&BX91kBG=!cf0M%{?XIubq67mivd4j(=l8McPQebETJQKE?gjs;P>lV%tx@`Y3aP*8dq`!TCI#w*=!&??Q zD@o=o$VjNmfy%3Mu>KEaKJR0SRnOJrH6Vd7o|)vlZ%ekWl$n1T51+BMdi9(m|5F7~ z=Omf$g7N<>d}k1Q!)rhyoQo8r9X7+7Z4>VUOd=mZnePx{pY$4#_`abSP1{Vh!Tl6_ zIqx3?#&-;{pZ6M&`2M0;^`2r&%lm%>6?{h!dpUaLwEQscJ3gt6KEC%XZvzK z-KIMv_e0T_Jc?Y=_L6@&$98>8`|rB!<-9BZ*LF)on!DTok;`7r#d+QShc0{hegeOY zf*+4gclG=%|7*MT-SR82ZFktq`7h6l0?4iJmajmE^Dphod3^d~+Fye$cUA0XTE`$! z_5bxb{r!3VFiHC|4t@vB*}k0b2la;+eP!&h7yS1wd-NihHb literal 0 HcmV?d00001 diff --git a/pkg/fish-spec/utils/epoch.osx b/pkg/fish-spec/utils/epoch.osx new file mode 100755 index 0000000000000000000000000000000000000000..3d27ae9be2e6744fb1a69fd7af0e4c5147965fff GIT binary patch literal 8496 zcmeHMO=uHA7@e(uMT@4OQqe*bBkG~8;z1B0kuGjA_){y0phMDbO(022vcXmq0;PpT z3b_b+^<2cOH$hP=f<1Zikc$#Qu{Vo|@x9G#vYV=RVLq6A^Jczz`_0=KnC!g!@%7gh zA&d<|RJw!^J5aM*tt8OVBd&X(UcJi%m$7Il*S0Th3+u;P2Ae6G?l+&eFQzzdI2tvLd72#ul zK)2#+=SM!7v2)XQ5kZ}NImLHS5fD@NmaWTgyyO(Kg_|m%ldr1ys1c1gXd!NNNLeo2 z$`&SMwlF#6;qd!-p!oRCX~dlz&7S73ly*i=7E^iK$6>yj;_Fj`h_TlGYFsCE6e))j zV~Ic*)xTEW1{6`? z!|)b7<2WbwSAe-@>hOHm+fXi|1dXvQ!FdGxSzn2^_hzsU+m0!D`)06QDh}qd>A{KF z+=L3+3(q{#ja~1%GN%qLd|Mt`dNfeuzJPQ{XscI_`j~An%%#F{+}AIgIp4M^tb>CRoa*eg* zxLJ424@vi#${a;&9KG>)0S^=$qRzNGD70?Q31+)TM0j+>m zKr5gX&-{V*=CFBL^q6eGQHdDC{BY~G%loJh^Gtq*O} zxRiD#fs`2%_laFHpON;AJzjQf+<~V^vp=887DTLhk+|Bg!u<-HcNpG{pZC>bw}+eG tIQ(xQ@U1TvyblcG;~lv9nATlu+{aPe;I7Y2dbx$?=g(}N9(a-vzX3(^_tF3W literal 0 HcmV?d00001