-
Notifications
You must be signed in to change notification settings - Fork 123
Enable jinja "strict undefined behavior", fix templates, improve reporting #1499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
18a45b1 to
fe96de9
Compare
|
Current state of this PR: the corresponding minjinja fix has landed in their So I don't love that for us and this PR can probably wait for a new minjinja to land (releases seem regular) BUT! it looks awesome and is very useful: I pulled in color-backtrace for coloring and filtering and this helps me at least (I'm curious to see what @mistydemeo and @duckinator think about it specifically) narrow down what's wrong almost immediately: color-backtrace is awesome (and the big dependency here is Even though I'd like to wait for a minjinja point release to drop, I'm gonna stack my other PRs on top of this one because, damn, that's good tooling. |
|
Note 1: I've forced backtrace capture, even if you haven't otherwise exported Note 2: this PR also fixes the few instances of us violating "strict undefined behavior", minjinja is going to get a little legalistic on us — the only thing y'all need to know is that if it complains something like: Then you need struct Blah {
#[serde(skip_serializing_if = "Option::is_none")]
pub bin: Option<String>,
}But in the actual case of cargo-dist/cargo-dist/src/backend/installer/npm.rs Lines 89 to 93 in 33316c5
ie. while "rendering the directory template", it gets rendered once with zero context, and then it's removed and re-rendered with the correct context. That's a hack and I hate it, but with just {%- if bin is defined %}
run({{ bin }});
{%- endif %} |
|
After discussing in Discord, we'll publish |
|
Taking this out of draft since it's ready for being merged imho! |
0c6a265 to
eb4e8ee
Compare
|
I caught another template issue (a benign one) while working on #1509 — which mostly tells me the homebrew stuff isn't all covered by unit (or integration) tests |
9c9433c to
7b80e2b
Compare
mistydemeo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but a few comments - one error, and a few other suggestions and questions.
1abdc8b to
d5017d6
Compare
| --- | ||
| source: cargo-dist/tests/gallery/dist/snapshot.rs | ||
| expression: self.payload | ||
| snapshot_kind: text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably due to the minijinja update? idk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version of cargo-insta do you have? This was added when Ellen updated a test, which makes me think they might have a newer version than you or I do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK yeah, this field landed in cargo-insta 1.41 mitsuhiko/insta@0b81773
Prior to that insta only had a single snapshot format so there was no need to specify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll upgrade locally!
|
@mistydemeo I addressed whitespace issues — in fact, I made sure the template produces exactly the same input as before, just using those nice macros and the new "template input" structs. I've also added a comment about the jinjaness of the macro (and a link to the surprising-to-find docs), and fixed the endif/end mishap. |
mistydemeo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just a few comments now!
|
The mac tests are failing because it's trying to install a linuxbrew-only package.. |
d5017d6 to
6b54bd3
Compare
..and make it really friendly to debug those errors. Also, due to homebrew template changes, dist now collects homebrew dependencies per-target, rather than globally, which means that when generating installers, we're no longer mixing up macbrew and linuxbrew dependencies, for example.
6b54bd3 to
4c88c10
Compare




Most likely we need to contribute back to minijinja2 to get proper tracking information for "undefined errors" because right now all we see is this: