test.command.executableSubcommand.signals.usr1.js
This file
Path
test/test.command.executableSubcommand.signals.usr1.js
33 lines · 1.0 KiB · JavaScript
Last changed by
feature: support for signals to subcommands (#632)Thomas Simoensbefore adoption1e4c689
History of this fileTake it
123456789101112131415161718192021222324252627282930313233var spawn = require('child_process').spawn, path = require('path'), should = require('should');
var bin = path.join(__dirname, './fixtures/pm');var proc = spawn(bin, ['listen'], {});
var output = '';proc.stdout.on('data', function (data) { output += data.toString();});
// Set a timeout to give 'proc' time to setup completelysetTimeout(function () { proc.kill('SIGUSR1');
// Set another timeout to give 'prog' time to handle the signal setTimeout(function() { /* * As described at https://nodejs.org/api/process.html#process_signal_events * this signal will start a debugger and thus the process might output an * additional error message: * * "Failed to open socket on port 5858, waiting 1000 ms before retrying". * * Therefore, we are a bit more lax in matching the output. * It must contain the expected output, meaning an empty line containing * only "SIGUSR1", but any other output is also allowed. */ output.should.match(/(^|\n)SIGUSR1\n/); }, 1000);
}, 2000);