Commit cab579d1 cab579d102e2e2ef7de7b3357b38cadd9ff296d3 by Nicolas Perriault

added the --run-tests option to auto-discover and run tests found within a given directory

1 parent ff9e8845
......@@ -263,16 +263,19 @@ if (!phantom.casperLoaded) {
if (!!phantom.casperArgs.options.version) {
console.log(phantom.casperVersion.toString());
phantom.exit(0);
} else if (!!phantom.casperArgs.get('run-tests')) {
phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js'));
} else if (phantom.casperArgs.args.length === 0 || !!phantom.casperArgs.options.help) {
var phantomVersion = [phantom.version.major, phantom.version.minor, phantom.version.patch].join('.');
console.log('CasperJS version ' + phantom.casperVersion.toString() + ' at ' + phantom.casperPath);
console.log('Using PhantomJS version ' + phantomVersion);
console.log('Usage: casperjs script.(js|coffee) [options...]');
console.log('Read the docs http://n1k0.github.com/casperjs/');
console.log(fs.read(fs.pathJoin(phantom.casperPath, 'bin', 'usage.txt')));
phantom.exit(0);
}
phantom.casperScript = phantom.casperArgs.get(0);
if (!phantom.casperScript) {
phantom.casperScript = phantom.casperArgs.get(0);
}
if (!fs.isFile(phantom.casperScript)) {
console.error('Unable to open file: ' + phantom.casperScript);
......
Usage:
$ casperjs [options] script.[js|coffee] [script argument [script argument ...]]
Read the docs http://n1k0.github.com/casperjs/
\ No newline at end of file
......@@ -41,10 +41,19 @@ exports.parse = function(phantomArgs) {
var extract = {
args: [],
options: {},
has: function(what) {
if (utils.isNumber(what)) {
return what in this.args;
} else if (utils.isString(what)) {
return what in this.options;
} else {
throw new CasperError("Unsupported cli arg tester " + typeof what);
}
},
get: function(what) {
if (typeof what === "number") {
if (utils.isNumber(what)) {
return this.args[what];
} else if (typeof what === "string") {
} else if (utils.isString(what)) {
return this.options[what];
} else {
throw new CasperError("Unsupported cli arg getter " + typeof what);
......