djc / askama

Type-safe, compiled Jinja-like templates for Rust
Apache License 2.0
3.43k stars 218 forks source link

Add tests for generated code #1038

Closed GuillaumeGomez closed 4 months ago

GuillaumeGomez commented 4 months ago

In https://github.com/djc/askama/pull/1037, I tried to add tests for generated content but it was quite ugly so I finally didn't put it into the PR until I find a better implementation.

I still think that we should have AST tests, in particular to ensure that code generation improvements don't have "hidden" regressions and that changes don't go unnoticed.

Kijewski commented 4 months ago

I guess we could do something like syn::parse(generated_code) == syn::parse("expected::code()"). syn's PartialEq ignores spans, so I think this should work.

GuillaumeGomez commented 4 months ago

:exploding_head: