@@ -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
@@ -163,8 +184,10 @@ fn multiple_options_with_none() {
163184
164185 p. cargo ( "build --verbose -Ztrim-paths" )
165186 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
166- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
167- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
187+ . with_stderr_line_without (
188+ & [ "[RUNNING][..]" ] ,
189+ & [ "-Zremap-path-scope" , "--remap-path-prefix" ] ,
190+ )
168191 . run ( ) ;
169192}
170193
@@ -193,13 +216,29 @@ fn registry_dependency() {
193216 . build ( ) ;
194217
195218 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
196- let registry_src = registry_src. display ( ) ;
219+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
197220
198221 p. cargo ( "run --verbose -Ztrim-paths" )
199222 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
200- . with_stdout ( format ! ( "{registry_src}/[..]/bar-0.0.1/src/lib.rs" ) )
201- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
202- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
223+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
224+ . with_stderr ( & format ! (
225+ "\
226+ [UPDATING] [..]
227+ [DOWNLOADING] crates ...
228+ [DOWNLOADED] bar v0.0.1 ([..])
229+ [COMPILING] bar v0.0.1
230+ [RUNNING] `rustc [..]\
231+ -Zremap-path-scope=object \
232+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
233+ --remap-path-prefix={pkg_remap} [..]
234+ [COMPILING] foo v0.0.1 ([CWD])
235+ [RUNNING] `rustc [..]\
236+ -Zremap-path-scope=object \
237+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
238+ --remap-path-prefix=[CWD]= [..]
239+ [FINISHED] dev [..]
240+ [RUNNING] `target/debug/foo[EXE]`"
241+ ) )
203242 . run ( ) ;
204243}
205244
@@ -233,13 +272,27 @@ fn git_dependency() {
233272 . build ( ) ;
234273
235274 let git_checkouts_src = paths:: home ( ) . join ( ".cargo/git/checkouts" ) ;
236- let git_checkouts_src = git_checkouts_src. display ( ) ;
275+ let pkg_remap = format ! ( "{}/bar-[..]/[..]=bar-0.0.1" , git_checkouts_src. display( ) ) ;
237276
238277 p. cargo ( "run --verbose -Ztrim-paths" )
239278 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
240- . with_stdout ( format ! ( "{git_checkouts_src}/bar-[..]/[..]/src/lib.rs" ) )
241- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
242- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
279+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
280+ . with_stderr ( & format ! (
281+ "\
282+ [UPDATING] git repository `{url}`
283+ [COMPILING] bar v0.0.1 ({url}[..])
284+ [RUNNING] `rustc [..]\
285+ -Zremap-path-scope=object \
286+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
287+ --remap-path-prefix={pkg_remap} [..]
288+ [COMPILING] foo v0.0.1 ([CWD])
289+ [RUNNING] `rustc [..]\
290+ -Zremap-path-scope=object \
291+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
292+ --remap-path-prefix=[CWD]= [..]
293+ [FINISHED] dev [..]
294+ [RUNNING] `target/debug/foo[EXE]`"
295+ ) )
243296 . run ( ) ;
244297}
245298
@@ -271,8 +324,21 @@ fn path_dependency() {
271324 p. cargo ( "run --verbose -Ztrim-paths" )
272325 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
273326 . with_stdout ( "cocktail-bar/src/lib.rs" )
274- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
275- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
327+ . with_stderr ( & format ! (
328+ "\
329+ [COMPILING] bar v0.0.1 ([..]/cocktail-bar)
330+ [RUNNING] `rustc [..]\
331+ -Zremap-path-scope=object \
332+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
333+ --remap-path-prefix=[CWD]= [..]
334+ [COMPILING] foo v0.0.1 ([CWD])
335+ [RUNNING] `rustc [..]\
336+ -Zremap-path-scope=object \
337+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
338+ --remap-path-prefix=[CWD]= [..]
339+ [FINISHED] dev [..]
340+ [RUNNING] `target/debug/foo[EXE]`"
341+ ) )
276342 . run ( ) ;
277343}
278344
@@ -306,9 +372,22 @@ fn path_dependency_outside_workspace() {
306372
307373 p. cargo ( "run --verbose -Ztrim-paths" )
308374 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
309- . with_stdout ( format ! ( "{bar_path}/src/lib.rs" ) )
310- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
311- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
375+ . with_stdout ( "bar-0.0.1/src/lib.rs" )
376+ . with_stderr ( & format ! (
377+ "\
378+ [COMPILING] bar v0.0.1 ([..]/bar)
379+ [RUNNING] `rustc [..]\
380+ -Zremap-path-scope=object \
381+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
382+ --remap-path-prefix={bar_path}=bar-0.0.1 [..]
383+ [COMPILING] foo v0.0.1 ([CWD])
384+ [RUNNING] `rustc [..]\
385+ -Zremap-path-scope=object \
386+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
387+ --remap-path-prefix=[CWD]= [..]
388+ [FINISHED] dev [..]
389+ [RUNNING] `target/debug/foo[EXE]`"
390+ ) )
312391 . run ( ) ;
313392}
314393
@@ -337,22 +416,34 @@ fn diagnostics_works() {
337416 . build ( ) ;
338417
339418 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
340- let registry_src = registry_src. display ( ) ;
419+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
341420
342421 p. cargo ( "build -vv -Ztrim-paths" )
343422 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
344- . with_stderr_contains ( format ! (
423+ . with_stderr_contains (
345424 "\
346425 warning: unused variable: `unused`
347- --> {registry_src}/[..]/ bar-0.0.1/src/lib.rs:1:18
426+ --> bar-0.0.1/src/lib.rs:1:18
348427 |
349- 1 | pub fn f() {{ let unused = 0; } }
428+ 1 | pub fn f() { let unused = 0; }
350429 | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
351430 |
352431 = note: `#[warn(unused_variables)]` on by default" ,
432+ )
433+ . with_stderr_contains ( & format ! (
434+ "\
435+ [RUNNING] [..]rustc [..]\
436+ -Zremap-path-scope=diagnostics \
437+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
438+ --remap-path-prefix={pkg_remap} [..]",
353439 ) )
354- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
355- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
440+ . with_stderr_contains (
441+ "\
442+ [RUNNING] [..]rustc [..]\
443+ -Zremap-path-scope=diagnostics \
444+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
445+ --remap-path-prefix=[CWD]= [..]",
446+ )
356447 . run ( ) ;
357448}
358449
@@ -369,6 +460,8 @@ fn object_works() {
369460 } ;
370461
371462 let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
463+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
464+ let rust_src = "/lib/rustc/src/rust" . as_bytes ( ) ;
372465 let registry_src_bytes = registry_src. as_os_str ( ) . as_bytes ( ) ;
373466
374467 Package :: new ( "bar" , "0.0.1" )
@@ -427,16 +520,26 @@ fn object_works() {
427520
428521 p. cargo ( "build --verbose -Ztrim-paths" )
429522 . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
430- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
431- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
523+ . with_stderr ( & format ! (
524+ "\
525+ [COMPILING] bar v0.0.1
526+ [RUNNING] `rustc [..]\
527+ -Zremap-path-scope=object \
528+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
529+ --remap-path-prefix={pkg_remap} [..]
530+ [COMPILING] foo v0.0.1 ([CWD])
531+ [RUNNING] `rustc [..]\
532+ -Zremap-path-scope=object \
533+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
534+ --remap-path-prefix=[CWD]= [..]
535+ [FINISHED] dev [..]" ,
536+ ) )
432537 . run ( ) ;
433538
434539 let bin_path = p. bin ( "foo" ) ;
435540 assert ! ( bin_path. is_file( ) ) ;
436541 let stdout = run_strings ( bin_path) . stdout ;
437- // TODO: re-enable this check when rustc bootstrap disables remapping
438- // <https://github.com/rust-lang/cargo/pull/12625#discussion_r1371714791>
439- // assert!(memchr::memmem::find(&stdout, rust_src).is_some());
440- assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_some( ) ) ;
441- assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_some( ) ) ;
542+ assert ! ( memchr:: memmem:: find( & stdout, rust_src) . is_none( ) ) ;
543+ assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_none( ) ) ;
544+ assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_none( ) ) ;
442545}
0 commit comments