assert-rs / snapbox

Snapshot testing for a herd of CLI tests
docs.rs/trycmd
Apache License 2.0
137 stars 18 forks source link

Handle jsonlines being mixed with other output #351

Open epage opened 3 months ago

epage commented 3 months ago

Cargo needs this for testing cargo test. This was found while testing the fix for #348.

weihanglo commented 3 months ago

Could you point out the specific tests needing this?

epage commented 3 months ago

https://github.com/rust-lang/cargo/blob/7f2079838ac6e0a3cb05b1b9dac4401a76572855/tests/testsuite/test.rs#L4365-L4420

We could look into other ways of solving that but I hadn't yet

weihanglo commented 3 months ago

--no-run seems like a viable solution for Cargo. In an ideal world everything should be JSON under --message-forma=json. I don't really think snapbox is responsible for this misfortune.

epage commented 3 months ago

I don't really think snapbox is responsible for this misfortune.

If only the world was so clean.

For example, I was looking at cargo's compilation for other reasons and cargo emits json on stderr and we only parse lines starting as { as json, forwarding the rest on to stderr.

epage commented 2 months ago

rust-lang/cargo#14297 dropped the priority of this