Skip to content

Commit df27bfe

Browse files
committed
Add debugging code to time_sleep_until test
1 parent d3112ad commit df27bfe

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

ext/standard/tests/misc/time_sleep_until_basic.phpt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ Michele Orselli [email protected]
1111
#PHPTestFest Cesena Italia on 2009-06-20
1212
--FILE--
1313
<?php
14-
$time = microtime(true) + 2;
15-
var_dump(time_sleep_until( (int)$time ));
16-
$now = microtime(true);
17-
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
14+
$time = microtime(true) + 2;
15+
$sleepUntil = (int) $time;
16+
var_dump(time_sleep_until($sleepUntil));
17+
$now = microtime(true);
18+
if (substr(PHP_OS, 0, 3) == 'WIN') {
1819
// on windows, time_sleep_until has millisecond accuracy while microtime() is accurate
1920
// to 10th of a second. this means there can be up to a .9 millisecond difference
2021
// which will fail this test. this test randomly fails on Windows and this is the cause.
@@ -26,9 +27,17 @@ Michele Orselli [email protected]
2627
// In practice, on slower machines even that can fail, so giving yet 50ms or more.
2728
$tmp = round($now, 3);
2829
$now = $tmp >= (int)$time ? $tmp : $tmp + .05;
29-
}
30-
var_dump($now >= (int)$time);
30+
}
31+
32+
if ($now >= $sleepUntil) {
33+
echo "Success\n";
34+
} else {
35+
echo "Sleep until (before truncation): ", $time, "\n";
36+
echo "Sleep until: ", $sleepUntil, "\n";
37+
echo "Now: ", $now, "\n";
38+
}
39+
3140
?>
3241
--EXPECT--
3342
bool(true)
34-
bool(true)
43+
Success

0 commit comments

Comments
 (0)