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

chore(runner): wait for debugger using then block #4014

Merged
merged 1 commit into from
Jan 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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