Skip to content

Commit e1396a3

Browse files
committedAug 28, 2023
Fix flaky file stat tests due to changing nature of atime
1 parent bffc744 commit e1396a3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎ext/standard/tests/file/file.inc

+9-2
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ $all_stat_keys = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
590590
"rdev", "size", "atime", "mtime", "ctime",
591591
"blksize", "blocks");
592592

593+
$stat_time_diff_keys = array(8, 'atime');
594+
593595
function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
594596
// dump the stat if requested
595597
if ( $flag == true ) {
@@ -606,8 +608,13 @@ function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
606608
{
607609
case "==":
608610
if ( $stat1[ $fields[$index] ] != $stat2[ $fields[$index] ] ) {
609-
$result = false;
610-
echo "Error: stat1 do not match with stat2 at key value: $fields[$index]\n";
611+
if ( ! in_array( $index, $stat_time_diff_keys ) ) {
612+
$result = false;
613+
echo "Error: stat1 do not match with stat2 at key value: $fields[$index]\n";
614+
} elseif (abs($stat1[ $fields[$index] ] - $stat2[ $fields[$index] ]) > 1) {
615+
$result = false;
616+
echo "Error: stat1 differs too much from stat2 at key value: $fields[$index]\n";
617+
}
611618
}
612619
break;
613620

0 commit comments

Comments
 (0)