Commit a48c2c0e a48c2c0ee2fd10ff8d5fc65683723720fa73298d by Nicolas Perriault

added syntax checking for test files using esprima.js

1 parent 30e703d6
...@@ -279,9 +279,16 @@ ...@@ -279,9 +279,16 @@
279 throw "Can only exec() files with .js or .coffee extensions"; 279 throw "Can only exec() files with .js or .coffee extensions";
280 } 280 }
281 if (fileExt(file) === "coffee") { 281 if (fileExt(file) === "coffee") {
282 phantom.injectJs(file); 282 phantom.injectJs(file); // FIXME: syntax validation?
283 } else { 283 } else {
284 eval(fs.read(file)); 284 var testContents = fs.read(file);
285 var parsed;
286 try {
287 parsed = esprima.parse(testContents);
288 } catch(e) {
289 throw "Unable to parse test file " + file + ": " + e.toString();
290 }
291 eval(testContents);
285 } 292 }
286 }; 293 };
287 294
......
1 phantom.injectJs('casper.js'); 1 phantom.injectJs('casper.js');
2 phantom.injectJs('lib/vendors/esprima.js');
2 3
3 var fs = require('fs'); 4 var fs = require('fs');
4 var casper = new phantom.Casper({ 5 var casper = new phantom.Casper({
......