Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from AtkinsSJ/fix-sleep-test-flake
Browse files Browse the repository at this point in the history
Make sleep builtin test more tolerant of minor variations
  • Loading branch information
KernelDeimos authored Mar 6, 2024
2 parents 2e2c598 + 4d7feec commit a4b3bf1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/coreutils/sleep.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ export const runSleepTests = () => {
assert.fail(e);
}
const endTimeMs = performance.now();
const actualDurationMs = endTimeMs- startTimeMs;
assert.ok(actualDurationMs >= (durationS * 1000), `takes at least ${durationS} seconds`);
const actualDurationMs = endTimeMs - startTimeMs;
assert.ok(Math.abs(actualDurationMs - (durationS * 1000)) <= 10,
`should pause for ${durationS} seconds, instead was ${actualDurationMs / 1000}`);

assert.equal(ctx.externs.out.output, '', 'sleep should not write to stdout');
assert.equal(ctx.externs.err.output, '', 'sleep should not write to stderr');
Expand Down

0 comments on commit a4b3bf1

Please sign in to comment.