@@ -25,7 +25,20 @@ $file_name = 'test.js';
2525
2626$ script = new v8 \Script ($ context , new \v8 \StringValue ($ isolate , $ source ), new \v8 \ScriptOrigin ($ file_name ));
2727
28- $ time_limit = 1.5 ;
28+ // NOTE: this check is a bit fragile but should fits our need
29+ $ needs_more_time = isset ($ _ENV ['TRAVIS ' ]) && isset ($ _ENV ['TEST_PHP_ARGS ' ]) && $ _ENV ['TEST_PHP_ARGS ' ] == '-m ' ;
30+
31+ if ($ needs_more_time ) {
32+ // On travis when valgrind active it takes more time to complete all operations so we just increase initial limits
33+ $ time_limit = 5.0 ;
34+ $ low_range = 4.5 ;
35+ $ high_range = 7.5 ;
36+ } else {
37+ $ time_limit = 1.5 ;
38+ $ low_range = 1.45 ;
39+ $ high_range = 1.6 ;
40+ }
41+
2942$ helper ->assert ('Time limit accessor report no hit ' , false === $ isolate ->IsTimeLimitHit ());
3043$ helper ->assert ('Get time limit default value is zero ' , 0.0 === $ isolate ->GetTimeLimit ());
3144$ isolate ->SetTimeLimit ($ time_limit );
4457 $ helper ->line ();
4558 $ t = microtime (true ) - $ t ;
4659 $ helper ->dump (round ($ t , 9 ));
47- $ helper ->assert (' Script execution time is between 1.500 and 1.600 ' , $ t >= 1.500 && $ t < 1.599 );
60+ $ helper ->assert (" Script execution time is within specified range ( { $ low_range } , { $ high_range } ) " , $ t >= $ low_range && $ t < $ high_range );
4861}
4962
5063$ helper ->assert ('Get time limit returns valid value ' , $ time_limit === $ isolate ->GetTimeLimit ());
@@ -61,7 +74,7 @@ object(v8\Isolate)#3 (5) {
6174 ["snapshot":"v8\Isolate":private]=>
6275 NULL
6376 ["time_limit":"v8\Isolate":private]=>
64- float(1.5 )
77+ float(%f )
6578 ["time_limit_hit":"v8\Isolate":private]=>
6679 bool(false)
6780 ["memory_limit":"v8\Isolate":private]=>
@@ -73,16 +86,16 @@ object(v8\Isolate)#3 (5) {
7386v8\Exceptions\TimeLimitException: Time limit exceeded
7487script execution terminated
7588
76- float(1.5%d )
77- Script execution time is between 1.500 and 1.600 : ok
89+ float(%f )
90+ Script execution time is within specified range (%f, %f) : ok
7891Get time limit returns valid value: ok
7992Time limit accessor report hit: ok
8093
8194object(v8\Isolate)#3 (5) {
8295 ["snapshot":"v8\Isolate":private]=>
8396 NULL
8497 ["time_limit":"v8\Isolate":private]=>
85- float(1.5 )
98+ float(%f )
8699 ["time_limit_hit":"v8\Isolate":private]=>
87100 bool(true)
88101 ["memory_limit":"v8\Isolate":private]=>
0 commit comments