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 #940 from isao/tests
Browse files Browse the repository at this point in the history
fold tests/cli into tests/unit
  • Loading branch information
Isao Yagi committed Jan 19, 2013
2 parents 5931754 + 06f6b50 commit a685e46
Show file tree
Hide file tree
Showing 22 changed files with 139 additions and 164 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ before_install:
- "sh -e /etc/init.d/xvfb start"
- "wget -nv http://selenium.googlecode.com/files/selenium-server-standalone-2.28.0.jar"
- "java -jar selenium-server-standalone-2.28.0.jar -p 4444 > /dev/null &"
- "arrow_server &"
- "sleep 6"
105 changes: 0 additions & 105 deletions tests/cli/lib/lib_test_descriptor.json

This file was deleted.

53 changes: 3 additions & 50 deletions tests/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var fs = require('fs'),

program.command('test')
.description('Run unit and functional tests')
.option('-c, --cli', 'Run command line tests')
.option('-u, --unit', 'Run unit tests')
.option('-f, --func', 'Run functional tests')
.option('-s, --no-selenium', 'Don\'t run arrow_selenium')
Expand All @@ -44,28 +43,20 @@ function test (cmd) {
var series = [];
cmd.logLevel = cmd.logLevel || 'WARN';
// Default to all tests
if (!cmd.unit && !cmd.func && !cmd.cli) {
cmd.cli = true;
if (!cmd.unit && !cmd.func) {
cmd.unit = true;
cmd.func = true;
}
cmd.unitBrowser = cmd.unitBrowser || cmd.browser || 'firefox';
cmd.funcBrowser = cmd.funcBrowser || cmd.browser || 'firefox';
cmd.cliPath = path.resolve(cwd, cmd.cliPath || cmd.path || './cli');
cmd.unitPath = path.resolve(cwd, cmd.unitPath || cmd.path || './unit');
cmd.funcPath = path.resolve(cwd, cmd.funcPath || cmd.path || './func');

// We only start the Arrow server when we're running unit or functional
// tests. If we're only running cli tests we skip that since it slows things
// down without adding value.
if (cmd.arrow && (!cmd.cli || (!cmd.cli && !cmd.unit && !cmd.func))) {
// tests.
if (cmd.arrow && (!cmd.unit && !cmd.func)) {
series.push(startArrowServer);
}
if (cmd.cli) {
series.push(function (callback) {
runCliTests(cmd, callback)
});
}
if (cmd.unit) {
if ('phantomjs' !== cmd.unitBrowser) {
if (cmd.selenium) {
Expand Down Expand Up @@ -118,44 +109,6 @@ function startArrowServer (callback) {
}, 5000);
}

function runCliTests (cmd, callback) {
console.log('---Running CLI Tests---');
var arrowReportDir = cmd.cliPath + '/artifacts/arrowreport/';
try {
wrench.rmdirSyncRecursive(arrowReportDir);
} catch (e) {}
wrench.mkdirSyncRecursive(arrowReportDir);

var descriptor = cmd.descriptor || '**/*_descriptor.json';
var commandArgs = [
cwd + "/../node_modules/yahoo-arrow/index.js",
"--descriptor=" + cmd.cliPath + '/' + descriptor,
"--exitCode=true",
"--report=true",
"--reportFolder=" + arrowReportDir
];
// Unlike other test types the CLI tests force use of the nodejs driver and
// do not specify a browser since one won't be useful for CLI testing.
commandArgs.push('--driver=nodejs');

commandArgs.push('--logLevel=' + cmd.logLevel);
cmd.testName && commandArgs.push('--testName=' + cmd.testName);
cmd.group && commandArgs.push('--group=' + cmd.group);
cmd.coverage && commandArgs.push('--coverage=' + cmd.coverage);

var p = runCommand(
cmd.cliPath,
"node",
commandArgs,
function (code) {
callback(code);
}
);
p.stdout.on('data', function (data) {
process.stdout.write(data);
});
}

function runUnitTests (cmd, callback) {
console.log('---Running Unit Tests---');
var arrowReportDir = cmd.unitPath + '/artifacts/arrowreport/';
Expand Down
3 changes: 0 additions & 3 deletions tests/runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@ $basedir/bin/mojito jslint -p
$basedir/tests/run.js test -u --group server --driver nodejs
$basedir/tests/run.js test -u --group client --driver selenium

# cli tests are distinct for now; ideally these should be unit tests
$basedir/tests/run.js test -c --driver nodejs

# func tests
$basedir/tests/run.js test -f
52 changes: 52 additions & 0 deletions tests/unit/lib/app/commands/build/build_test_descriptor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[{
"settings": [ "master" ],
"name": "lib-cli-commands-tests",
"config": {
"mojitodir": "../../../../../.."
},
"commonlib": "$$config.mojitodir$$/tests/base/mojito-test.js",
"dataprovider" : {
"writer.js": {
"params": {
"test": "./test-writer.js",
"lib-DISABLED-BZ6046277": "$$config.mojitodir$$/lib/app/commands/build/writer.js",
"driver": "nodejs"
}
},
"shared.js": {
"params": {
"test": "./test-shared.js",
"lib": "$$config.mojitodir$$/lib/app/commands/build/shared.js",
"driver": "nodejs"
}
},
"index.js": {
"params": {
"test": "./test-index.js",
"lib-DISABLED-BZ6046277": "$$config.mojitodir$$/lib/app/commands/build/index.js",
"driver": "nodejs"
}
},
"scraper.js": {
"params": {
"test": "./test-scraper.js",
"lib": "$$config.mojitodir$$/lib/app/commands/build/scraper.js",
"driver": "nodejs"
}
},
"hybridapp.js": {
"params": {
"test": "./test-hybridapp.js",
"lib-DISABLED-BZ6046277": "$$config.mojitodir$$/lib/app/commands/build/hybridapp.js",
"driver": "nodejs"
}
},
"html5app.js": {
"params": {
"test": "./test-html5app.js",
"lib-DISABLED-BZ6046277": "$$config.mojitodir$$/lib/app/commands/build/html5app.js",
"driver": "nodejs"
}
}
}
}]
68 changes: 68 additions & 0 deletions tests/unit/lib/app/commands/commands_test_descriptor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[
{
"settings": [ "master" ],
"name": "lib-cli-commands-tests",
"config": {
"mojitodir": "../../../../.."
},
"commonlib": "$$config.mojitodir$$/tests/base/mojito-test.js",
"dataprovider" : {
"info.js": {
"params": {
"test": "./test-info.js",
"lib": "$$config.mojitodir$$/lib/app/commands/info.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"info1.js": {
"params": {
"test": "./test-info1.js",
"lib-DISABLED-BZ6046277": "$$config.mojitodir$$/lib/app/commands/info.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"docs.js": {
"params": {
"test": "./test-docs.js",
"lib": "$$config.mojitodir$$/lib/app/commands/docs.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"docs1.js": {
"params": {
"test": "./test-docs1.js",
"lib": "$$config.mojitodir$$/lib/app/commands/docs1.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"help.js": {
"params": {
"test": "./test-help.js",
"lib": "$$config.mojitodir$$/lib/app/commands/help.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"version.js": {
"params": {
"test": "./test-version.js",
"lib": "$$config.mojitodir$$/lib/app/commands/version.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"jslint.js": {
"params": {
"test": "./test-jslint.js",
"lib-DISABLED-BZ6046277": "$$config.mojitodir$$/lib/app/commands/jslint.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
}
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ YUI().use('test', function(Y) {
},

'test run info': function() {
info.run(null, null, function() {});
info.run(null, null, function(err, usage, die) {
A.isUndefined(err);
});
}
}));

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/lib_test_descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"page": "$$config.base$$/mojito-test.html",
"driver": "nodejs"
},
"group": "fw,server"
"group": "fw,unit,server"
},
"output-handler.server": {
"params": {
Expand Down
15 changes: 11 additions & 4 deletions tests/unit/lib/management/management_test_descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
"settings": [ "master" ],
"name": "mojito-unit-tests",
"config": {
"lib": "../../../../lib",
"base": "../../../base"
"mojitodir": "../../../.."
},
"commonlib": "$$config.base$$/mojito-test.js",
"commonlib": "$$config.mojitodir$$/tests/base/mojito-test.js",
"dataprovider" : {
"cli.js": {
"params": {
"test": "./test-cli.js",
"lib": "$$config.mojitodir$$/lib/management/cli.js",
"driver": "nodejs"
},
"group": "fw,unit,server"
},
"utils.server": {
"params": {
"lib": "$$config.lib$$/management/utils.js",
"lib": "$$config.mojitodir$$/lib/management/utils.js",
"test": "./test-utils.server.js",
"driver": "nodejs"
},
Expand Down

0 comments on commit a685e46

Please sign in to comment.