eupn / macrotest

Test harness for declarative and procedural macros expansion via `cargo-expand`
47 stars 9 forks source link

Fix compat failures due to dependency updates (by honouring parent's dep versions) #111

Closed ijackson closed 4 months ago

ijackson commented 4 months ago

Use Cargo.lock from workspace root (if available)

When using macrotest, to make output consistent, it is necessary to pin to a particular version of Nightly Rust.

But of course usptream Nightly Rust changes, and that means that dependencies (of the macro package under test) may need to be updated upstream. Sometimes those updates aren't compatible with our pinned Nightly.

Therefore, tests must run with pinned versions of the dependencies, not just pinned versions of the compiler. Without this, we can run into trouble, as seen here, for example: https://gitlab.torproject.org/Diziet/rust-derive-deftly/-/issues/60

Borrow a trick from dtolnay's trybuild, which faces the same problem: copy the outer workspace's Cargo.lock into the synthetic crate. This influences Cargo's resolver sufficiently; but since we run without --locked, Cargo can still adjust the file as needed for the synthetic crate.

taiki-e commented 4 months ago

Published in 1.0.12.

ijackson commented 4 months ago

:heart: