@@ -78,8 +78,15 @@ fn release_profile_default_to_object() {
78
78
79
79
p. cargo ( "build --release --verbose -Ztrim-paths" )
80
80
. 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
+ )
83
90
. run ( ) ;
84
91
}
85
92
@@ -109,8 +116,15 @@ fn one_option() {
109
116
for option in [ "macro" , "diagnostics" , "object" , "all" ] {
110
117
build ( option)
111
118
. 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
+ ) )
114
128
. run ( ) ;
115
129
}
116
130
build ( "none" )
@@ -139,8 +153,15 @@ fn multiple_options() {
139
153
140
154
p. cargo ( "build --verbose -Ztrim-paths" )
141
155
. 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
+ )
144
165
. run ( ) ;
145
166
}
146
167
@@ -169,13 +190,29 @@ fn registry_dependency() {
169
190
. build ( ) ;
170
191
171
192
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( ) ) ;
173
194
174
195
p. cargo ( "run --verbose -Ztrim-paths" )
175
196
. 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
+ ) )
179
216
. run ( ) ;
180
217
}
181
218
@@ -209,13 +246,27 @@ fn git_dependency() {
209
246
. build ( ) ;
210
247
211
248
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( ) ) ;
213
250
214
251
p. cargo ( "run --verbose -Ztrim-paths" )
215
252
. 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
+ ) )
219
270
. run ( ) ;
220
271
}
221
272
@@ -247,8 +298,21 @@ fn path_dependency() {
247
298
p. cargo ( "run --verbose -Ztrim-paths" )
248
299
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
249
300
. 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
+ ) )
252
316
. run ( ) ;
253
317
}
254
318
@@ -282,9 +346,22 @@ fn path_dependency_outside_workspace() {
282
346
283
347
p. cargo ( "run --verbose -Ztrim-paths" )
284
348
. 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
+ ) )
288
365
. run ( ) ;
289
366
}
290
367
@@ -314,13 +391,29 @@ fn diagnostics_works() {
314
391
315
392
let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
316
393
let registry_src = registry_src. display ( ) ;
394
+ let pkg_remap = format ! ( "{registry_src}/[..]/bar-0.0.1=bar-0.0.1" ) ;
317
395
318
396
p. cargo ( "build -vv -Ztrim-paths" )
319
397
. 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
+ )
321
402
. 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
+ )
324
417
. run ( ) ;
325
418
}
326
419
@@ -338,6 +431,8 @@ fn object_works() {
338
431
} ;
339
432
340
433
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 ( ) ;
341
436
let registry_src_bytes = registry_src. as_os_str ( ) . as_bytes ( ) ;
342
437
343
438
Package :: new ( "bar" , "0.0.1" )
@@ -393,16 +488,26 @@ fn object_works() {
393
488
394
489
p. cargo ( "build --verbose -Ztrim-paths" )
395
490
. 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
+ ) )
398
505
. run ( ) ;
399
506
400
507
let bin_path = p. bin ( "foo" ) ;
401
508
assert ! ( bin_path. is_file( ) ) ;
402
509
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( ) ) ;
408
513
}
0 commit comments