Permalink
Browse files

Will now start an embedded myriad server if no myriad server URL is p…

…rovided
  • Loading branch information...
simondean committed May 25, 2013
1 parent d83f06e commit bf8cb809c7f16d16687656985efd915b7fb2dae1
Showing with 53 additions and 18 deletions.
  1. +5 −2 README.md
  2. +10 −3 bin/myriad-cucumber
  3. +1 −3 example/package.json
  4. +33 −8 lib/{myriad-cucumber.js → myriad_cucumber.js}
  5. +4 −2 package.json
View
@@ -77,9 +77,12 @@ doesn't support the HTML or pretty formatters.
### Run
-myriad-cucumber is executed like this:
+myriad-cucumber is executed by running the following commands in two separate terminals:
``` shell
$ node_modules/.bin/myriad-server
-$ node_modules/.bin/myriad-cucumber --workers 4 --myriad-server http://localhost:7777 --local-package
+```
+
+``` shell
+$ node_modules/.bin/myriad-cucumber --workers 4 --myriad-server http://localhost:7777
```
View
@@ -4,7 +4,7 @@
var Optimist = require('optimist');
var Debug = require('debug')('myriad-cucumber')
-var MyriadCucumber = require('../lib/myriad-cucumber');
+var MyriadCucumber = require('../lib/myriad_cucumber');
function exit(code) {
if (process.stdout.write("")) {
@@ -30,7 +30,6 @@ var optimist = Optimist
})
.options('s', {
alias: 'myriad-server',
- default: 'http://localhost:7777',
describe: 'URL of the myriad-server'
})
.options('w', {
@@ -41,6 +40,7 @@ var optimist = Optimist
.options('l', {
alias: 'local-package',
boolean: true,
+ default: false,
describe: 'For use when running myriad-server locally. If true, use locally installed package instead of sending a tarball of the package to myriad-server'
});
var argv = optimist.argv;
@@ -50,7 +50,14 @@ if (argv.help) {
exit(0);
}
else {
- MyriadCucumber(argv).run(function(err, report) {
+ var options = {
+ myriadServerUrl: argv['myriad-server'],
+ configFile: argv['config'],
+ localPackage: argv['local-package'],
+ workers: argv.workers
+ };
+
+ MyriadCucumber(options).run(function(err, report) {
if (err) {
Debug('Exiting');
console.error(err);
View
@@ -1,16 +1,14 @@
{
"name": "myriad-cucumber-example",
"description": "Exmaple test codebase that uses myriad-cucumber",
- "version": "0.1.0",
"private": true,
"author": "Simon Dean <simon@simondean.org> (http://www.simondean.org)",
"contributors": [],
"engines": {
"node": ">=0.6"
},
"dependencies": {
- "cucumber": "~0.3.0",
- "async": "~0.2.8"
+ "cucumber": "~0.3.0"
},
"devDependencies": {},
"licenses": [
@@ -1,19 +1,45 @@
var Async = require('async');
var Myriad = require('myriad');
+var MyriadServer = require('myriad-server');
var Path = require('path');
var Debug = require('debug')('myriad-cucumber')
var FeatureFinder = require('./feature_finder');
+var Freeport = require('freeport');
-var MyriadCucumber = function(argv) {
+var MyriadCucumber = function(options) {
var self = {
run: function(callback) {
- var configFile = argv['config'];
- var localPackage = argv['local-package'];
+ var configFile = options.configFile;
+ var localPackage = options.localPackage;
var config = require(Path.resolve(configFile));
Async.parallel(
[
+ function(callback) {
+ if (options.myriadServerUrl) {
+ callback(null, options.myriadServerUrl);
+ }
+ else {
+ Async.waterfall(
+ [
+ Freeport,
+ function(port, callback) {
+ MyriadServer({ port: port });
+ callback(null, port);
+ }
+ ],
+ function(err, port) {
+ if (err) {
+ callback(err);
+ }
+ else {
+ callback(null, 'http://localhost:' + port);
+ }
+ }
+ )
+ }
+ },
function(callback) {
if (config.features.length == 0) {
callback({ message: "No features have been specified" });
@@ -52,10 +78,9 @@ var MyriadCucumber = function(argv) {
callback(err);
}
else {
- var featureFiles = results[0];
- var package = results[1];
-
- var myriadServerUrl = argv['myriad-server'];
+ var myriadServerUrl = results[0];
+ var featureFiles = results[1];
+ var package = results[2];
Debug('Spawning cucumber instances');
@@ -81,7 +106,7 @@ var MyriadCucumber = function(argv) {
Async.mapLimit(
tasks,
- argv.workers,
+ options.workers,
function(task, callback) {
var workerIndex = workerCount++;
var debugPrefix = '#' + workerIndex + ' '
View
@@ -1,6 +1,6 @@
{
"name": "myriad-cucumber",
- "description": "myriad task that executes tests through cucumber-js",
+ "description": "Uses myriad to execute cucumber tests across multiple processes or machines",
"keywords": [
"cucumber",
"cucumber-js",
@@ -28,10 +28,12 @@
},
"dependencies": {
"myriad": "~0.1.0",
+ "myriad-server": "~0.1.0",
"optimist": "~0.4.0",
"async": "~0.2.7",
"glob": "~3.2.1",
- "debug": "~0.7.2"
+ "debug": "~0.7.2",
+ "freeport": "~1.0.0"
},
"devDependencies": {},
"bin": {

0 comments on commit bf8cb80

Please sign in to comment.