add websocket server to this dir. fix stuff for client
This commit is contained in:
23
websocket_server/node_modules/node-cleanup/tests/bin/grandchild.js
generated
vendored
Executable file
23
websocket_server/node_modules/node-cleanup/tests/bin/grandchild.js
generated
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/******************************************************************************
|
||||
Grandchild process used to test process group signals. It conditionally ignores SIGINTs in order to emulate programs that catch and discard them.
|
||||
******************************************************************************/
|
||||
|
||||
var heedSignal = (process.argv[2] === 'true');
|
||||
var waitMillis = parseInt(process.argv[3]);
|
||||
|
||||
if (!heedSignal) {
|
||||
process.on('SIGINT', function () {
|
||||
// ignore it
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
// disconnect IPC so can exit when stdout, stderr,
|
||||
// child processes, and other resources complete.
|
||||
process.disconnect();
|
||||
process.exit(0);
|
||||
}, waitMillis);
|
||||
|
||||
process.send('ready');
|
92
websocket_server/node_modules/node-cleanup/tests/bin/groupable.js
generated
vendored
Executable file
92
websocket_server/node_modules/node-cleanup/tests/bin/groupable.js
generated
vendored
Executable file
@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/******************************************************************************
|
||||
Child process that installs node-cleanup for testing in situations that may entail forking a grandchild process in the same process group. It accepts a single argument of serialized JSON having the following (FlowType) structure:
|
||||
|
||||
{
|
||||
grandchild: boolean; // whether to fork a grandchild process
|
||||
grandchildHeedsSIGINT: boolean; // whether grandchild heeds SIGINT
|
||||
messages: object|null; // messages argument for nodeCleanup()
|
||||
exception: boolean; // whether to throw an uncaught exception
|
||||
skipTermination: boolean; // true => cleanup handler returns false
|
||||
exitReturn: 'true'|'undefined'; // value that cleanup handler should
|
||||
// return to indicate whether the process should exit
|
||||
maxDuration: number; // max duration of process in millisecs
|
||||
}
|
||||
|
||||
exitReturn indicates the type of value that the cleanup handler returns to indicate whether the process should exit on SIGINT. Ideally, the handler would always return a boolean, but for backwards compatibility, for compatibility with the Stackoverflow solution, and to allow programmers some room for laziness when there are no child processes, an undefined return value also indicates 'true'.
|
||||
|
||||
This process implements the WCE solution described for SIGINT at https://www.cons.org/cracauer/sigint.html. That is, the process ignores a SIGINT received while a nested process is running, but sends a SIGINT to itself after a nested process terminates with SIGINT. SIGQUIT is not handled this way because it is not expected that child processes would override and ignore it.
|
||||
|
||||
The process writes behavioral results to stdout for comparison with expectations. The output includes space-delimited strings from the following list, ordered in the string by their order of occurrence:
|
||||
|
||||
cleanup - child's cleanup handler was called and performed cleanup
|
||||
skipped_cleanup - child's cleanup handler was called for SIGINT but
|
||||
did not perform cleanup because a child was running.
|
||||
grandchild=<reason> - grandchild exited for the given reason, which is
|
||||
either an integer exit code or the string name of a signal
|
||||
|
||||
The process also writes to stderr for comparison with expectations.
|
||||
******************************************************************************/
|
||||
|
||||
//// MODULES //////////////////////////////////////////////////////////////////
|
||||
|
||||
var path = require('path');
|
||||
var fork = require('child_process').fork;
|
||||
var nodeCleanup = require('../../');
|
||||
|
||||
//// CONFIGURATION ////////////////////////////////////////////////////////////
|
||||
|
||||
var config = JSON.parse(process.argv[2]);
|
||||
var grandchildFile = path.resolve(__dirname, "./grandchild.js");
|
||||
var grandchildMaxDuration = Math.round(config.maxDuration*0.5);
|
||||
|
||||
//// STATE ////////////////////////////////////////////////////////////////////
|
||||
|
||||
var grandchild = null;
|
||||
|
||||
//// MAIN /////////////////////////////////////////////////////////////////////
|
||||
|
||||
nodeCleanup(function (exitCode, signal) {
|
||||
var reason = (exitCode !== null ? exitCode : signal);
|
||||
if (grandchild !== null && reason === 'SIGINT') {
|
||||
process.stdout.write('skipped_cleanup ');
|
||||
return false;
|
||||
}
|
||||
process.stdout.write('cleanup ');
|
||||
if (config.skipTermination) {
|
||||
nodeCleanup.uninstall(); // don't cleanup again
|
||||
return false;
|
||||
}
|
||||
if (config.exitReturn === 'true')
|
||||
return true;
|
||||
}, config.messages);
|
||||
|
||||
setTimeout(function () {
|
||||
// disconnect IPC so can exit when stdout, stderr,
|
||||
// child processes, and other resources complete.
|
||||
process.disconnect();
|
||||
if (config.exception)
|
||||
throw new Error("unexpected exception");
|
||||
process.exit(0);
|
||||
}, config.maxDuration);
|
||||
|
||||
if (config.grandchild) {
|
||||
grandchild = fork(grandchildFile, [
|
||||
config.grandchildHeedsSIGINT,
|
||||
grandchildMaxDuration
|
||||
]);
|
||||
grandchild.on('message', function (msg) {
|
||||
if (msg === 'ready')
|
||||
process.send('ready');
|
||||
});
|
||||
grandchild.on('exit', function (exitCode, signal) {
|
||||
grandchild = null; // allow process to heed forthcoming SIGINT
|
||||
process.stdout.write('grandchild='+
|
||||
(exitCode !== null ? exitCode : signal) +' ');
|
||||
if (signal === 'SIGINT')
|
||||
process.kill(process.pid, signal);
|
||||
});
|
||||
}
|
||||
else
|
||||
process.send('ready');
|
75
websocket_server/node_modules/node-cleanup/tests/bin/stackable.js
generated
vendored
Executable file
75
websocket_server/node_modules/node-cleanup/tests/bin/stackable.js
generated
vendored
Executable file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/******************************************************************************
|
||||
Child process that installs node-cleanup for testing zero, one, or multiple (two) concurrent cleanup handlers. It accepts a single argument of serialized JSON having the following (FlowType) structure:
|
||||
|
||||
{
|
||||
handlers; number; // 0, 1, or 2 concurrent cleanup handlers
|
||||
messages0: object|null; // messages argument for no-cleanup call, if any
|
||||
messages1: object|null; // messages argument for 1st nodeCleanup() call
|
||||
messages2: object|null; // messages argument for 2nd nodeCleanup() call
|
||||
return1: boolean; // return value of 1st cleanup handler
|
||||
return2: boolean; // return value of 2nd cleanup handler
|
||||
uninstall: boolean; // whether to uninstall handlers before test
|
||||
maxDuration: number; // max duration of process in millisecs
|
||||
}
|
||||
|
||||
The process writes behavioral results to stdout for comparison with expectations. The output includes space-delimited strings from the following list, ordered in the string by their order of occurrence:
|
||||
|
||||
cleanup1 - the first cleanup handler ran
|
||||
cleanup2 - the second cleanup handler ran
|
||||
|
||||
The process also writes to stderr for comparison with expectations.
|
||||
******************************************************************************/
|
||||
|
||||
//// MODULES //////////////////////////////////////////////////////////////////
|
||||
|
||||
var nodeCleanup = require('../../');
|
||||
|
||||
//// CONFIGURATION ////////////////////////////////////////////////////////////
|
||||
|
||||
var config = JSON.parse(process.argv[2]);
|
||||
|
||||
//// CLEANUP HANDLERS /////////////////////////////////////////////////////////
|
||||
|
||||
function cleanup1(exitCode, signal) {
|
||||
process.stdout.write('cleanup1 ');
|
||||
if (!config.return1)
|
||||
nodeCleanup.uninstall(); // don't cleanup again
|
||||
return config.return1;
|
||||
}
|
||||
|
||||
function cleanup2(exitCode, signal) {
|
||||
process.stdout.write('cleanup2 ');
|
||||
if (!config.return2)
|
||||
nodeCleanup.uninstall(); // don't cleanup again
|
||||
return config.return2;
|
||||
}
|
||||
|
||||
//// MAIN /////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (config.handlers === 0) {
|
||||
if (config.messages0)
|
||||
nodeCleanup(config.messages0);
|
||||
else
|
||||
nodeCleanup();
|
||||
}
|
||||
else {
|
||||
nodeCleanup(cleanup1, config.messages1);
|
||||
if (config.handlers > 1)
|
||||
nodeCleanup(cleanup2, config.messages2);
|
||||
}
|
||||
|
||||
if (config.uninstall)
|
||||
nodeCleanup.uninstall();
|
||||
|
||||
setTimeout(function () {
|
||||
// disconnect IPC so can exit when stdout, stderr,
|
||||
// child processes, and other resources complete.
|
||||
process.disconnect();
|
||||
if (config.exception)
|
||||
throw new Error("unexpected exception");
|
||||
process.exit(0);
|
||||
}, config.maxDuration);
|
||||
|
||||
process.send('ready');
|
88
websocket_server/node_modules/node-cleanup/tests/lib/library.js
generated
vendored
Executable file
88
websocket_server/node_modules/node-cleanup/tests/lib/library.js
generated
vendored
Executable file
@ -0,0 +1,88 @@
|
||||
/******************************************************************************
|
||||
Library of functions for running child processes.
|
||||
******************************************************************************/
|
||||
|
||||
//// MODULES //////////////////////////////////////////////////////////////////
|
||||
|
||||
var MemoryStream = require('memory-streams').WritableStream;
|
||||
var path = require('path');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
//// PUBLIC CONSTANTS /////////////////////////////////////////////////////////
|
||||
|
||||
exports.DEFAULT_SIGINT_OUT = "[ctrl-C]\n";
|
||||
exports.DEFAULT_EXCEPTION_OUT = /^Uncaught exception\.\.\./;
|
||||
|
||||
//// PRIVATE CONSTANTS ////////////////////////////////////////////////////////
|
||||
|
||||
var MAX_DURATION = 250; // max duration of child process in millisecs
|
||||
|
||||
var childEnv = {};
|
||||
Object.keys(process.env).forEach(function (key) {
|
||||
childEnv[key] = process.env[key];
|
||||
});
|
||||
var childOptions = {
|
||||
env: childEnv,
|
||||
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
||||
detached: true
|
||||
};
|
||||
|
||||
//// FUNCTIONS ////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Launch a child process that uses nodeCleanup(), performing an action once the child is running, and provide the results of the run when the child exits. The child runs in a new process group, separate from the test process, so that the caller may signal the group as a whole.
|
||||
*
|
||||
* @param config Child process configuration. See the description of this structure in the comments of tests/bin/child.js.
|
||||
* @param action A callback function(childPID) that may send signals to the child or the child's process group (-childPID). Must be synchronous.
|
||||
* @param done A callback function(reason, stdoutString, stderrString) providing the output of the child. This callback should test this output against expectations. reason is the exit code, unless the process was terminated by a signal, in which case it is the string name of the signal.
|
||||
*/
|
||||
|
||||
exports.launch = function (config, action, done)
|
||||
{
|
||||
config.maxDuration = MAX_DURATION;
|
||||
var childPath = path.resolve(__dirname, "../bin/"+ config.child +".js");
|
||||
var childArgs = [ childPath, JSON.stringify(config) ];
|
||||
var child = spawn(process.execPath, childArgs, childOptions);
|
||||
var stdoutStream = new MemoryStream();
|
||||
var stderrStream = new MemoryStream();
|
||||
child.stdout.pipe(stdoutStream);
|
||||
child.stderr.pipe(stderrStream);
|
||||
|
||||
child.on('message', function (msg) {
|
||||
if (msg === 'ready')
|
||||
action(child.pid);
|
||||
});
|
||||
|
||||
child.on('exit', function (exitCode, signal) {
|
||||
done((exitCode !== null ? exitCode : signal),
|
||||
stdoutStream.toString(), stderrStream.toString());
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Shorthand function for launching a process, optionally sending a signal to it, and testing the resulting output. It calls t.equal() or t.match() on each of the expected results, depending on whether it is a string or a regular expression, and then t.end() to complete the test.
|
||||
*
|
||||
* @param t tap test instance
|
||||
* @param config See launch() config.
|
||||
* @param action See launch() action.
|
||||
* @param expectedResults A structure of the form {exitCode, stdout, stderr} containing the expected output of the test. exitCode is an integer. stdout and stderr are strings or regular expressions. stdout is compared against the result trimmed of preceding and trailing whitespace. When stdout or stderr is a string, it is tested for being identical with the actual result.
|
||||
*/
|
||||
|
||||
exports.test = function (t, config, action, expectedResults)
|
||||
{
|
||||
exports.launch(config, action, function (reason, stdout, stderr) {
|
||||
t.equal(reason, expectedResults.exitReason, "exit reason");
|
||||
|
||||
stdout = stdout.trim();
|
||||
if (typeof expectedResults.stdout === 'string')
|
||||
t.equal(stdout, expectedResults.stdout, "stdout");
|
||||
else
|
||||
t.match(stdout, expectedResults.stdout, "stdout");
|
||||
|
||||
if (typeof expectedResults.stderr === 'string')
|
||||
t.equal(stderr, expectedResults.stderr, "stderr");
|
||||
else
|
||||
t.match(stderr, expectedResults.stderr, "stderr");
|
||||
t.end();
|
||||
});
|
||||
};
|
358
websocket_server/node_modules/node-cleanup/tests/multiple.js
generated
vendored
Normal file
358
websocket_server/node_modules/node-cleanup/tests/multiple.js
generated
vendored
Normal file
@ -0,0 +1,358 @@
|
||||
// tests in which spawned child installs multiple cleanup handlers
|
||||
|
||||
var t = require('tap');
|
||||
var lib = require('./lib/library');
|
||||
|
||||
t.test("multiple handlers: normal exit", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: null,
|
||||
messages2: null,
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: uncaught exception - custom messages", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
uncaughtException: "Not the surprise you're looking for."
|
||||
},
|
||||
messages2: {
|
||||
uncaughtException: "Look! A surprise!"
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: true,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: /^Look! A surprise!/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: uncaught exception - removed message",
|
||||
function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
uncaughtException: "Not the surprise you're looking for."
|
||||
},
|
||||
messages2: {
|
||||
uncaughtException: ""
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: true,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: /tests[\/\\]bin[\/\\]stackable.js/
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
t.test("multiple handlers: uncaught exception - added message",
|
||||
function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
ctrl_C: "{^C}}"
|
||||
},
|
||||
messages2: {
|
||||
uncaughtException: "Oops!"
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: true,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: /^Oops!/
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
t.test("multiple handlers: uncaught exception - no message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: null,
|
||||
messages2: null,
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: true,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: /tests[\/\\]bin[\/\\]stackable.js/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: child SIGINT - both heeded, custom messages",
|
||||
function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
ctrl_C: "{^C1}"
|
||||
},
|
||||
messages2: {
|
||||
ctrl_C: "{^C2}"
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: "{^C2}\n"
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
t.test("multiple handlers: child SIGINT - first heeded, custom messages",
|
||||
function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
ctrl_C: "{^C1}"
|
||||
},
|
||||
messages2: {
|
||||
ctrl_C: "{^C2}"
|
||||
},
|
||||
return1: true,
|
||||
return2: false,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: ""
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
t.test("multiple handlers: child SIGINT - second heeded, custom messages",
|
||||
function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
ctrl_C: "{^C1}"
|
||||
},
|
||||
messages2: {
|
||||
ctrl_C: "{^C2}"
|
||||
},
|
||||
return1: false,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: ""
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
t.test("multiple handlers: child SIGINT - removed message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
ctrl_C: "{^C1}"
|
||||
},
|
||||
messages2: {
|
||||
ctrl_C: ""
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: child SIGINT - added message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
uncaughtException: "Oops!"
|
||||
},
|
||||
messages2: {
|
||||
ctrl_C: "{^C1}"
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: "{^C1}\n"
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: child SIGQUIT", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: null,
|
||||
messages2: null,
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGQUIT');
|
||||
}, {
|
||||
exitReason: 'SIGQUIT',
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: child SIGTERM", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: null,
|
||||
messages2: null,
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGTERM');
|
||||
}, {
|
||||
exitReason: 'SIGTERM',
|
||||
stdout: "cleanup1 cleanup2",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers: child SIGKILL", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: null,
|
||||
messages2: null,
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGKILL');
|
||||
}, {
|
||||
exitReason: 'SIGKILL',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers/uninstall: normal child exit", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: null,
|
||||
messages2: null,
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: true
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers/uninstall: uncaught exception", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
uncaughtException: "Shouldn't show."
|
||||
},
|
||||
messages2: {
|
||||
uncaughtException: "Also shouldn't show."
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: true,
|
||||
uninstall: true
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "",
|
||||
stderr: /tests[\/\\]bin[\/\\]stackable.js/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("multiple handlers/uninstall: child SIGINT", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 2,
|
||||
messages1: {
|
||||
ctrl_C: "{^C1}"
|
||||
},
|
||||
messages2: {
|
||||
ctrl_C: "{^C2}"
|
||||
},
|
||||
return1: true,
|
||||
return2: true,
|
||||
exception: false,
|
||||
uninstall: true
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
175
websocket_server/node_modules/node-cleanup/tests/nocleanup.js
generated
vendored
Normal file
175
websocket_server/node_modules/node-cleanup/tests/nocleanup.js
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
// tests in which spawned child uses the default cleanup handler
|
||||
|
||||
var t = require('tap');
|
||||
var lib = require('./lib/library');
|
||||
|
||||
t.test("nocleanup: normal child exit", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: uncaught exception - default message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: true,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "",
|
||||
stderr: lib.DEFAULT_EXCEPTION_OUT
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: uncaught exception - custom message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
messages0: {
|
||||
uncaughtException: "Yikes!"
|
||||
},
|
||||
exception: true,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "",
|
||||
stderr: /^Yikes!/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: child SIGINT - default message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "",
|
||||
stderr: lib.DEFAULT_SIGINT_OUT
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: child SIGINT - custom message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
messages0: {
|
||||
ctrl_C: "{^C}"
|
||||
},
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "",
|
||||
stderr: "{^C}\n"
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: child SIGQUIT", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGQUIT');
|
||||
}, {
|
||||
exitReason: 'SIGQUIT',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: child SIGTERM", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGTERM');
|
||||
}, {
|
||||
exitReason: 'SIGTERM',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup: child SIGKILL", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: false
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGKILL');
|
||||
}, {
|
||||
exitReason: 'SIGKILL',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup/uninstall: normal child exit", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: true
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup/uninstall: uncaught exception", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: true,
|
||||
uninstall: true
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "",
|
||||
stderr: /tests[\/\\]bin[\/\\]stackable.js/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("nocleanup/uninstall: child SIGINT", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'stackable',
|
||||
handlers: 0,
|
||||
exception: false,
|
||||
uninstall: true
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
399
websocket_server/node_modules/node-cleanup/tests/single.js
generated
vendored
Normal file
399
websocket_server/node_modules/node-cleanup/tests/single.js
generated
vendored
Normal file
@ -0,0 +1,399 @@
|
||||
// tests in which spawned child installs a custom cleanup handler
|
||||
|
||||
var t = require('tap');
|
||||
var lib = require('./lib/library');
|
||||
|
||||
t.test("single: normal child exit - true return", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: normal child exit - undefined return", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'undefined'
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: normal grandchild exit", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "grandchild=0 cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: uncaught exception - custom message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: {
|
||||
uncaughtException: "Oh gosh look what happened:"
|
||||
},
|
||||
exception: true,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "cleanup",
|
||||
stderr: /^Oh gosh look what happened:/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: uncaught exception - no message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: {
|
||||
uncaughtException: ""
|
||||
},
|
||||
exception: true,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
// no signal
|
||||
}, {
|
||||
exitReason: 1,
|
||||
stdout: "cleanup",
|
||||
stderr: /^Error: unexpected exception/
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGINT - true return, custom message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: {
|
||||
ctrl_C: "{^C}"
|
||||
},
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "cleanup",
|
||||
stderr: "{^C}\n"
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGINT - undefined return, custom message",
|
||||
function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: {
|
||||
ctrl_C: "{^C}"
|
||||
},
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'undefined'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "cleanup",
|
||||
stderr: "{^C}\n"
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
t.test("single: child SIGINT - no message", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: group SIGINT - grandchild ignores", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: {
|
||||
ctrl_C: "{^C}"
|
||||
},
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(-childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "skipped_cleanup grandchild=0 cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: group SIGINT - grandchild heeds", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: true,
|
||||
messages: {
|
||||
ctrl_C: "{^C}"
|
||||
},
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(-childPID, 'SIGINT');
|
||||
}, {
|
||||
exitReason: 'SIGINT',
|
||||
stdout: "skipped_cleanup grandchild=SIGINT cleanup",
|
||||
stderr: "{^C}\n"
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGHUP - exiting", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGHUP');
|
||||
}, {
|
||||
exitReason: 'SIGHUP',
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGHUP - non-exiting", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: true,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGHUP');
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: group SIGHUP", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(-childPID, 'SIGHUP');
|
||||
}, {
|
||||
exitReason: 'SIGHUP',
|
||||
// grandchild may exit before,during, or after child exits
|
||||
stdout: /^(cleanup( grandchild=SIGHUP)?|grandchild=SIGHUP cleanup)$/,
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGQUIT - exiting", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGQUIT');
|
||||
}, {
|
||||
exitReason: 'SIGQUIT',
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGQUIT - non-exiting", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: true,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGQUIT');
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: group SIGQUIT", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(-childPID, 'SIGQUIT');
|
||||
}, {
|
||||
exitReason: 'SIGQUIT',
|
||||
// grandchild may exit before,during, or after child exits
|
||||
stdout: /^(cleanup( grandchild=SIGQUIT)?|grandchild=SIGQUIT cleanup)$/,
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGTERM - exiting", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGTERM');
|
||||
}, {
|
||||
exitReason: 'SIGTERM',
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGTERM - non-exiting", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: true,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGTERM');
|
||||
}, {
|
||||
exitReason: 0,
|
||||
stdout: "cleanup",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: group SIGTERM", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(-childPID, 'SIGTERM');
|
||||
}, {
|
||||
exitReason: 'SIGTERM',
|
||||
// grandchild may exit before,during, or after child exits
|
||||
stdout: /^(cleanup( grandchild=SIGTERM)?|grandchild=SIGTERM cleanup)$/,
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: child SIGKILL", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: false,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(childPID, 'SIGKILL');
|
||||
}, {
|
||||
exitReason: 'SIGKILL',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
||||
|
||||
t.test("single: group SIGKILL", function (t) {
|
||||
lib.test(t, {
|
||||
child: 'groupable',
|
||||
grandchild: true,
|
||||
grandchildHeedsSIGINT: false,
|
||||
messages: null,
|
||||
exception: false,
|
||||
skipTermination: false,
|
||||
exitReturn: 'true'
|
||||
}, function (childPID) {
|
||||
process.kill(-childPID, 'SIGKILL');
|
||||
}, {
|
||||
exitReason: 'SIGKILL',
|
||||
stdout: "",
|
||||
stderr: ""
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user