Commit f92de3f9 f92de3f9485803222230ce77ac1f3c8c9924d083 by Nicolas Perriault

fixed #250 - prevent self tests to be run using the `casper test` command

1 parent 2f60c14c
......@@ -65,6 +65,7 @@ The documentation has been [updated accordingly](http://casperjs.org/api.html#ca
- [Casper.resourceExists()](http://casperjs.org/api.html#casper.resourceExists) and related functions now checks for non HTTP-404 received responses.
- closes [#230](https://github.com/n1k0/casperjs/issues/230) - added [`ClientUtils.getElementsBound()`](http://casperjs.org/api.html#clientutils.getElementsBounds) and [`Casper.getElementsBound()`](http://casperjs.org/api.html#casper.getElementsBounds)
- fixed [#250](https://github.com/n1k0/casperjs/issues/250) - prevent self tests to be run using the standard `casper test` command
- fixes [#254](https://github.com/n1k0/casperjs/issues/254) - fix up one use of qsa, hit when filling forms with missing elements
2012-10-01, v1.0.0-RC2
......
......@@ -278,6 +278,7 @@ function bootstrap(global) {
phantom.casperArgs.drop("test");
} else if (phantom.casperArgs.get(0) === "selftest") {
phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js'));
phantom.casperSelfTest = true;
phantom.casperArgs.options.includes = fs.pathJoin(phantom.casperPath, 'tests', 'selftest.js');
if (phantom.casperArgs.args.length > 1) {
// we want a single test file
......
......@@ -14,6 +14,19 @@ var casper = require('casper').create({
});
// local utils
function checkSelfTest(tests) {
var isCasperTest = false;
tests.forEach(function(test) {
var testDir = fs.absolute(fs.dirname(test));
if (fs.isDirectory(testDir)) {
if (fs.exists(fs.pathJoin(testDir, '.casper'))) {
isCasperTest = true;
}
}
});
return isCasperTest;
}
function checkIncludeFile(include) {
var absInclude = fs.absolute(include.trim());
if (!fs.exists(absInclude)) {
......@@ -54,6 +67,12 @@ if (casper.cli.args.length) {
casper.exit(1);
}
// check for casper selftests
if (!phantom.casperSelfTest && checkSelfTest(tests)) {
casper.warn('To run casper self tests, use the `selftest` command.');
casper.exit(1);
}
// includes handling
this.loadIncludes.forEach(function(include){
var container;
......