Subject: [tap] More uncertainty about junk lines

From: Andrew Rodland <[email-masked]>
Date: Fri, 24 Jun 2011 09:08:10 -0400

Once again I'm working on my parser and trying to deal with some
ambiguities, and I'm realizing that I may be mistaken about the handling of
junk lines. What does "any line that does not parse must be ignored" in the
draft spec really mean? Does it mean lines that couldn't possibly be TAP in
any position (in which case we can still throw an error on out-of-sequence
TAP) or does it mean any line that can't parse in *this* position, in which
case there are no true parse errors at all? In other words, is this TAP:

1..3
ok 1
ok 2
1..1
ok 3

valid with an ignored fourth line, or does it have an error on the fourth
line?

Andrew

---

From: Andrew Rodland <[email-masked]>
Date: Fri, 24 Jun 2011 09:52:16 -0400

On Fri, Jun 24, 2011 at 9:20 AM, Ovid <[email-masked]> wrote:

> >________________________________
> >From: Andrew Rodland <[email-masked]>
> >To: "[email-masked]" <[email-masked]>; "[email-masked]" <
> [email-masked]>
> >Sent: Friday, 24 June 2011, 15:08
> >Subject: [tap] More uncertainty about junk lines
> >
> >
> That's a very annoying edge case you have there, but I would argue that
> anything which *could* be parsed as a TAP line MUST be parsed as such, thus
> rendering the above invalid. Otherwise, we'd have no idea if you were
> spitting out bad TAP or something else was spitting out junk which happened
> to look like TAP.
>
> Thus:
>
> * If something *can* be parsed as a TAP line, do so, even if it renders the
> TAP document invalid.
> * If something *can't* be parsed as a TAP line, ignore it.
>

I agree entirely. I implemented the opposite behavior in TAP::Spec::Parser
and I've been uncomfortable about it ever since I have. Only allowing
"non-TAP lines" to be ignored as junk seems a lot more sane, in terms of
allowing us to reject malformed TAP and in terms of keeping parsers
manageable. I'm going to change the behavior in TAP::Spec::Parser, write a
few tests for it, and then set about clarifying the spec, maybe at YAPC.

Andrew

---

From: Ovid <[email-masked]>
Date: Fri, 24 Jun 2011 06:20:30 -0700 (PDT)

>To: "[email-masked]" <[email-masked]>; "[email-masked]" <[email-masked]>
>Once again I'm working on my parser and trying to deal with some ambiguities, and I'm realizing that I may be mistaken about the handling of junk lines. What does "any line that does not parse must be ignored" in the draft spec really mean? Does it mean lines that couldn't possibly be TAP in any position (in which case we can still throw an error on out-of-sequence TAP) or does it mean any line that can't parse in *this* position, in which case there are no true parse errors at all? In other words, is this TAP:
>1..3
>ok 1
>ok 2
>1..1
>ok 3
>valid with an ignored fourth line, or does it have an error on the fourth line?

That's a very annoying edge case you have there, but I would argue that anything which *could* be parsed as a TAP line MUST be parsed as such, thus rendering the above invalid. Otherwise, we'd have no idea if you were spitting out bad TAP or something else was spitting out junk which happened to look like TAP.
 
Thus:

* If something *can* be parsed as a TAP line, do so, even if it renders the TAP document invalid.
* If something *can't* be parsed as a TAP line, ignore it.

Cheers,
Ovid
--
Live and work overseas - http://overseas-exile.blogspot.com/
Buy the book           - http://www.oreilly.com/catalog/perlhks/
Tech blog              - http://blogs.perl.org/users/ovid/
Twitter                - http://twitter.com/OvidPerl/