@@ -24,6 +24,7 @@ use File::Temp qw/tempfile/;
2424use HTTP::Cookies::Netscape;
2525use HTTP::Request ();
2626use HTTP::Request::Common 6.12 qw/ GET POST/ ;
27+ use POSIX ();
2728use Plack::Test;
2829use Test::More;
2930use Time::HiRes qw/ sleep gettimeofday tv_interval/ ;
@@ -756,6 +757,7 @@ sub test_command {
756757 }
757758
758759 my ($prg ,$arg ) = split (/ \s +/ , $test -> {' cmd' }, 2);
760+ $test -> {' start_time' } = &time_milli_str();
759761
760762 # wait for something?
761763 if (defined $test -> {' waitfor' }) {
@@ -1116,12 +1118,14 @@ sub bail_out_cmd {
11161118
11171119 diag(" \n ######################################################\n " );
11181120 diag(" cmd diagnostics:" );
1119- diag(" error: '" .(ref $msg ? Dumper($msg ) : $msg )." '\n " );
1121+ diag(" error: '" .(ref $msg ? Dumper($msg ) : $msg )." '\n " );
11201122 my $cmd = $test -> {' test_cmd' };
1121- diag(" cmd: '" .$test -> {' cmd' }." ' failed\n " );
1122- diag(" stdout: '" .($cmd -> stdout // ' ' )." '\n " ) if $cmd ;
1123- diag(" stderr: '" .($cmd -> stderr // ' ' )." '\n " ) if $cmd ;
1124- diag(" exit: '" .($rc // ' (none)' )." '\n " );
1123+ diag(" cmd: '" .$test -> {' cmd' }." ' failed\n " );
1124+ diag(" stdout: '" .($cmd -> stdout // ' ' )." '\n " ) if $cmd ;
1125+ diag(" stderr: '" .($cmd -> stderr // ' ' )." '\n " ) if $cmd ;
1126+ diag(" exit: " .($rc // ' (none)' )." \n " );
1127+ diag(" time (start): " .($test -> {' start_time' } // ' <unknown>' )." \n " );
1128+ diag(" time (end): " .time_milli_str()." \n " );
11251129
11261130 diag(Carp::longmess(" started here:" ));
11271131 diag(" \n ######################################################\n " );
@@ -1317,7 +1321,6 @@ sub js_init {
13171321 headless => 1,
13181322 separate_session => 1,
13191323 incognito => 1,
1320- tab => ' current' ,
13211324 launch_arg => [" --password-store=basic" , " --remote-allow-origins=*" ],
13221325 );
13231326 $mech -> get_local(-f " ./data/blank.html" ? " ./data/blank.html" : " ../../data/blank.html" );
@@ -1396,6 +1399,14 @@ sub js_is {
13961399# ################################################
13971400sub _js_diag_error {
13981401 my ($e , $diag ) = @_ ;
1402+
1403+ if ($e -> {' type' } && ($e -> {' type' } eq ' debug' || $e -> {' type' } eq ' info' )) {
1404+ return unless $ENV {' HARNESS_VERBOSE' };
1405+ diag(" not failing on debug " .$e -> {' type' }." console message" );
1406+ } else {
1407+ fail(" got js error" );
1408+ }
1409+
13991410 diag($diag ) if $diag ;
14001411 my $known = 0;
14011412 if ($e -> {' message' }) {
@@ -1418,12 +1429,6 @@ sub _js_diag_error {
14181429 }
14191430 $known = 1;
14201431 }
1421- if ($e -> {' type' } && ($e -> {' type' } eq ' debug' || $e -> {' type' } eq ' info' )) {
1422- # diag("not failing on debug lvl console message");
1423- return ;
1424- } else {
1425- fail(" got js error" );
1426- }
14271432 if ($e -> {' stackTrace' } && ref $e -> {' stackTrace' } eq ' HASH' && $e -> {' stackTrace' }-> {' callFrames' }) {
14281433 diag(" Stack Trace:" );
14291434 for my $frame (@{$e -> {' stackTrace' }-> {' callFrames' }}) {
@@ -1445,16 +1450,16 @@ sub _js_format_err_arg {
14451450
14461451 if ($arg -> {' type' } eq ' object' && defined $arg -> {' preview' } && defined $arg -> {' preview' }-> {' properties' }) {
14471452 my $x = 0;
1448- my $str = ($arg -> {' className' } // " unknown" ) . " ( " ;
1453+ my $str = ($arg -> {' className' } // " unknown" ) . " { " ;
14491454 for my $p (@{$arg -> {' preview' }-> {' properties' }}) {
14501455 if ($x > 0) {
14511456 $str .= " , " ;
14521457 }
14531458 $x ++;
14541459
1455- $str .= sprintf (" %s (%s ): %s " , $p -> {' name' }, $p -> {' type' }, $p -> {' value' });
1460+ $str .= sprintf (" ' %s ' (%s ): %s " , $p -> {' name' }, $p -> {' type' }, $p -> {' value' });
14561461 }
1457- $str .= " ) " ;
1462+ $str .= " } " ;
14581463 return ($str );
14591464 }
14601465
@@ -1504,6 +1509,16 @@ sub is_deeply_diff {
15041509 return 0;
15051510}
15061511
1512+ # ################################################
1513+ # return current time with milliseconds
1514+ sub time_milli_str {
1515+ my ($seconds , $microseconds ) = Time::HiRes::gettimeofday;
1516+ return (sprintf (" %s ,%s " ,
1517+ POSIX::strftime(" %Y -%m -%d %H :%M :%S " , localtime ($seconds )),
1518+ substr (sprintf (" %06s" , $microseconds ), 0, 3),
1519+ ));
1520+ }
1521+
15071522# replace is_deeply with our own version which shows the diff if the test fails
15081523{
15091524 no warnings ' redefine' ;
0 commit comments