rust-lang / libtest-next

T-testing-devex experiments for new testing tools for Rust developers
https://docs.rs/pytest-rs
Apache License 2.0
55 stars 4 forks source link

Stabilize json output #42

Open epage opened 1 year ago

epage commented 1 year ago

This is to track our effort for stabilizing our json putput

Open questions

epage commented 1 year ago

@pietroalbini privately raised a concern that rendered output should be included for pretty / terse. This is to make it easier when callers need to capture json messages while still rendering output, which they did for bootstrap

On the flip side

pietroalbini commented 1 year ago

I'm trying to shift knowledge of pretty/terse to cargo and change their meaning

Would this mean there'd be no renderer in libtest anymore? That'd force anyone not using cargo to reimplement it for themselves. In addition to other build systems, compiletest uses libtest directly without cargo.

To reuse the rendered output is messy as it gets into whether its multi-threaded or not, whether multiple items are supposed to be printed per-line, the as-you-go details vs failure report, etc. This feels like a stabilization nightmare to get these scenarios to work out

A possible solution would be to have a new output event, that is emitted separately from the "normal" JSON events every time a write is called by the pretty/terse renderer.

We are trying to open the door more for custom test harnesses. Do we put the complexity on the author of harnesses or on the test reporters?

I imagine we'll eventually standardize to a small-ish number of test harnesses, while I can easily see lots of project hacking together scripts using the JSON events in CI.

epage commented 1 year ago

Would this mean there'd be no renderer in libtest anymore? That'd force anyone not using cargo to reimplement it for themselves. In addition to other build systems, compiletest uses libtest directly without cargo.

Most likely, the renderer would be frozen as-is and custom test harnesses could choose to render as they wish for default and --quiet

A possible solution would be to have a new output event, that is emitted separately from the "normal" JSON events every time a write is called by the pretty/terse renderer.

Which renderer? Both at once? If not, how does the user select?

And is this "output" supposed to literally be the equivalent of all of the write calls? Thats the only way I can see that working. We'd then likely also need to include an Event for flushing.

epage commented 1 year ago

On the upstream issue, I saw https://github.com/testing-cabal/subunit / https://github.com/mtreinish/subunit-rust mentioned and will need to take a look, either for inspiration or if we can use it outright.

epage commented 1 year ago

pytest's test / testsuite property might be reasonable to support. I've already been thinking of the issue between benchmark metrics and general test metrics. The general test metrics could just be properties.

epage commented 1 year ago

And someone created a json format for pytest: https://github.com/numirias/pytest-json-report

An ndjson one which has the potential to be merged is https://github.com/pytest-dev/pytest-reportlog

epage commented 1 year ago

Pulling in some related projects for input on benches

pietroalbini commented 1 year ago

Which renderer? Both at once? If not, how does the user select?

I would include only one renderer at the time (to avoid hardcoding "terse" vs "verbose" in the output), not sure how to encode that. Maybe json+terse, json+verbose as the format name?

And is this "output" supposed to literally be the equivalent of all of the write calls? Thats the only way I can see that working. We'd then likely also need to include an Event for flushing.

Yeah, I'd also include an event for flushing. That way third party runners shouldn't have many problems supporting this.

epage commented 11 months ago

We should probably dig into these ideas for exploring the ability to support these in the future if we need it

epage commented 11 months ago

Similarly, we should look to TAP for ideas.