fix(launcher): force send SIGINT when spawned via subprocess #1051

Merged
merged 1 commit into from Jan 28, 2016

Projects

None yet

2 participants

@vvo
Member
vvo commented Jan 25, 2016

So basically, when doing a wrapper that will spawn wdio, if you do CTRL+C on wrapper or if you send SIGINT to the spawned wdio then the child runners will not get killed and selenium sessions will not be cleaned.

With this fix I am able to do a simple watch/relaunch runner on top of wdio, code:

import webpack from 'webpack';
import config from './webpack.config.jsdelivr.babel.js';
import debounce from 'lodash/function/debounce';

import {spawn} from 'child_process';

const compiler = webpack(config);
let wdio;
const launch = debounce(() => {
  if (wdio) {
    console.log('Restarting tests');
    wdio.kill('SIGINT');
    wdio.kill('SIGINT');
  }

  wdio = spawn('wdio', ['functional-tests/wdio.conf.js'], {stdio: [null, process.stdout, null]});
}, 1500, {
  leading: true,
  trailing: true
});

compiler.watch({
  aggregateTimeout: 300,
  usePolling: true
}, compilationDone);

function compilationDone(err) {
  if (err) {
    throw err;
  }

  console.log('Got webpack compilation event');

  launch();
}
@vvo vvo fix(launcher): force send SIGINT when spawned via subprocess
b02c7c4
@christian-bromann
Member

Noice, thanks!

@christian-bromann christian-bromann merged commit ddcc12f into master Jan 28, 2016

0 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/travis-ci/push The Travis CI build failed
Details
coverage/coveralls Coverage decreased (-21.2%) to 60.427%
Details
@christian-bromann christian-bromann deleted the vvo-launcher-SIGINT branch Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment