Skip to content

Commit 11e40ae

Browse files
committed
test(trim-paths): verify Windows cdb works after trimmed
GitHub Actions has Windows SDK pre-installed, so cdb should be available at that path always. Additionally, this adds a new CI job for windows-msvc nightly toolchain
1 parent cf87e11 commit 11e40ae

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ jobs:
155155
os: windows-latest
156156
rust: stable-msvc
157157
other: i686-pc-windows-msvc
158+
- name: Windows x86_64 MSVC nightly
159+
os: windows-latest
160+
rust: nightly-msvc
161+
other: i686-pc-windows-msvc
158162
- name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite
159163
os: windows-latest
160164
rust: nightly-gnu
@@ -179,6 +183,10 @@ jobs:
179183
- run: sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y
180184
if: matrix.os == 'ubuntu-latest'
181185
- run: rustup component add rustfmt || echo "rustfmt not available"
186+
- name: Add Windows debuggers bin to PATH
187+
shell: pwsh
188+
run: Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64"
189+
if: matrix.os == 'windows-latest'
182190
- name: Configure extra test environment
183191
run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
184192
if: matrix.os == 'ubuntu-latest'

tests/testsuite/profile_trim_paths.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,68 @@ Hello, Ferris!
763763
);
764764
}
765765

766+
#[cfg(target_env = "msvc")]
767+
#[cargo_test(requires = "cdb", nightly, reason = "-Zremap-path-scope is unstable")]
768+
fn cdb_works_after_trimmed() {
769+
use cargo_test_support::compare::assert_e2e;
770+
771+
let run_debugger = |path| {
772+
std::process::Command::new("cdb")
773+
.args(["-c", "bp `main.rs:4`;g;g;q"])
774+
.arg(path)
775+
.output()
776+
.expect("debugger works")
777+
};
778+
779+
let p = project()
780+
.file(
781+
"Cargo.toml",
782+
r#"
783+
[package]
784+
name = "foo"
785+
version = "0.0.1"
786+
edition = "2015"
787+
788+
[profile.dev]
789+
trim-paths = "object"
790+
"#,
791+
)
792+
.file(
793+
"src/main.rs",
794+
r#"
795+
fn main() {
796+
let msg = "Hello, Ferris!";
797+
println!("{msg}");
798+
}
799+
"#,
800+
)
801+
.build();
802+
803+
p.cargo("build --verbose -Ztrim-paths")
804+
.masquerade_as_nightly_cargo(&["-Ztrim-paths"])
805+
.with_stderr_data(str![[r#"
806+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
807+
[RUNNING] `rustc [..]-Zremap-path-scope=object --remap-path-prefix=[ROOT]/foo=. --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]`
808+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
809+
810+
"#]])
811+
.run();
812+
813+
let bin_path = p.bin("foo");
814+
assert!(bin_path.is_file());
815+
let stdout = String::from_utf8(run_debugger(bin_path).stdout).unwrap();
816+
assert_e2e().eq(
817+
&stdout,
818+
str![[r#"
819+
...
820+
Breakpoint 0 hit
821+
Hello, Ferris!
822+
...
823+
824+
"#]],
825+
);
826+
}
827+
766828
#[cargo_test(nightly, reason = "rustdoc --remap-path-prefix is unstable")]
767829
fn rustdoc_without_diagnostics_scope() {
768830
Package::new("bar", "0.0.1")

0 commit comments

Comments
 (0)