test: loosen test for negative timestamps in test-fs-stat-date

PR-URL: https://github.com/nodejs/node/pull/44707
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
Livia Medeiros authored and Danielle Adams committed 2022-10-11 09:10:09 -04:00
1 parent db5aeed702
commit fe91bebb67
1 file changed
+8
+8
View File
@@ -31,6 +31,14 @@ function closeEnough(actual, expected, margin) {
if (process.arch === 'ppc64') {
margin += 1000;
}
// Filesystems without support for timestamps before 1970-01-01, such as NFSv3,
// should return 0 for negative numbers. Do not treat it as error.
if (actual === 0 && expected < 0) {
console.log(`ignored 0 while expecting ${expected}`);
return;
}
assert.ok(Math.abs(Number(actual - expected)) < margin,
`expected ${expected} ± ${margin}, got ${actual}`);
}