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 ...@@ -65,6 +65,7 @@ The documentation has been [updated accordingly](http://casperjs.org/api.html#ca
65 65
66 - [Casper.resourceExists()](http://casperjs.org/api.html#casper.resourceExists) and related functions now checks for non HTTP-404 received responses. 66 - [Casper.resourceExists()](http://casperjs.org/api.html#casper.resourceExists) and related functions now checks for non HTTP-404 received responses.
67 - 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) 67 - 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)
68 - fixed [#250](https://github.com/n1k0/casperjs/issues/250) - prevent self tests to be run using the standard `casper test` command
68 - fixes [#254](https://github.com/n1k0/casperjs/issues/254) - fix up one use of qsa, hit when filling forms with missing elements 69 - fixes [#254](https://github.com/n1k0/casperjs/issues/254) - fix up one use of qsa, hit when filling forms with missing elements
69 70
70 2012-10-01, v1.0.0-RC2 71 2012-10-01, v1.0.0-RC2
......
...@@ -278,6 +278,7 @@ function bootstrap(global) { ...@@ -278,6 +278,7 @@ function bootstrap(global) {
278 phantom.casperArgs.drop("test"); 278 phantom.casperArgs.drop("test");
279 } else if (phantom.casperArgs.get(0) === "selftest") { 279 } else if (phantom.casperArgs.get(0) === "selftest") {
280 phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js')); 280 phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js'));
281 phantom.casperSelfTest = true;
281 phantom.casperArgs.options.includes = fs.pathJoin(phantom.casperPath, 'tests', 'selftest.js'); 282 phantom.casperArgs.options.includes = fs.pathJoin(phantom.casperPath, 'tests', 'selftest.js');
282 if (phantom.casperArgs.args.length > 1) { 283 if (phantom.casperArgs.args.length > 1) {
283 // we want a single test file 284 // we want a single test file
......
...@@ -14,6 +14,19 @@ var casper = require('casper').create({ ...@@ -14,6 +14,19 @@ var casper = require('casper').create({
14 }); 14 });
15 15
16 // local utils 16 // local utils
17 function checkSelfTest(tests) {
18 var isCasperTest = false;
19 tests.forEach(function(test) {
20 var testDir = fs.absolute(fs.dirname(test));
21 if (fs.isDirectory(testDir)) {
22 if (fs.exists(fs.pathJoin(testDir, '.casper'))) {
23 isCasperTest = true;
24 }
25 }
26 });
27 return isCasperTest;
28 }
29
17 function checkIncludeFile(include) { 30 function checkIncludeFile(include) {
18 var absInclude = fs.absolute(include.trim()); 31 var absInclude = fs.absolute(include.trim());
19 if (!fs.exists(absInclude)) { 32 if (!fs.exists(absInclude)) {
...@@ -54,6 +67,12 @@ if (casper.cli.args.length) { ...@@ -54,6 +67,12 @@ if (casper.cli.args.length) {
54 casper.exit(1); 67 casper.exit(1);
55 } 68 }
56 69
70 // check for casper selftests
71 if (!phantom.casperSelfTest && checkSelfTest(tests)) {
72 casper.warn('To run casper self tests, use the `selftest` command.');
73 casper.exit(1);
74 }
75
57 // includes handling 76 // includes handling
58 this.loadIncludes.forEach(function(include){ 77 this.loadIncludes.forEach(function(include){
59 var container; 78 var container;
......