From 8f8ce2505d2d9e0124398640b1fe17beee282014 Mon Sep 17 00:00:00 2001 From: Livia Medeiros Date: Sat, 8 Oct 2022 01:22:39 +0900 Subject: [PATCH] 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 Reviewed-By: Richard Lau --- test/parallel/test-fs-stat-date.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-fs-stat-date.mjs b/test/parallel/test-fs-stat-date.mjs index 979f6d5f453cd1..71cdb1a40f986b 100644 --- a/test/parallel/test-fs-stat-date.mjs +++ b/test/parallel/test-fs-stat-date.mjs @@ -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}`); }