added syntax checking for test files using esprima.js
Showing
3 changed files
with
10 additions
and
2 deletions
... | @@ -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 | ... | ... |
lib/vendors/esprima.js
0 → 100644
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment