trycmd
trycmd copied to clipboard
Escape backticks in output in trycmd files
Wanted to add test to https://github.com/rust-lang/cargo-bisect-rustc before switching from StructOpt to Clapv3 but it is seems tests are failing because the output contains backticks (and backslashes, same as https://github.com/assert-rs/trycmd/issues/91)
A workaround for now would be to treat the output as a binary file which from what I've read in other issues is not normalised at all, but I have not found a way to force it
Could you help me understand how backticks are causing tests to fail and why escaping them would help?
Minimal reproducible example, using the test CLI of the repo
# My .trycmd file
```
$ stdout='```Hello```' bin-fixture
```Hello```
```
The backtips in the output are considered the end of the markdown block, and the end of the output is not parsed. It looks like trycmd does not support to use more than 3 backticks in that case as block delimiter to allow the use of 3 in it.
Thanks, knowing you are using markdown and running into conflicts between code fences and output is a big help!
A workaround is to write your cases with toml files rather than markdown / trycmd
The minimum solution is for us to support variable number of backticks for fences. This will allow users to manually choose more backticks to avoid this situation. For faster compile times, we aren't using a full blown markdown parser but just enough to extract a subset of fenced blocks which is why we can't offer this workaround yet.
The ideal solution is we detect the conflict and automatically increase the number of backticks for fences on the users behalf.
v0.13.4 is released with the workaround
Thanks for the quick fix!
The minimum solution is for us to support variable number of backticks for fences.
Could the minimum solution be to grab the first and last line that starts with triple backticks?
Could the minimum solution be to grab the first and last line that starts with triple backticks?
There can be multiple code fences within a file. This also wouldn't be compatible with markdown which we are striving for.
Oops, I just realized that trycmd files can have multiple code fences for multistep assertions.
Yeah, nevermind.