From 8fee56c1d7240ff33fa3dd3871ee70394010b4ae Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Sun, 18 Sep 2022 17:35:10 +0800 Subject: [PATCH] test: loosen test for negative timestamps in `test-fs-stat-date` --- 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}`); }