thlorenz / redeyed

Takes JavaScript code, along with a config and returns the original code with tokens wrapped and/or replaced as configured.
MIT License
25 stars 7 forks source link

Make the smoke tests more robust #12

Closed ariya closed 8 years ago

ariya commented 8 years ago

Skip any source file that is either syntactically invalid (e.g. async-map-ordered.js) or does not contain the var keyword (checked by tokenizing the source).

ariya commented 8 years ago

@thlorenz This should be a good trade-off between redeyed processing as many files as possible (smoke testing) and avoiding any false positives.

thlorenz commented 8 years ago

Yeah seems great, only would bite us if the esprima parser ever wouldn't detect var statements as then that wouldn't be caught as we're using the same parser to prove to use if they are there or not. i.e. the code we use to validate the tests is very similar to the code we are testing.

However I trust that is very unlikely, so LGTM. Please merge to master. No release will be necessary as only tests are affected.

ariya commented 8 years ago

Thanks @thlorenz, I'll merge it soon.

Note that I agree on the possibility of missing a test case. It is unlikely to happen, though, because we use Esprima tokenizer (and not the parser).

The only other alternative I can think of is to build a simplified tokenizer that skips any block comments and line comments, and then search for var after those comments are scrubbed. However, I doubt that it will be more robust and cleaner that simply using Esprima tokenizer as is.