GerHobbelt / jison

bison / YACC / LEX in JavaScript (LALR(1), SLR(1), etc. lexer/parser generator)
https://gerhobbelt.github.io/jison/
MIT License
117 stars 20 forks source link

Fix issues which make jison / jison-lex / ... tests fail when run under istanbul/nyc code coverage #32

Closed GerHobbelt closed 6 years ago

GerHobbelt commented 6 years ago

Code instrumentation for coverage analysis causes the generated parsers/lexers/misc code to fail, hence the mocha test suits fail dramatically when run under istanbul/nyc code coverage.

Guess: This is probably related to #7 as this is yet another code rewriting issue with the jison tool itself. Trouble is very probably due to code being stringified, then edited, then fed back into eval()/new Function()/similar 'live' code generation constructs.

Use https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md as a hint list too as the jison core should be 'text-rather-than-code' fixed, while unit tests injecting action code as JavaScript functions, etc. can be nudged into cooperation by using the /* istanbul ignore ... */ marker documented in the URL https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md .

GerHobbelt commented 6 years ago

Related matter: https://github.com/gotwarlost/istanbul/issues/856

GerHobbelt commented 6 years ago

Fixed since today's release 0.6.1-215. All tests and examples behave the same when executed the normal way or when run via nyc.

jison make now includes all-around code coverage analysis near the end of the build phase; the compound/summary report ends up in the /coverage/lcov-report/ directory as per nyc/istanbul default.