rust-analyzer / expect-test

Minimalistic snapshot testing for Rust.
Apache License 2.0
248 stars 22 forks source link

"]]" inside an `expect` breaks updating #20

Closed ecstatic-morse closed 2 years ago

ecstatic-morse commented 2 years ago

The current code does a simple search for the character sequence ]] to determine the end of an expect![[ macro invocation. However, expect takes a string, and "]]" is perfectly valid as part of a string.

matklad commented 2 years ago

Yeah… we should’t be adding a real Rust parser here, but it makes sense to make heuristic more robust to the practical cases. Here, I think it makes sense to verify that symbols before ]] are quote/hash and whotespace

ecstatic-morse commented 2 years ago

we should’t be adding a real Rust parser here

@matklad Interesting. I thought this would be the solution. Is this just to avoid a syn dependency? You could also go half way and write/steal a tokenizer for just string literals. I'll write the simple regex in the meantime. Maybe we can discuss on the PR.