Set environment variables specified via `cargo::rustc-env` in the build script
As discussed in #1787, cargo test does this, so nextest should too.
I added warnings in case the build script output file is not found, this should usually have been created when cargo executes the build script. I also decided to package the build script output file in the same step as the build script output directory. Let me know if you prefer creating a separate step for this.
I tried to approach this with minimal changes, maybe it would be nicer to store the path to the $OUT_DIR parent, so that getting the path of the output file is a tad simpler, but that would have required me touching more code.
Let me know if you have suggestions for implementing any of this differently.
Side note: trying to run tests with cargo run -p cargo-nextest -- nextest run --all-features failed with tracing complaining that it failed to set a global subscriber since one is already set, so I ran tests without the --all-features flag.
Codecov Report
Attention: Patch coverage is 87.87879% with 8 lines in your changes missing coverage. Please review.
Project coverage is 79.92%. Comparing base (
93fcd9e) to head (3a5625e). Report is 21 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| nextest-runner/src/test_command.rs | 88.23% | 6 Missing :warning: |
| nextest-runner/src/reuse_build/archiver.rs | 85.71% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1798 +/- ##
==========================================
+ Coverage 79.91% 79.92% +0.01%
==========================================
Files 80 80
Lines 20179 20244 +65
==========================================
+ Hits 16126 16180 +54
- Misses 4053 4064 +11
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Ah, I didn't realize you're testing against 1.75, which doesn't support the new cargo:: syntax yet. Any ideas for how to circumvent this? I could make the with-build-script test crate depend on rustversion to only include the new syntax test conditionally.
I changed the test to be dependent on the rustversion crate now, but I kept it a separate commit for now, since this requires a new dependency for the testing fixtures, and I'm not sure if this is fine. If yes, the commits should be squashed, otherwise we'll need another fix.
Thanks! Can this use a very simple version check, similar to:
https://github.com/camino-rs/camino/blob/467b33692ac2224f6ccfb6b4e96d7dfe2ea09ec7/build.rs#L32-L34
I don't think it's necessary to pull down a dependency here.
Thanks for the pointer of where to look for how to do this. I agree that this is definitely cleaner this way.
Now also added documentation, where I noted that cargo actually discourages using these variables at runtime. I hadn't noticed that before.
Side note: trying to run tests with cargo run -p cargo-nextest -- nextest run --all-features failed with tracing complaining that it failed to set a global subscriber since one is already set, so I ran tests without the --all-features flag.
Ah good catch, I'll try and fix this.
Released this as part of cargo-nextest 0.9.82. Thanks again!
Ah good catch, I'll try and fix this.
Fixed in https://github.com/nextest-rs/nextest/commit/11623d5ce06fd63ff3803499e594400876bac502.