diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53f6ab8ac..a49ac0988 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -148,7 +148,7 @@ jobs: - run: rustup target add ${{ matrix.other }} - run: rustup component add rustc-dev llvm-tools-preview rust-docs if: startsWith(matrix.rust, 'nightly') - - run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y + - run: sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y if: matrix.os == 'ubuntu-latest' - run: rustup component add rustfmt || echo "rustfmt not available" - name: Configure extra test environment diff --git a/crates/cargo-test-macro/src/lib.rs b/crates/cargo-test-macro/src/lib.rs index 937fbce6b..14672ab94 100644 --- a/crates/cargo-test-macro/src/lib.rs +++ b/crates/cargo-test-macro/src/lib.rs @@ -208,10 +208,11 @@ fn has_command(command: &str) -> bool { let output = match Command::new(command).arg("--version").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. - if is_ci() && command != "hg" { + // * 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() && !["hg", "lldb"].contains(&command) { panic!( "expected command `{}` to be somewhere in PATH: {}", command, e diff --git a/tests/testsuite/profile_trim_paths.rs b/tests/testsuite/profile_trim_paths.rs index a682de939..8a627ecea 100644 --- a/tests/testsuite/profile_trim_paths.rs +++ b/tests/testsuite/profile_trim_paths.rs @@ -612,3 +612,69 @@ fn custom_build_env_var_trim_paths() { .run(); } } + +#[cfg(unix)] +#[cargo_test(requires_lldb, nightly, reason = "-Zremap-path-scope is unstable")] +fn lldb_works_after_trimmed() { + use cargo_test_support::compare::match_contains; + + let run_lldb = |path| { + std::process::Command::new("lldb") + .args(["-o", "breakpoint set --file src/main.rs --line 4"]) + .args(["-o", "run"]) + .args(["-o", "continue"]) + .args(["-o", "exit"]) + .arg("--no-use-colors") + .arg(path) + .output() + .expect("lldb works") + }; + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [profile.dev] + trim-paths = "object" + "#, + ) + .file( + "src/main.rs", + r#" + fn main() { + let msg = "Hello, Ferris!"; + println!("{msg}"); + } + "#, + ) + .build(); + + p.cargo("build --verbose -Ztrim-paths") + .masquerade_as_nightly_cargo(&["-Ztrim-paths"]) + .with_stderr_contains( + "\ +[RUNNING] `rustc [..]\ + -Zremap-path-scope=object \ + --remap-path-prefix=[CWD]= \ + --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]", + ) + .run(); + + let bin_path = p.bin("foo"); + assert!(bin_path.is_file()); + let stdout = String::from_utf8(run_lldb(bin_path).stdout).unwrap(); + match_contains("[..]stopped[..]", &stdout, None).unwrap(); + match_contains("[..]stop reason = breakpoint[..]", &stdout, None).unwrap(); + match_contains( + "\ +(lldb) continue +Hello, Ferris!", + &stdout, + None, + ) + .unwrap(); +}