Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: change test limit for atime from 2ms to 5ms #30437

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 10 additions & 9 deletions test/parallel/test-fs-stat-bigint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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));
Expand Down Expand Up @@ -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`);
Expand Down