Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for node debugging

  • Loading branch information...
commit f8da18a2f7e830a07f13b24ed8df76b8afaa6981 1 parent 6af0002
@simondean authored
Showing with 43 additions and 11 deletions.
  1. +8 −0 bin/myriad-cucumber
  2. +35 −11 lib/myriad_cucumber.js
View
8 bin/myriad-cucumber
@@ -51,6 +51,12 @@ var optimist = Optimist
boolean: true,
default: false,
describe: 'Enables cucumber\'s dry run mode'
+ })
+ .options('debug', {
+ describe: 'Starts cucumber workers in debug mode. Pass a number to set the port the first worker should listen on. Subsequent workers will increment the port number. Default debug port is the node.js standard of 5858'
+ })
+ .options('debug-brk', {
+ describe: 'Starts cucumber workers in debug mode and breaks on the first line. Accepts an optional port number like --debug'
});
var argv = optimist.argv;
@@ -66,6 +72,8 @@ else {
localPackage: argv['local-package'],
workers: argv.workers,
dryRun: argv['dry-run'],
+ debug: argv.debug,
+ debugBrk: argv['debug-brk'],
features: argv._
};
View
46 lib/myriad_cucumber.js
@@ -150,8 +150,6 @@ MyriadCucumber.prototype._executeFeaturesOnMyriadServer = function(options, call
Debug('Found ' + tasks.length + ' tasks to execute');
Debug('Execution will be limited to ' + options.workers + ' workers');
- var workerCount = 0;
-
var firstReport = true;
var workers = [];
@@ -159,10 +157,8 @@ MyriadCucumber.prototype._executeFeaturesOnMyriadServer = function(options, call
tasks,
options.workers,
function(task, callback) {
- var workerIndex = workerCount++;
-
var worker = new Worker({
- workerIndex: workerIndex,
+ workerIndex: task.workerIndex,
myriadServerUrl: options.myriadServerUrl,
taskOptions: task.options,
featurePath: task.featurePath,
@@ -237,26 +233,54 @@ MyriadCucumber.prototype._executeFeaturesOnMyriadServer = function(options, call
MyriadCucumber.prototype._getWorkerTasks = function(options, callback) {
var tasks = [];
+ var workerCount = 0;
+ var debugArgName;
+ var firstDebugPort;
+
+ if (options.debug) {
+ Debug('Enabling node debug mode')
+ debugArgName = '--debug';
+ firstDebugPort = options.debug;
+ }
+ else if (options.debugBrk) {
+ Debug('Enabling node debug mode, breaking on first line')
+ debugArgName = '--debug-brk';
+ firstDebugPort = options.debugBrk;
+ }
- var extraArgs = [];
-
- if (options.dryRun) {
- extraArgs.push('--dry-run');
+ if (debugArgName) {
+ if (typeof firstDebugPort !== 'number') {
+ firstDebugPort = 5858;
+ }
+ Debug('Debug ports starting from ' + firstDebugPort);
}
options.featurePaths.forEach(function(featurePath) {
Object.keys(options.profiles).forEach(function(profileName) {
+ var workerIndex = workerCount++;
var profile = options.profiles[profileName];
-
+ var args = profile.args.slice();
var env = profile.env || {};
+
+ if (debugArgName) {
+ args.unshift(debugArgName + '=' + (firstDebugPort + workerIndex));
+ }
+
+ if (options.dryRun) {
+ args.push('--dry-run');
+ }
+
+ args.push(featurePath);
+
env.MYRIAD_CUCUMBER_PROFILE = profileName;
var task = {
+ workerIndex: workerIndex,
options: {
package: options.package,
localPackage: options.localPackage,
bin: profile.bin,
- args: profile.args.concat(extraArgs, [featurePath]),
+ args: args,
env: env
},
profileName: profileName,
Please sign in to comment.
Something went wrong with that request. Please try again.