[Pkg-javascript-commits] [node-foreground-child] 12/69: added a unit test, because I strive to be a good open-source-citizen
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Aug 25 11:43:02 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-foreground-child.
commit 5ad7ed2228e98069ff5945c523b718a8b3c63988
Author: Benjamin Coe <ben at npmjs.com>
Date: Sat Jun 20 19:04:56 2015 -0400
added a unit test, because I strive to be a good open-source-citizen
---
test/basic.js | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/test/basic.js b/test/basic.js
index 2b0b83a..96ffbb6 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -22,9 +22,20 @@ if (process.argv[2] === 'child') {
}
if (process.argv[2] === 'parent') {
+ var cb = undefined
+
+ // we can optionally assign a beforeExit handler
+ // to the foreground-child process; we should test it.
+ if (process.argv[4] === 'beforeExitHandler') {
+ cb = function (done) {
+ console.log('beforeExitHandler')
+ return done()
+ }
+ }
+
var program = process.execPath
var args = [__filename, 'child'].concat(process.argv.slice(3))
- var child = fg(program, args)
+ var child = fg(program, args, cb)
if (process.argv[3] === 'signalexit') {
signalExit(function (code, signal) {
@@ -42,6 +53,7 @@ if (process.argv[2] === 'parent') {
break
}
}
+
return
}
@@ -112,6 +124,26 @@ t.test('parent emits exit when SIGTERMed', function (t) {
t.end()
})
+t.test('beforeExitHandler', function (t) {
+ var codes = [0, 1, 2]
+ codes.forEach(function (c) {
+ t.test(c, function (t) {
+ t.plan(3)
+ var prog = process.execPath
+ var args = [__filename, 'parent', c, 'beforeExitHandler']
+ var child = spawn(prog, args)
+ var out = ''
+ child.stdout.on('data', function (c) { out += c })
+ child.on('close', function (code, signal) {
+ t.equal(signal, null)
+ t.equal(code, c)
+ t.equal(out, 'stdout\nbeforeExitHandler\n')
+ })
+ })
+ })
+ t.end()
+})
+
function isZero10OnTravis () {
return process.env.TRAVIS && /^v0\.10\.[0-9]+$/.test(process.version)
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-foreground-child.git
More information about the Pkg-javascript-commits
mailing list