Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAP flavour for subtests #1

Open
eliasvasylenko opened this issue Aug 28, 2021 · 1 comment
Open

TAP flavour for subtests #1

eliasvasylenko opened this issue Aug 28, 2021 · 1 comment

Comments

@eliasvasylenko
Copy link
Contributor

Specification work on TAP stalled before settling on subtest semantics.

Looking at the JS community (and to some extent e.g. the Perl community) it looks like people who want to pin subtest semantics onto the side of TAP 13 use some variation on the four-space-indent encoding proposed in the above issue.

It has a lot going for it;

  • Already seen some adoption.
  • Existing consumers should at least be forwards compatible with it, if they don't support it directly.
    • No false negatives.
    • No false positives, given the requirement that a parent test MUST fail if any enclosed subtests fail.
  • Supports streaming.
  • Easy to read for humans; we intuitively understand indentation as an encoding of structure.
  • Easy to read for computers and composes well; a subtest is essentially itself a valid TAP stream, with just a simple line-by-line transformation to embed into/extract from an enclosing stream.

But it has some outstanding objections;

  • indentation is also used to help delineate YAML sections and this can confuse some parsers.
  • Concurrency. It is an inherently serial format, meaning subtests either have to be run one at a time, or their results have to be buffered so they can be pushed out all at once.
@eliasvasylenko
Copy link
Contributor Author

Regarding the concurrency, i do think there is a possible solution that supports streaming.

Given that TestAnything/Specification#14, would break forwards compatibility, I would instead challange the prevailing assumption in the #2 thread that we need to associate a subtest line with the number of its enclosing test point. Instead we can associate it with the description. This is something like that was touched on here TestAnything/Specification#15, but again no consensus was reached.

So to illustrate, taking the following results:

    1..2
    ok 1 - a subtest
    ok 2 - a second subetest
ok 1 - some test
        ok 1 - sub-sub-test
        1..1
    ok 1 - a subtest
    ok 2 - subtest number two
    1..2
ok 2 - another test

If the producer wants to execute tests and subtests concurrently, it can prefix them with tags instead of just spaces:

[some test]  1..2
[some test]  ok 1 - a subtest
[another test]  [a subtest]  ok 1 - sub-sub-test
[another test]  [a subtest]  1..1
[another test]  ok 1 - a subtest
[another test]  ok 2 - subtest number two
[another test]  1..2
ok 1 - another test
[some test]  ok 2 - a second subetest
ok 2 - some test

There's a lot of repetition, but it may be more readable that the alternatives.

  • Using human-readable text instead of a number makes associated lines easier to differentiate a glance as they are more visually distinct that a sea of numbers.
  • Formatting the prefix as something like [test description] or test description| creates a sort of margin, so it's not too hard to refocus attention to the embedded TAP for a subtest.
  • For consumers it only requires a generalisation of the same machinery behind reading indented subtests. Incremental extra complexity, one more layer of abstraction, rather than completely new and different semantics.

eliasvasylenko added a commit to eliasvasylenko/ducktest that referenced this issue Sep 9, 2021
- added optional plan for number of tests, and included plan output
for TAP report, automatically counting and putting at end if not
given. This fixes StrangeSkies#17

- changed format for the diagnostic line that introduces a subtest.
Switched it from a diagnostic to `[description]` to make it more
consistent with the plan for concurrent subtests as per StrangeSkies#1. This
is still forwards compatible with existing TAP parsers.

- added TAP version line at start of report output.

This commit also includes some refinement of Stream/Reporter/Report
API; now we don't always assume that a report must be associated
with an output stream. It's totally possible that this isn't always
the case!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant