mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
test(trim-paths): exercise with real world debugger
This commit is contained in:
parent
1ef8575839
commit
5c32fe0432
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user