Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions crates/cargo-test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 66 additions & 0 deletions tests/testsuite/profile_trim_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}