@@ -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
@@ -163,8 +184,10 @@ fn multiple_options_with_none() {
163
184
164
185
p. cargo ( "build --verbose -Ztrim-paths" )
165
186
. 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
+ )
168
191
. run ( ) ;
169
192
}
170
193
@@ -193,13 +216,29 @@ fn registry_dependency() {
193
216
. build ( ) ;
194
217
195
218
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( ) ) ;
197
220
198
221
p. cargo ( "run --verbose -Ztrim-paths" )
199
222
. 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
+ ) )
203
242
. run ( ) ;
204
243
}
205
244
@@ -233,13 +272,27 @@ fn git_dependency() {
233
272
. build ( ) ;
234
273
235
274
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( ) ) ;
237
276
238
277
p. cargo ( "run --verbose -Ztrim-paths" )
239
278
. 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
+ ) )
243
296
. run ( ) ;
244
297
}
245
298
@@ -271,8 +324,21 @@ fn path_dependency() {
271
324
p. cargo ( "run --verbose -Ztrim-paths" )
272
325
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
273
326
. 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
+ ) )
276
342
. run ( ) ;
277
343
}
278
344
@@ -306,9 +372,22 @@ fn path_dependency_outside_workspace() {
306
372
307
373
p. cargo ( "run --verbose -Ztrim-paths" )
308
374
. 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
+ ) )
312
391
. run ( ) ;
313
392
}
314
393
@@ -337,22 +416,34 @@ fn diagnostics_works() {
337
416
. build ( ) ;
338
417
339
418
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( ) ) ;
341
420
342
421
p. cargo ( "build -vv -Ztrim-paths" )
343
422
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
344
- . with_stderr_contains ( format ! (
423
+ . with_stderr_contains (
345
424
"\
346
425
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
348
427
|
349
- 1 | pub fn f() {{ let unused = 0; } }
428
+ 1 | pub fn f() { let unused = 0; }
350
429
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
351
430
|
352
431
= 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} [..]",
353
439
) )
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
+ )
356
447
. run ( ) ;
357
448
}
358
449
@@ -369,6 +460,8 @@ fn object_works() {
369
460
} ;
370
461
371
462
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 ( ) ;
372
465
let registry_src_bytes = registry_src. as_os_str ( ) . as_bytes ( ) ;
373
466
374
467
Package :: new ( "bar" , "0.0.1" )
@@ -427,16 +520,26 @@ fn object_works() {
427
520
428
521
p. cargo ( "build --verbose -Ztrim-paths" )
429
522
. 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
+ ) )
432
537
. run ( ) ;
433
538
434
539
let bin_path = p. bin ( "foo" ) ;
435
540
assert ! ( bin_path. is_file( ) ) ;
436
541
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( ) ) ;
442
545
}
0 commit comments