On Wed, 2024-07-24 at 18:14 -0400, Eli Schwartz wrote: > On 7/24/24 6:07 PM, James Le Cuirot wrote: > > Rust packages have a tendency to rebuild parts during test and install. > > It is not clear whether this can be addressed. We were therefore relying > > on some environment variables set during the compile phase for > > cross-compiling to work in the later phases. This is not ideal, > > especially if you need to build for multiple targets. > > > Oof, yeah, as I mentioned on Monday in -dev, I have a package that > actually produces meaningfully different programs if you rebuild it > during test. > > dev-util/ruff will, when built with FEATURES=test, not show color when > you run it. Don't know why, feel a bit too freaked out about rebuilding > for tests *at all* to even think about fixing this in a "src_test > compatible way". > > So I wonder if maybe we can somehow switch to e.g. doing the test phase > in a different directory such that it doesn't modify the artifacts we > actually want to install. It can happen due to files or environment variables changing. It sounds like the tests inadvertently cause that in this case. You could copy the $(cargo_target_dir) to $(cargo_target_dir)-test and then set CARGO_TARGET_DIR to the latter before running the tests.