@@ -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,32 +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=[..]" )
144
- . run ( ) ;
145
- }
146
-
147
- #[ cargo_test( nightly, reason = "-Zremap-path-scope is unstable" ) ]
148
- fn multiple_options_with_none ( ) {
149
- let p = project ( )
150
- . file (
151
- "Cargo.toml" ,
152
- r#"
153
- [package]
154
- name = "foo"
155
- version = "0.0.1"
156
-
157
- [profile.dev]
158
- trim-paths = ["diagnostics", "macro", "object", "all", "none"]
159
- "# ,
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 [..]" ,
160
164
)
161
- . file ( "src/lib.rs" , "" )
162
- . build ( ) ;
163
-
164
- p. cargo ( "build --verbose -Ztrim-paths" )
165
- . masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
166
- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
167
- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
168
165
. run ( ) ;
169
166
}
170
167
@@ -193,13 +190,29 @@ fn registry_dependency() {
193
190
. build ( ) ;
194
191
195
192
let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
196
- let registry_src = registry_src. display ( ) ;
193
+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
197
194
198
195
p. cargo ( "run --verbose -Ztrim-paths" )
199
196
. 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=[..]" )
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
+ ) )
203
216
. run ( ) ;
204
217
}
205
218
@@ -233,13 +246,27 @@ fn git_dependency() {
233
246
. build ( ) ;
234
247
235
248
let git_checkouts_src = paths:: home ( ) . join ( ".cargo/git/checkouts" ) ;
236
- let git_checkouts_src = git_checkouts_src. display ( ) ;
249
+ let pkg_remap = format ! ( "{}/bar-[..]/[..]=bar-0.0.1" , git_checkouts_src. display( ) ) ;
237
250
238
251
p. cargo ( "run --verbose -Ztrim-paths" )
239
252
. 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=[..]" )
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
+ ) )
243
270
. run ( ) ;
244
271
}
245
272
@@ -271,8 +298,21 @@ fn path_dependency() {
271
298
p. cargo ( "run --verbose -Ztrim-paths" )
272
299
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
273
300
. 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=[..]" )
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
+ ) )
276
316
. run ( ) ;
277
317
}
278
318
@@ -306,9 +346,22 @@ fn path_dependency_outside_workspace() {
306
346
307
347
p. cargo ( "run --verbose -Ztrim-paths" )
308
348
. 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=[..]" )
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
+ ) )
312
365
. run ( ) ;
313
366
}
314
367
@@ -337,22 +390,34 @@ fn diagnostics_works() {
337
390
. build ( ) ;
338
391
339
392
let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
340
- let registry_src = registry_src. display ( ) ;
393
+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
341
394
342
395
p. cargo ( "build -vv -Ztrim-paths" )
343
396
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
344
- . with_stderr_contains ( format ! (
397
+ . with_stderr_contains (
345
398
"\
346
399
warning: unused variable: `unused`
347
- --> {registry_src}/[..]/ bar-0.0.1/src/lib.rs:1:18
400
+ --> bar-0.0.1/src/lib.rs:1:18
348
401
|
349
- 1 | pub fn f() {{ let unused = 0; } }
402
+ 1 | pub fn f() { let unused = 0; }
350
403
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
351
404
|
352
405
= note: `#[warn(unused_variables)]` on by default" ,
406
+ )
407
+ . with_stderr_contains ( & format ! (
408
+ "\
409
+ [RUNNING] [..]rustc [..]\
410
+ -Zremap-path-scope=diagnostics \
411
+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
412
+ --remap-path-prefix={pkg_remap} [..]",
353
413
) )
354
- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
355
- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
414
+ . with_stderr_contains (
415
+ "\
416
+ [RUNNING] [..]rustc [..]\
417
+ -Zremap-path-scope=diagnostics \
418
+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
419
+ --remap-path-prefix=[CWD]= [..]",
420
+ )
356
421
. run ( ) ;
357
422
}
358
423
@@ -370,6 +435,8 @@ fn object_works() {
370
435
} ;
371
436
372
437
let registry_src = paths:: home ( ) . join ( ".cargo/registry/src" ) ;
438
+ let pkg_remap = format ! ( "{}/[..]/bar-0.0.1=bar-0.0.1" , registry_src. display( ) ) ;
439
+ let rust_src = "/lib/rustc/src/rust" . as_bytes ( ) ;
373
440
let registry_src_bytes = registry_src. as_os_str ( ) . as_bytes ( ) ;
374
441
375
442
Package :: new ( "bar" , "0.0.1" )
@@ -425,16 +492,26 @@ fn object_works() {
425
492
426
493
p. cargo ( "build --verbose -Ztrim-paths" )
427
494
. masquerade_as_nightly_cargo ( & [ "-Ztrim-paths" ] )
428
- . with_stderr_does_not_contain ( "[..]-Zremap-path-scope=[..]" )
429
- . with_stderr_does_not_contain ( "[..]--remap-path-prefix=[..]" )
495
+ . with_stderr ( & format ! (
496
+ "\
497
+ [COMPILING] bar v0.0.1
498
+ [RUNNING] `rustc [..]\
499
+ -Zremap-path-scope=object \
500
+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
501
+ --remap-path-prefix={pkg_remap} [..]
502
+ [COMPILING] foo v0.0.1 ([CWD])
503
+ [RUNNING] `rustc [..]\
504
+ -Zremap-path-scope=object \
505
+ --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
506
+ --remap-path-prefix=[CWD]= [..]
507
+ [FINISHED] dev [..]" ,
508
+ ) )
430
509
. run ( ) ;
431
510
432
511
let bin_path = p. bin ( "foo" ) ;
433
512
assert ! ( bin_path. is_file( ) ) ;
434
513
let stdout = run_readelf ( bin_path) . stdout ;
435
- // TODO: re-enable this check when rustc bootstrap disables remapping
436
- // <https://github.com/rust-lang/cargo/pull/12625#discussion_r1371714791>
437
- // assert!(memchr::memmem::find(&stdout, rust_src).is_some());
438
- assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_some( ) ) ;
439
- assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_some( ) ) ;
514
+ assert ! ( memchr:: memmem:: find( & stdout, rust_src) . is_none( ) ) ;
515
+ assert ! ( memchr:: memmem:: find( & stdout, registry_src_bytes) . is_none( ) ) ;
516
+ assert ! ( memchr:: memmem:: find( & stdout, pkg_root) . is_none( ) ) ;
440
517
}
0 commit comments