-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add failing test demonstrating long running onExit() hook in child pr…
…ocess
- Loading branch information
1 parent
1d565e4
commit bf65e22
Showing
3 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
'use strict'; | ||
const test = require('../../'); | ||
var onExit = require('signal-exit'); | ||
|
||
test('long running', function (t) { | ||
t.plan(1); | ||
|
||
onExit(function () { | ||
// simulate an exit hook that lasts a short while | ||
var start = Date.now(); | ||
while(Date.now() - start < 2000) { | ||
//synchronously wait for 2 seconds | ||
} | ||
process.send('cleanup-completed', true); | ||
}); | ||
|
||
setTimeout(function () { | ||
t.ok(true); | ||
}); | ||
|
||
setTimeout(function () { | ||
// this would keep the process running for a long time. | ||
console.log('I\'m gonna live forever!!'); | ||
}, 15000); | ||
|
||
t.ok(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters