trycmd icon indicating copy to clipboard operation
trycmd copied to clipboard

Handle jsonlines being mixed with other output

Open epage opened this issue 1 year ago • 5 comments

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

epage avatar Jul 23 '24 19:07 epage

Could you point out the specific tests needing this?

weihanglo avatar Jul 24 '24 12:07 weihanglo

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

  • Could we pass --no-run?
  • We could read the output and do our own filtering before doing a direct call to assert_e2e().eq

epage avatar Jul 24 '24 13:07 epage

--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.

weihanglo avatar Jul 24 '24 20:07 weihanglo

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 avatar Jul 24 '24 21:07 epage

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

epage avatar Aug 14 '24 20:08 epage