@@ -78,8 +78,15 @@ fn release_profile_default_to_object() {
7878
7979 p. cargo ( "build --release --verbose -Ztrim-paths" )
8080 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
81- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
82- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
81+ . with_stderr (
82+ "\
83+ [COMPILING] foo v0.0.1 ([CWD])
84+ [RUNNING] `rustc [..]\
85+ -Zremap-path-scope=object \
86+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
87+ --remap-path-prefix=[CWD]= [..]
88+ [FINISHED] release [..]" ,
89+ )
8390 . run ( ) ;
8491}
8592
@@ -109,8 +116,15 @@ fn one_option() {
109116 for option in [ "macro" , "diagnostics" , "object" , "all" ] {
110117 build ( option)
111118 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
112- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
113- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
119+ . with_stderr ( & format ! (
120+ "\
121+ [COMPILING] foo v0.0.1 ([CWD])
122+ [RUNNING] `rustc [..]\
123+ -Zremap-path-scope={option} \
124+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
125+ --remap-path-prefix=[CWD]= [..]
126+ [FINISHED] dev [..]" ,
127+ ) )
114128 . run ( ) ;
115129 }
116130 build ( "none" )
@@ -139,8 +153,15 @@ fn multiple_options() {
139153
140154 p. cargo ( "build --verbose -Ztrim-paths" )
141155 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
142- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
143- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
156+ . with_stderr (
157+ "\
158+ [COMPILING] foo v0.0.1 ([CWD])
159+ [RUNNING] `rustc [..]\
160+ -Zremap-path-scope=diagnostics,macro,object \
161+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
162+ --remap-path-prefix=[CWD]= [..]
163+ [FINISHED] dev [..]" ,
164+ )
144165 . run ( ) ;
145166}
146167
@@ -169,13 +190,29 @@ fn registry_dependency() {
169190 . build ( ) ;
170191
171192 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
172- let registry_src = registry_src. display ( ) ;
193+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
173194
174195 p. cargo ( "run --verbose -Ztrim-paths" )
175196 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
176- . with_stdout ( format ! ( "{registry_src}/[..]/bar-0.0.1/src/lib.rs" ) )
177- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
178- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
197+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
198+ . with_stderr ( & format ! (
199+ "\
200+ [UPDATING] [..]
201+ [DOWNLOADING] crates ...
202+ [DOWNLOADED] bar v0.0.1 ([..])
203+ [COMPILING] bar v0.0.1
204+ [RUNNING] `rustc [..]\
205+ -Zremap-path-scope=object \
206+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
207+ --remap-path-prefix={pkg_remap} [..]
208+ [COMPILING] foo v0.0.1 ([CWD])
209+ [RUNNING] `rustc [..]\
210+ -Zremap-path-scope=object \
211+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
212+ --remap-path-prefix=[CWD]= [..]
213+ [FINISHED] dev [..]
214+ [RUNNING] `target/debug/foo[EXE]`"
215+ ) )
179216 . run ( ) ;
180217}
181218
@@ -209,13 +246,27 @@ fn git_dependency() {
209246 . build ( ) ;
210247
211248 let git_checkouts_src = paths:: home ( ) . join ( ".cargo/git/checkouts" ) ;
212- let git_checkouts_src = git_checkouts_src. display ( ) ;
249+ let pkg_remap = format ! ( "{}/bar-[..]/[..]=bar-0.0.1" , git_checkouts_src. display( ) ) ;
213250
214251 p. cargo ( "run --verbose -Ztrim-paths" )
215252 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
216- . with_stdout ( format ! ( "{git_checkouts_src}/bar-[..]/[..]/src/lib.rs" ) )
217- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
218- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
253+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
254+ . with_stderr ( & format ! (
255+ "\
256+ [UPDATING] git repository `{url}`
257+ [COMPILING] bar v0.0.1 ({url}[..])
258+ [RUNNING] `rustc [..]\
259+ -Zremap-path-scope=object \
260+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
261+ --remap-path-prefix={pkg_remap} [..]
262+ [COMPILING] foo v0.0.1 ([CWD])
263+ [RUNNING] `rustc [..]\
264+ -Zremap-path-scope=object \
265+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
266+ --remap-path-prefix=[CWD]= [..]
267+ [FINISHED] dev [..]
268+ [RUNNING] `target/debug/foo[EXE]`"
269+ ) )
219270 . run ( ) ;
220271}
221272
@@ -247,8 +298,21 @@ fn path_dependency() {
247298 p. cargo ( "run --verbose -Ztrim-paths" )
248299 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
249300 . with_stdout ( "cocktail-bar/src/lib.rs" )
250- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
251- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
301+ . with_stderr ( & format ! (
302+ "\
303+ [COMPILING] bar v0.0.1 ([..]/cocktail-bar)
304+ [RUNNING] `rustc [..]\
305+ -Zremap-path-scope=object \
306+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
307+ --remap-path-prefix=[CWD]= [..]
308+ [COMPILING] foo v0.0.1 ([CWD])
309+ [RUNNING] `rustc [..]\
310+ -Zremap-path-scope=object \
311+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
312+ --remap-path-prefix=[CWD]= [..]
313+ [FINISHED] dev [..]
314+ [RUNNING] `target/debug/foo[EXE]`"
315+ ) )
252316 . run ( ) ;
253317}
254318
@@ -282,9 +346,22 @@ fn path_dependency_outside_workspace() {
282346
283347 p. cargo ( "run --verbose -Ztrim-paths" )
284348 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
285- . with_stdout ( format ! ( "{bar_path}/src/lib.rs" ) )
286- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
287- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
349+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
350+ . with_stderr ( & format ! (
351+ "\
352+ [COMPILING] bar v0.0.1 ([..]/bar)
353+ [RUNNING] `rustc [..]\
354+ -Zremap-path-scope=object \
355+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
356+ --remap-path-prefix={bar_path}=bar-0.0.1 [..]
357+ [COMPILING] foo v0.0.1 ([CWD])
358+ [RUNNING] `rustc [..]\
359+ -Zremap-path-scope=object \
360+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
361+ --remap-path-prefix=[CWD]= [..]
362+ [FINISHED] dev [..]
363+ [RUNNING] `target/debug/foo[EXE]`"
364+ ) )
288365 . run ( ) ;
289366}
290367
@@ -314,13 +391,29 @@ fn diagnostics_works() {
314391
315392 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
316393 let registry_src = registry_src. display ( ) ;
394+ let pkg_remap = format ! ( "{registry_src}/[..]/bar-0.0.1=bar-0.0.1" ) ;
317395
318396 p. cargo ( "build -vv -Ztrim-paths" )
319397 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
320- . with_stderr_contains ( format ! ( "[..]{registry_src}/[..]/bar-0.0.1/src/lib.rs:1[..]" ) )
398+ . with_stderr_line_without (
399+ & [ "[..]bar-0.0.1/src/lib.rs:1[..]" ] ,
400+ & [ & format ! ( "{registry_src}" ) ] ,
401+ )
321402 . with_stderr_contains ( "[..]unused_variables[..]" )
322- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
323- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
403+ . with_stderr_contains ( & format ! (
404+ "\
405+ [RUNNING] [..]rustc [..]\
406+ -Zremap-path-scope=diagnostics \
407+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
408+ --remap-path-prefix={pkg_remap} [..]",
409+ ) )
410+ . with_stderr_contains (
411+ "\
412+ [RUNNING] [..]rustc [..]\
413+ -Zremap-path-scope=diagnostics \
414+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
415+ --remap-path-prefix=[CWD]= [..]",
416+ )
324417 . run ( ) ;
325418}
326419
@@ -338,6 +431,8 @@ fn object_works() {
338431 } ;
339432
340433 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
434+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
435+ let rust_src = "/lib/rustc/src/rust" . as_bytes ( ) ;
341436 let registry_src_bytes = registry_src. as_os_str ( ) . as_bytes ( ) ;
342437
343438 Package :: new ( "bar" , "0.0.1" )
@@ -393,16 +488,26 @@ fn object_works() {
393488
394489 p. cargo ( "build --verbose -Ztrim-paths" )
395490 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
396- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
397- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
491+ . with_stderr ( & format ! (
492+ "\
493+ [COMPILING] bar v0.0.1
494+ [RUNNING] `rustc [..]\
495+ -Zremap-path-scope=object \
496+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
497+ --remap-path-prefix={pkg_remap} [..]
498+ [COMPILING] foo v0.0.1 ([CWD])
499+ [RUNNING] `rustc [..]\
500+ -Zremap-path-scope=object \
501+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
502+ --remap-path-prefix=[CWD]= [..]
503+ [FINISHED] dev [..]" ,
504+ ) )
398505 . run ( ) ;
399506
400507 let bin_path = p. bin ( "foo" ) ;
401508 assert ! ( bin_path. is_file( ) ) ;
402509 let stdout = run_readelf ( bin_path) . stdout ;
403- // TODO: re-enable this check when rustc bootstrap disables remapping
404- // <https://github.com/rust-lang/cargo/pull/12625#discussion_r1371714791>
405- // assert!(memchr::memmem::find(&stdout, rust_src).is_some());
406- assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_some( ) ) ;
407- assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_some( ) ) ;
510+ assert ! ( memchr:: memmem:: find( & stdout, rust_src) . is_none( ) ) ;
511+ assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_none( ) ) ;
512+ assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_none( ) ) ;
408513}
0 commit comments