-
Notifications
You must be signed in to change notification settings - Fork 1.4k
TAP output is inconsistent with other producers #920
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
Comments
Here is a gist containing everything discussed: https://gist.github.com/Hypercubed/96db4034dbf80317c3e9d2864265b519 |
There is no good way for us to mimic the With tests running concurrently, it's possible to jumble console output even more than what you've shown. |
Why exactly is this a problem? I don't know how |
@jamestalmage Understood, I had no expectation of fixing this issue when not using @sindresorhus From what I understand it is up to the TAP consumer to decide what to do with extra output. The reason I'm interested in this because I am writing to console.log when running Chuhai benchmarks then using This works well, using tape or blue-tape, and would like this to also work in ava. |
Doing so would require a completely separate implementation of our TAP output, specifically for When a test completes in a child process, we send a single event to the parent process, and it prints the opening Any output from the child process To accommodate your request, we would need to:
IMO, it seems like a lot of work to support a somewhat niche use. |
From the spec:
Based on that, I think printing everything else to |
Yes, I think many of the TAP consumers are relying on undocumented behavior. According to spec the test title is also to be ignored. What if the output from within the test is a yaml block? How do we ensure that goes to stout? |
The YAML block is output by the test runner, not log statements in the test. In Right now, there's really no way for you to inject additional metadata into a test for consumption by a custom TAP reporter (I think that's what you really want here, right?). I don't see why we couldn't allow something like this in the future. We would have to figure out a good API for it. IMO, that's not something we should address until we are serious about plugin support (custom assertions, etc.). |
I would like Chuhai to be compatible with ava and others without custom behavior (i.e. |
Are we OK with the TAP reporter writing output from the test worker to Is the remaining issue that we should implement |
Alternatively, |
Another issue with the TAP output I've had is that if I run it through tap-spec, it produces a "grouping" per test. Here is a sample output: I've tried consuming the TAP output of ava in both Another issue I've had is that I have no way of knowing which file a test is coming from. This is especially bad if I'm using a glob to do tests, but only have 1 test file. So here is my suggestion, split this up into two tasks, one of which is easy and can be done fast (I can probably provide a PR if wanted), the other is likely more work and can be left for later.
This would require each assert event to be transmitted to the test runner though (which I don't know if it does or not). Alternatively |
This is when there is an assertion failure? Depending on the assertion we don't necessarily have the data
Indeed, we should solve this. How does
We only emit success and failure states. I'm not opposed to collecting each assertion, though again I'd be worried if downstream TAP reporters have specific unstated requirements on assertion data. |
@novemberborn The problem with TAP is that for the most part it's largely unspecified. The spec only states that you need to declare the number of ok/not oks, and then you do the actual ok/not oks. That and support for The entire thing seems to me like a confusing half-specified text protocol that people implement their own parsers for that are to a certain extent incompatible, which is bound to lead to problem downstream. IMHO, ava would be much better served by either allowing custom reporters (which have already been dismissed because TAP is apparently supposed to solve all of these problem), or invent a streaming JSON protocol or similar (something that has easy expandable data, and cannot be misinterpreted). Simple translation from TAP for instance:
The advantage with this, is that like TAP it's streamed (one line per assert), but you get all the data inline. There is no speculation. No conventions. Sure, different keys might be used, but it should always be valid JSON. And none of the "anything not understood by a parser is ignored" bullshit that people abuse to tuck stacktraces in there. And if we want it to be standard, than create a simple standard for it. Define required, optional, and expansion fields for each assert. Figure out how to deal with grouping, etc. Or find some standard that already solves this. Because as it stands, more than 50 percent of the TAP output the TAP parser produces, is not actually TAP. It's just conventions somebody invented because they tried to shoehorn more data into TAP. It's not standard, nor specified. At least as far as I've been able to find. Now, enough of my rant. Regardless of whether we stay on TAP, do something else, or both, I think the reporter should have the option to emit each assert. So that if I wanted to I could format it like this:
|
We'd prefer if external, existing reporters can be used, rather than encouraging users to reinvent the wheel just for AVA. If there's fundamental incompatibility issues due to TAP being underspecified then that changes things. I'd then prefer a new protocol that other (Node.js) test tools can opt in to, so we can share reporters. @avajs/core?
Yea that seems sensible. #1330 is related. It'll take a fair amount of work on AVA's internals though. |
I've just reread this discussion and I don't think there's anything immediately actionable here. Please open new specific issues if I've overlooked anything. |
Description
The TAP output from AVA is inconsistent with other TAP producers in two ways.
Forgive me if either of these are a feature or reported before. There are many issues that may be related (example #392) but I couldn't find any that are exactly these issues.
Below I compare the output of ava's TAP reporter to
substack/tape
. I see the same inconsistency when comparing totapjs/node-tap
.Test Source
In ava: (using
test.cb
for comparison).outputs:
Notice that the "inside ava test" console logs appear before the test title. Additionally, the console logs are output to stderr which makes it difficult to work with TAP consumers (for example https://github.com/Hypercubed/tap-markdown).
in tape:
outputs:
Console logs are output after titles and to stdout.
Command-Line Arguments
For ava:
For tape:
Environment
The text was updated successfully, but these errors were encountered: