Skip to content

Commit

Permalink
test: refactor beforeExit tests
Browse files Browse the repository at this point in the history
Combine and rename tests for the `beforeExit` event on `process`.

The naming now more closely follows the de facto conventions of the
project.

The two tests were very similar and do not seem to benefit from being
separate.

PR-URL: #10581
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
Trott committed Jan 6, 2017
1 parent 8066215 commit d2c96af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
14 changes: 0 additions & 14 deletions test/parallel/test-process-before-exit.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ function tryListen() {
.listen(0)
.on('listening', common.mustCall(function() {
this.close();
process.on('beforeExit', common.mustCall(() => {}));
process.once('beforeExit', common.mustCall(tryRepeatedTimer));
}));
}

// test that a function invoked from the beforeExit handler can use a timer
// to keep the event loop open, which can use another timer to keep the event
// loop open, etc.
function tryRepeatedTimer() {
const N = 5;
let n = 0;
const repeatedTimer = common.mustCall(function() {
if (++n < N)
setTimeout(repeatedTimer, 1);
}, N);
setTimeout(repeatedTimer, 1);
}

0 comments on commit d2c96af

Please sign in to comment.