Scrub more of the test environment
This adds a few environment variables that if set outside the testsuite will cause problems.
This also has a separate commit which sorts the environment list.
Make more reads of environment variables go through the `Config`
As discussed in #11588, it's better to make reads of environment variables go through the `Config` instead of calling `std::env::var` or `env::var_os` everywhere.
Most of the "easy" places to change this in `src/` were handled in https://github.com/rust-lang/cargo/pull/11727. This PR fixes a few remaining call sites that were missed in #11727, namely:
- `LocalFingerprint::find_stale_item`
- `util::profile::start` and `Profiler`
- `util::rustc::rustc_fingerprint`
After doing this, there are a few remaining calls to `env::var` in `src/` but those probably require more discussion to fix.
Switch some tests from `build` to `check`
#11341 brought up issues with cargo's `testsute` size and speed. One of the suggested fixes was switching most tests to `check` instead of `build`. This PR did that.
Before size on `nightly`: 4.4GB
After size on `nightly`: 4.2GB
Regex to find `build` in `tests/testsuite`: `cargo\(".*build.*\)`
Before: 1607
After: 626
Note I did not remove all `build` I only did the easy ones that required minimal changes. I also tried not to touch systems I was unsure about. There could be other uses of `build` I missed as well.
I still need to play around with `opt-level`, `debug=0`, and a few other tweaks, but there should be more time/memory to drop.
Each test file changed is in a commit of its own, so you should look commit by commit.
Fix typo in sparse-registry warning message
Fixes#11752
Message now shows as:
```
warning: flag `-Z sparse-registry` has been stabilized in the 1.68 release, and is no longer necessary
This flag currently still sets the default protocol to `sparse` when accessing crates.io. However, this will be removed in the future.
The stable equivalent is to set the config value `registries.crates-io.protocol = 'sparse'`
or environment variable `CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse`
```
Read environment variables through `Config` instead of `std::env::var(_os)`
### What does this PR try to resolve?
Adds two new methods `get_env` and `get_env_os` for reading environment variables from the `Config` and uses them to replace the many of the calls to `std::env::var` and `var_os` (see the discussion in #11588).
Closes#11588
Update curl-sys to use libcurl 7.88.1
This updates curl-sys to update the vendored curl from 7.86.0 to 7.88.1. The changelog is at https://curl.se/changes.html.
mdman: update pretty_assertions to reduce deps
This reduces deps in rust repo by dropping `ansi_term 0.11.0` and `difference` crates. `yansi` and `diff` already used there (rust repo).
Cleanup tests
When working on #11738 I noticed a few tests that needed to be cleaned up. It [was suggested](https://github.com/rust-lang/cargo/pull/11738#discussion_r1111128128) to split the test changes into their own PR.
- `bad_config::bad1`
- This was trying to match `config` which would get matched in the wrong place due to the test name having `config` in it
- Fixed by making the match `/config`
- `build_script::panic_abort_with_build_scripts`
- This test was failing as it was making sure `panic` was not in the output. After this change, it could match the test name and fail.
- To fix this I updated it to look at `panic=abort` which appears to be what it was originally looking for (#5711). `@ehuss` please let me know if I misread what the test was testing.
- `cargo_command::cargo_subcommand_args`
- This test had `#[test]` above `#[cargo_test]` which caused it to throw an error removing it fixed the issue
During this time I also ran into issues with `cargo_remove` tests being named `fn case()` which is different from how tests are normally named. I talked with `@epage` and it was decided that `fn case()` should probably be used for all `snapbox` tests since the unique test name is already the folder name. I went ahead and renamed all tests within `cargo_add/` and `init/` to match this style.
This PR should be reviewed commit by commit.