Skip to content
Merged
18 changes: 15 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
CARGO_PROFILE_TEST_DEBUG: 1
CARGO_INCREMENTAL: 0
CARGO_PUBLIC_NETWORK_TESTS: 1
CARGO_TEST_REQUIRE_EXTERNAL_TOOLS: 1
# Workaround for https://github.com/rust-lang/rustup/issues/3036
RUSTUP_WINDOWS_PATH_ADD_BIN: 0
strategy:
Expand Down Expand Up @@ -168,22 +169,27 @@ jobs:
- name: Windows x86_64 MSVC stable
os: windows-latest
rust: stable-msvc
target_env: msvc
other: i686-pc-windows-msvc
- name: Windows x86_64 MSVC nightly
os: windows-latest
rust: nightly-msvc
target_env: msvc
other: i686-pc-windows-msvc
- name: Windows aarch64 MSVC stable
os: windows-11-arm
rust: stable-msvc
target_env: msvc
other: i686-pc-windows-msvc
- name: Windows aarch64 MSVC nightly
os: windows-11-arm
rust: nightly-msvc
target_env: msvc
other: i686-pc-windows-msvc
- name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite
os: windows-latest
rust: nightly-gnu
target_env: gnu
other: i686-pc-windows-gnu
name: Tests ${{ matrix.name }}
steps:
Expand All @@ -204,6 +210,12 @@ jobs:
if: startsWith(matrix.rust, 'nightly')
- run: sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y
if: matrix.os == 'ubuntu-latest'
- name: Install LLDB on Linux ARM
run: sudo apt update -y && sudo apt install lldb -y
if: matrix.os == 'ubuntu-24.04-arm'
- name: Check LLDB debugger tool
run: lldb --version
if: runner.os != 'Windows'
- run: rustup component add rustfmt || echo "rustfmt not available"
- name: Add Windows debuggers bin to PATH
shell: pwsh
Expand All @@ -215,13 +227,13 @@ jobs:
if: matrix.os == 'windows-11-arm'
- name: Check Windows MSVC debugger tool
run: cdb -version
if: matrix.rust == 'nightly-msvc'
if: runner.os == 'Windows' && matrix.target_env == 'msvc'
- name: Check Windows GNU object tool
run: objdump --version
if: matrix.os == 'windows-latest' && matrix.rust == 'nightly-gnu'
if: runner.os == 'Windows' && matrix.target_env == 'gnu'
- name: Check Windows GNU debugger tool
run: gdb --version
if: matrix.os == 'windows-latest' && matrix.rust == 'nightly-gnu'
if: runner.os == 'Windows' && matrix.target_env == 'gnu'
- name: Configure extra test environment
run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'
Expand Down
25 changes: 17 additions & 8 deletions crates/cargo-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use std::sync::LazyLock;
/// A `reason` field is required to explain why it is nightly-only.
/// * `requires = "<cmd>"` --- This indicates a command that is required to be installed to be run.
/// For example, `requires = "rustfmt"` means the test will only run if the executable `rustfmt` is installed.
/// These tests are *always* run on CI.
/// These tests are run in Cargo's CI when CARGO_TEST_REQUIRE_EXTERNAL_TOOLS is set.
/// Other environments, including rust-lang/rust's CI, ignore the test when the command is unavailable.
/// This is mainly used to avoid requiring contributors from having every dependency installed.
/// * `requires_host_split_debuginfo = "<value>"` --- This indicates a `-Csplit-debuginfo` value
/// that is required to be supported by the host `rustc`.
Expand Down Expand Up @@ -374,11 +375,7 @@ fn check_command(command_path: &Path, args: &[&str]) -> bool {
let output = match command.output() {
Ok(output) => output,
Err(e) => {
// * hg is not installed on GitHub macOS or certain constrained
// environments like Docker. Consider installing it if Cargo
// gains more hg support, but otherwise it isn't critical.
// * lldb is not pre-installed on Ubuntu and Windows, so skip.
if is_ci() && !matches!(command_name.as_str(), "hg" | "lldb") {
if is_ci() {
panic!("expected command `{command_name}` to be somewhere in PATH: {e}",);
}
return false;
Expand All @@ -404,7 +401,7 @@ fn has_command(command: &str) -> bool {
let Some(paths) = std::env::var_os("PATH") else {
return false;
};
std::env::split_paths(&paths)
let found = std::env::split_paths(&paths)
.flat_map(|path| {
let candidate = path.join(&command);
let with_exe = if EXE_EXTENSION.is_empty() {
Expand All @@ -415,7 +412,14 @@ fn has_command(command: &str) -> bool {
std::iter::once(candidate).chain(with_exe)
})
.find(|p| is_executable(p))
.is_some()
.is_some();
// * hg is not installed on GitHub macOS or certain constrained
// environments like Docker. Consider installing it if Cargo
// gains more hg support, but otherwise it isn't critical.
if !found && requires_external_tools() && command != "hg" {
panic!("expected command `{command}` to be somewhere in PATH");
}
found
}

#[cfg(unix)]
Expand Down Expand Up @@ -455,3 +459,8 @@ fn is_ci() -> bool {
// itself like option_env does.
option_env!("CI").is_some() || option_env!("TF_BUILD").is_some()
}

/// Whether to enforce external tools (`requires=<tool>`) availability.
fn requires_external_tools() -> bool {
option_env!("CARGO_TEST_REQUIRE_EXTERNAL_TOOLS").is_some()
}
3 changes: 0 additions & 3 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,9 +1541,6 @@ fn trim_paths_args_rustdoc(
_ => {}
}

// feature gate was checked during manifest/config parsing.
cmd.arg("-Zunstable-options");

for pair in trim_paths_remap(build_runner, unit) {
let mut arg = OsString::from("--remap-path-prefix=");
arg.push(pair);
Expand Down
Loading