Commit a48c2c0e a48c2c0ee2fd10ff8d5fc65683723720fa73298d by Nicolas Perriault

added syntax checking for test files using esprima.js

1 parent 30e703d6
......@@ -279,9 +279,16 @@
throw "Can only exec() files with .js or .coffee extensions";
}
if (fileExt(file) === "coffee") {
phantom.injectJs(file);
phantom.injectJs(file); // FIXME: syntax validation?
} else {
eval(fs.read(file));
var testContents = fs.read(file);
var parsed;
try {
parsed = esprima.parse(testContents);
} catch(e) {
throw "Unable to parse test file " + file + ": " + e.toString();
}
eval(testContents);
}
};
......
phantom.injectJs('casper.js');
phantom.injectJs('lib/vendors/esprima.js');
var fs = require('fs');
var casper = new phantom.Casper({
......