From 74d857818d631074624827ef9a642688d6561c31 Mon Sep 17 00:00:00 2001 From: Duncan Healy Date: Tue, 12 Nov 2019 16:10:22 +0000 Subject: [PATCH 1/2] test: fix flaky test-fs-stat-bigint Change test limit for atime from 2ms to 5ms. Add comment explaining why the wiggle room is needed. Fixes: https://github.com/nodejs/node/issues/24593 --- test/parallel/test-fs-stat-bigint.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-fs-stat-bigint.js b/test/parallel/test-fs-stat-bigint.js index 998ddb289da111..811070cd9aeb99 100644 --- a/test/parallel/test-fs-stat-bigint.js +++ b/test/parallel/test-fs-stat-bigint.js @@ -13,6 +13,10 @@ tmpdir.refresh(); let testIndex = 0; +// It's possible that the file stats are updated between the two statSync() +// calls so allow for a small difference. +const allowableDelta = 5; + function getFilename() { const filename = path.join(tmpdir.path, `test-file-${++testIndex}`); fs.writeFileSync(filename, 'test'); @@ -26,8 +30,8 @@ function verifyStats(bigintStats, numStats) { const time = val.getTime(); const time2 = bigintStats[key].getTime(); assert( - Math.abs(time - time2) < 2, - `difference of ${key}.getTime() should < 2.\n` + + Math.abs(time - time2) < allowableDelta, + `difference of ${key}.getTime() should < ${allowableDelta}.\n` + `Number version ${time}, BigInt version ${time2}n`); } else if (key === 'mode') { assert.strictEqual(bigintStats[key], BigInt(val)); @@ -65,17 +69,14 @@ function verifyStats(bigintStats, numStats) { const nsFromBigInt = bigintStats[nsKey]; const msFromBigIntNs = Number(nsFromBigInt / (10n ** 6n)); const msFromNum = numStats[key]; - // The difference between the millisecond-precision values should be - // smaller than 2 + assert( - Math.abs(msFromNum - Number(msFromBigInt)) < 2, + Math.abs(msFromNum - Number(msFromBigInt)) < allowableDelta, `Number version ${key} = ${msFromNum}, ` + `BigInt version ${key} = ${msFromBigInt}n`); - // The difference between the millisecond-precision value and the - // nanosecond-precision value scaled down to milliseconds should be - // smaller than 2 + assert( - Math.abs(msFromNum - Number(msFromBigIntNs)) < 2, + Math.abs(msFromNum - Number(msFromBigIntNs)) < allowableDelta, `Number version ${key} = ${msFromNum}, ` + `BigInt version ${nsKey} = ${nsFromBigInt}n` + ` = ${msFromBigIntNs}ms`); From daad06e125f1282005ee5c27091d52208cae5e5e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Feb 2020 01:32:57 -1000 Subject: [PATCH 2/2] test: remove flaky designation for test-fs-stat-bigint --- test/parallel/parallel.status | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index bf1123ee153ada..43ef8e40b5b452 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -5,8 +5,6 @@ prefix parallel # sample-test : PASS,FLAKY [true] # This section applies to all platforms -# https://github.com/nodejs/node/issues/24593 -test-fs-stat-bigint: PASS,FLAKY # https://github.com/nodejs/node/issues/23207 test-net-connect-options-port: PASS,FLAKY