Andy Armstrong wrote:
>> Its not either / or. They're complimentary. Most test failure
>> diagnostics
>> are going to be structured and use structured YAML diagnostics. But
>> sometimes
>> you just need to print a line of text. And outputting a full blown YAML
>> document for that is visual overkill. For that there's the logging
>> syntax.
>
> Ah. Penny drops. Thanks.
Oh good, I'm glad that's cleared up.
>> Oh, that's easy.
>>
>> is( 23, 42, { foo => "bar", name => "is 23 42?" });
>>
>> If the "name" argument is a hash ref we interpret it instead as extra
>> diagnostics.
>
> That's OK in the simple case but you might want to see if the test
> failed and then do some work to build the diagnostic data. So you'd have
> to optionally be able to
>
> is ( 23, 42 );
> my $info = { foo => "bar", name => "is 23 42?" };
> details( $info );
Ahh, the ok() or diag() case. Currently expressed like so:
ok( open FILE, $filename ) or diag("Can't open $filename: $!");
In the producer it can be as simple as having a function which is defined to
spit out structured diagnostics associated with the last test.
In the TAP stream the association between a block of YAML and a particular
test could be made explicit by putting the test number in the block.
not ok 5
---
test: 5
got: 23
expected: 42
...
This would be optional. How's that?
>> The TAP parser simply starts at /^\s+---\s*$/ and ends at either
>> /^\s+...\s*$/
>> or the next test line. This means the TAP parser needs no knowledge
>> of YAML,
>> just the start and end of document delimiters. It also allows the TAP
>> parser
>> to pass a complete document to the YAML parser, the YAML parser does
>> not have
>> to stream. Means you can use most off-the-shelf YAML parsers.
>
> I think it's worthwhile to define the subset of YAML that we expect to
> see. If you just say it's YAML then potentially you're requiring the
> baggage of a hugely complex parser.
OTOH someone else has already written that hugely complex parser... well,
unfortunately in the case of YAML that might not be true.
This I would like to shelve the discussion of what subset of YAML to use for
the moment if you don't mind, until we've worked out all this other
surrounding detail. I feel it will be another long process.