scottcorgan / tap-out

A different tap parser
MIT License
23 stars 28 forks source link

fails to parse yaml block info without `not ok` #15

Closed keithamus closed 6 years ago

keithamus commented 8 years ago

Hi @scottcorgan! Thanks for the project, I've been playing with it recently - but I've noticed a couple of issues around yaml blocks I thought I'd address.

Summary

If a test is marked as anything but not ok - but includes diagnostic output via a yaml block, then tap-out will crash, and not parse any of the results.

Details

Here's the smallest TAP output I can generate that passes with a yaml block:

not ok 1 - a test
  ---
    a: b
  ...

Now, here's one that fails:

ok 1 - a test
  ---
    a: b
  ...

The error it fails with:

TypeError: Cannot read property 'name' of undefined
  at Parser._handleError (./tap-out/index.js:165:19)
  at Parser.handleLine (./tap-out/index.js:44:8)
  at Stream.<anonymous> (./tap-out/index.js:199:14)
  at emitOne (events.js:77:13)
  at Stream.emit (events.js:169:7)
  at drain (./through/index.js:36:16)
  at Stream.stream.queue.stream.push (./through/index.js:45:5)
  at emit (./tap-out/node_modules/split/index.js:37:14)
  at next (./tap-out/node_modules/split/index.js:49:7)
  at Stream.<anonymous> (./tap-out/node_modules/split/index.js:54:5)

It seems to be relying on there only being an error block when the test result is not ok. For example comments can be in between the test result and the yaml block and its fine:

not ok - a test
# Diagnostic
  ---
  a: b
  ...

Whereas if we just change not ok to ok, it fails with the same error above.

ok - a test
# Diagnostic
  ---
  a: b
  ...

Other info

scottcorgan commented 8 years ago

Will be fixed in the 2.0 rewrite.

scottcorgan commented 6 years ago

This should be fixed now