Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(runner): wait for debugger using then block (#4014)
Browse files Browse the repository at this point in the history
Closes #3898
  • Loading branch information
sjelin committed Jan 27, 2017
1 parent 46c8898 commit 41b4fcc
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class Runner extends EventEmitter {
plugins_: Plugins;
restartPromise: q.Promise<any>;
frameworkUsesAfterEach: boolean;
ready_?: wdpromise.Promise<void>;

constructor(config: Config) {
super();
Expand All @@ -49,16 +50,18 @@ export class Runner extends EventEmitter {
process['_debugProcess'](process.pid);
let flow = wdpromise.controlFlow();

flow.execute(() => {
let nodedebug = require('child_process').fork('debug', ['localhost:5858']);
process.on('exit', function() {
nodedebug.kill('SIGTERM');
});
nodedebug.on('exit', function() {
process.exit(1);
});
}, 'start the node debugger');
flow.timeout(1000, 'waiting for debugger to attach');
this.ready_ = flow.execute(() => {
let nodedebug =
require('child_process').fork('debug', ['localhost:5858']);
process.on('exit', function() {
nodedebug.kill('SIGTERM');
});
nodedebug.on('exit', function() {
process.exit(1);
});
}, 'start the node debugger').then(() => {
return flow.timeout(1000, 'waiting for debugger to attach');
});
}

if (config.capabilities && config.capabilities.seleniumAddress) {
Expand Down Expand Up @@ -304,9 +307,13 @@ export class Runner extends EventEmitter {
throw new Error('Spec patterns did not match any files.');
}

// 1) Setup environment
// noinspection JSValidateTypes
return this.driverprovider_.setupEnv()
// 0) Wait for debugger
return q(this.ready_)
.then(() => {
// 1) Setup environment
// noinspection JSValidateTypes
return this.driverprovider_.setupEnv();
})
.then(() => {
// 2) Create a browser and setup globals
browser_ = this.createBrowser(plugins);
Expand Down

0 comments on commit 41b4fcc

Please sign in to comment.