File tree Expand file tree Collapse file tree 3 files changed +72
-5
lines changed
crates/cargo-test-macro/src Expand file tree Collapse file tree 3 files changed +72
-5
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ jobs:
148148 - run : rustup target add ${{ matrix.other }}
149149 - run : rustup component add rustc-dev llvm-tools-preview rust-docs
150150 if : startsWith(matrix.rust, 'nightly')
151- - run : sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y
151+ - run : sudo apt update -y && sudo apt install lldb gcc-multilib libsecret-1-0 libsecret-1-dev -y
152152 if : matrix.os == 'ubuntu-latest'
153153 - run : rustup component add rustfmt || echo "rustfmt not available"
154154 - name : Configure extra test environment
Original file line number Diff line number Diff line change @@ -208,10 +208,11 @@ fn has_command(command: &str) -> bool {
208208 let output = match Command :: new ( command) . arg ( "--version" ) . output ( ) {
209209 Ok ( output) => output,
210210 Err ( e) => {
211- // hg is not installed on GitHub macOS or certain constrained
212- // environments like Docker. Consider installing it if Cargo gains
213- // more hg support, but otherwise it isn't critical.
214- if is_ci ( ) && command != "hg" {
211+ // * hg is not installed on GitHub macOS or certain constrained
212+ // environments like Docker. Consider installing it if Cargo
213+ // gains more hg support, but otherwise it isn't critical.
214+ // * lldb is not pre-installed on Ubuntu and Windows, so skip.
215+ if is_ci ( ) && ![ "hg" , "lldb" ] . contains ( & command) {
215216 panic ! (
216217 "expected command `{}` to be somewhere in PATH: {}" ,
217218 command, e
Original file line number Diff line number Diff line change @@ -612,3 +612,69 @@ fn custom_build_env_var_trim_paths() {
612612 . run ( ) ;
613613 }
614614}
615+
616+ #[ cfg( unix) ]
617+ #[ cargo_test( requires_lldb, nightly, reason = "-Zremap-path-scope is unstable" ) ]
618+ fn lldb_works_after_trimmed ( ) {
619+ use cargo_test_support:: compare:: match_contains;
620+
621+ let run_lldb = |path| {
622+ std:: process:: Command :: new ( "lldb" )
623+ . args ( [ "-o" , "breakpoint set --file src/main.rs --line 4" ] )
624+ . args ( [ "-o" , "run" ] )
625+ . args ( [ "-o" , "continue" ] )
626+ . args ( [ "-o" , "exit" ] )
627+ . arg ( "--no-use-colors" )
628+ . arg ( path)
629+ . output ( )
630+ . expect ( "lldb works" )
631+ } ;
632+
633+ let p = project ( )
634+ . file (
635+ "Cargo.toml" ,
636+ r#"
637+ [package]
638+ name = "foo"
639+ version = "0.0.1"
640+
641+ [profile.dev]
642+ trim-paths = "object"
643+ "# ,
644+ )
645+ . file (
646+ "src/main.rs" ,
647+ r#"
648+ fn main() {
649+ let msg = "Hello, Ferris!";
650+ println!("{msg}");
651+ }
652+ "# ,
653+ )
654+ . build ( ) ;
655+
656+ p. cargo ( "build --verbose -Ztrim-paths" )
657+ . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
658+ . with_stderr_contains (
659+ "\
660+ [RUNNING] `rustc [..]\
661+ -Zremap-path-scope=object \
662+ --remap-path-prefix=[CWD]= \
663+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]",
664+ )
665+ . run ( ) ;
666+
667+ let bin_path = p. bin ( "foo" ) ;
668+ assert ! ( bin_path. is_file( ) ) ;
669+ let stdout = String :: from_utf8 ( run_lldb ( bin_path) . stdout ) . unwrap ( ) ;
670+ match_contains ( "[..]stopped[..]" , & stdout, None ) . unwrap ( ) ;
671+ match_contains ( "[..]stop reason = breakpoint[..]" , & stdout, None ) . unwrap ( ) ;
672+ match_contains (
673+ "\
674+ (lldb) continue
675+ Hello, Ferris!" ,
676+ & stdout,
677+ None ,
678+ )
679+ . unwrap ( ) ;
680+ }
You can’t perform that action at this time.
0 commit comments