Skip to content
Myr

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 file

Take it

feature: support for signals to subcommands (#632)Thomas Simoensbefore adoption1e4c689

lines 1–33why, one step back
1var spawn = require('child_process').spawn,
2 path = require('path'),3 should = require('should');45var bin = path.join(__dirname, './fixtures/pm');6var proc = spawn(bin, ['listen'], {});78var output = '';9proc.stdout.on('data', function (data) {10 output += data.toString();11});1213// Set a timeout to give 'proc' time to setup completely14setTimeout(function () {15 proc.kill('SIGUSR1');1617 // Set another timeout to give 'prog' time to handle the signal18 setTimeout(function() {19 /*20 * As described at https://nodejs.org/api/process.html#process_signal_events21 * this signal will start a debugger and thus the process might output an22 * additional error message: 23 * 24 * "Failed to open socket on port 5858, waiting 1000 ms before retrying".25 * 26 * Therefore, we are a bit more lax in matching the output.27 * It must contain the expected output, meaning an empty line containing28 * only "SIGUSR1", but any other output is also allowed.29 */30 output.should.match(/(^|\n)SIGUSR1\n/);31 }, 1000);3233}, 2000);