Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
process: move test-process-uptime to parallel
In addition, do not make too many assumptions about the startup
time and timer latency in test-process-uptime. Instead only test
that the value is likely in the correct unit (seconds) and it should
be increasing in subsequent calls.
  • Loading branch information
joyeecheung authored and Trott committed Feb 19, 2019
commit a6ea194f008451603628801d76d0d82cf95226cd
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
const common = require('../common');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const common = require('../common');
require('../common');

const assert = require('assert');

console.error(process.uptime());
assert.ok(process.uptime() <= 2);
// Add some wiggle room for different platforms.
// Verify that the returned value is in seconds -
// 15 seconds should be a good estimate.
assert.ok(process.uptime() <= 15);

const original = process.uptime();

setTimeout(function() {
const uptime = process.uptime();
// some wiggle room to account for timer
// granularity, processor speed, and scheduling
assert.ok(uptime >= original + 2);
assert.ok(uptime <= original + 3);
}, 2000);
assert.ok(original < uptime);
}, 10);