Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #519 from mridgway/runPath
Browse files Browse the repository at this point in the history
Adds a --path option to run.js to allow specifying a path to find the te...
  • Loading branch information
mridgway committed Sep 14, 2012
2 parents 772ad84 + 587ff0e commit 1a58bbb
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions tests/run.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

var fs = require('fs'),
path = require('path'),
wrench = require('wrench'),
libpath = require('path'),
program = require('commander'),
Expand All @@ -24,6 +25,7 @@ program.command('test')
.option('--group <value>', 'Arrow group')
.option('--driver <value>', 'Arrow driver')
.option('--browser <value>', 'Arrow browser')
.option('--path <value>', 'Path to find the tests')
.action(test);

program.command('build')
Expand All @@ -46,14 +48,16 @@ function test (cmd) {
}
cmd.unitBrowser = cmd.unitBrowser || cmd.browser || 'firefox';
cmd.funcBrowser = cmd.funcBrowser || cmd.browser || 'firefox';
cmd.unitPath = path.resolve(cwd, cmd.unitPath || cmd.path || './unit');
cmd.funcPath = path.resolve(cwd, cmd.funcPath || cmd.path || './func');
if (cmd.arrow) {
series.push(startArrowServer);
}
if (cmd.unit) {
if ('phantomjs' !== cmd.unitBrowser) {
if (cmd.selenium) {
series.push(function (callback) {
startArrowSelenium(cmd.unitBrowser, callback);
startArrowSelenium(cmd, callback);
});
}
}
Expand All @@ -70,7 +74,7 @@ function test (cmd) {
if ('phantomjs' !== cmd.funcBrowser) {
if (cmd.selenium) {
series.push(function (callback) {
startArrowSelenium(cmd.funcBrowser, callback);
startArrowSelenium(cmd, callback);
});
}
}
Expand Down Expand Up @@ -113,15 +117,15 @@ function startArrowServer (callback) {

function runUnitTests (cmd, callback) {
console.log('---Running Unit Tests---');
var arrowReportDir = cwd + '/artifacts/arrowreport/unit/';
var arrowReportDir = cmd.unitPath + '/artifacts/arrowreport/';
try {
wrench.rmdirSyncRecursive(arrowReportDir);
} catch (e) {}
wrench.mkdirSyncRecursive(arrowReportDir);

var commandArgs = [
cwd + "/../node_modules/yahoo-arrow/index.js",
cwd + "/unit/**/*_descriptor.json",
cmd.unitPath + "/**/*_descriptor.json",
"--report=true",
"--reportFolder=" + arrowReportDir
];
Expand All @@ -135,7 +139,7 @@ function runUnitTests (cmd, callback) {
cmd.group && commandArgs.push('--group=' + cmd.group);

var p = runCommand(
cwd + '/unit',
cmd.unitPath,
"node",
commandArgs,
function (code) {
Expand All @@ -150,17 +154,17 @@ function runUnitTests (cmd, callback) {
function build (cmd, callback) {
console.log('---Building Apps---');
runCommand(
cwd + '/func/applications/frameworkapp/common',
cmd.funcPath + '/applications/frameworkapp/common',
cwd + "/../bin/mojito",
['build', 'html5app', cwd + '/func/applications/frameworkapp/flatfile'],
['build', 'html5app', cmd.funcPath + '/applications/frameworkapp/flatfile'],
callback
);
}

function deploy (cmd, callback) {
console.log('---Deploying Apps---');
var appSeries = [],
appsConfig = JSON.parse(fs.readFileSync(cwd + '/func/applications/apps.json', 'utf8')),
appsConfig = JSON.parse(fs.readFileSync(cmd.funcPath + '/applications/apps.json', 'utf8')),
apps = appsConfig.applications;

for (var i=0; i<apps.length; i++) {
Expand All @@ -177,45 +181,45 @@ function deploy (cmd, callback) {
var test = mytests[j],
port = test.port ? parseInt(test.port) : null;
appSeries.push(function (callback) {
runMojitoApp(cwd + '/func/applications', app.path, port, test.param, callback);
runMojitoApp(cmd.funcPath + '/applications', app.path, port, test.param, callback);
});
})();
}
} else if (app.enabled === "true" && app.path && port) {
appSeries.push(function (callback) {
runMojitoApp(cwd + '/func/applications', app.path, port, app.param, callback);
runMojitoApp(cmd.funcPath + '/applications', app.path, port, app.param, callback);
});
}
} else if ('static' === type) {
appSeries.push(function (callback) {
runStaticApp(cwd + '/func/applications', app.path, port, app.param, callback);
runStaticApp(cmd.funcPath + '/applications', app.path, port, app.param, callback);
});
}
})();
}
async.series(appSeries, callback);
}

function startArrowSelenium (browser, callback) {
function startArrowSelenium (cmd, callback) {
console.log("---Starting Arrow Selenium---");
var commandArgs = [cwd+"/../node_modules/yahoo-arrow/arrow_selenium/selenium.js"];
commandArgs.push("--open=" + browser);
runCommand(cwd+"/func/applications/frameworkapp/common", "node", commandArgs, function () {
commandArgs.push("--open=" + cmd.funcBrowser);
runCommand(cwd, "node", commandArgs, function () {
callback(null);
});
}

function runFuncTests (cmd, callback) {
console.log('---Running Functional Tests---');
var arrowReportDir = cwd + '/artifacts/arrowreport/func/';
var arrowReportDir = cmd.funcPath + '/artifacts/arrowreport/';
try {
wrench.rmdirSyncRecursive(arrowReportDir);
} catch (e) {}
wrench.mkdirSyncRecursive(arrowReportDir);

var commandArgs = [
cwd + "/../node_modules/yahoo-arrow/index.js",
cwd + "/func/**/*_descriptor.json",
cmd.funcPath + "/**/*_descriptor.json",
"--report=true",
"--reportFolder=" + arrowReportDir
];
Expand All @@ -229,7 +233,7 @@ function runFuncTests (cmd, callback) {
cmd.group && commandArgs.push('--group=' + cmd.group);

var p = runCommand(
cwd + '/func/',
cmd.funcPath,
"node",
commandArgs,
function (code) {
Expand Down

0 comments on commit 1a58bbb

Please sign in to comment.