Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Fix assert event position #20

Closed
wants to merge 2 commits into from
Closed

Fix assert event position #20

wants to merge 2 commits into from

Conversation

simov
Copy link

@simov simov commented May 31, 2015

Fixes #18
Closes #19

Thanks for the thorough explanation, @isaacs , my solution was to simply emit any cached single line assert result, or if not followed by yamlish starting line, before parsing (respectively emitting) anything else.

// assert from previous line
if (this.current) {
  var indent = line.match(/^[ \t]+/)
  if (indent) {
    indent = indent[0]
    // not beginning of yamlish, and not already in yamlish
    if (line !== indent + '---\n' && !this.yind && !this.yamlish) {
      this.emitResult()
    }
  // single line assert
  } else {
    this.emitResult()
  }
}

Then I changed the position of all of the assert events for single assert lines one by one by hand, just to make sure the logic is correct (except tap-tests-stdout and tap-tests that I generated). So even if you don't like my solution, you can still pick the tests fix commit and test your solution against that, because this is the correct event order anyway.

indent = indent[0]
// not beginning of yamlish, and not already in yamlish
if (line !== indent + '---\n' && !this.yind && !this.yamlish) {
this.emitResult()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails to parse valid tap.

TAP version 13
1..1
not ok 1 - please keep my diags
  # the diags are coming
  ---
  after: comment
  ...

This will cause it to lose the diags and emit them as "extra" lines.

isaacs added a commit that referenced this pull request May 31, 2015
Keep a queue of comments that occur when we're waiting on potential
diags for a previous assert.

Then emit those comment events all at once when we are sure that either
the test point line is finished (without diags) or that the diags are
done.

Fix #18
Fix #19
Fix #20
@isaacs isaacs mentioned this pull request May 31, 2015
@isaacs isaacs closed this May 31, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comment/assert events are emitted in the wrong order if interleaved
2 participants