4
4
// because MSVC link.exe just gives a warning on unknown flags (how helpful!),
5
5
// and other linkers will return an error.
6
6
7
- #![ allow( deprecated) ]
8
-
9
7
use cargo_test_support:: registry:: Package ;
8
+ use cargo_test_support:: str;
10
9
use cargo_test_support:: { basic_bin_manifest, basic_lib_manifest, basic_manifest, project} ;
11
10
12
11
#[ cargo_test]
@@ -26,8 +25,11 @@ fn build_script_extra_link_arg_bin() {
26
25
27
26
p. cargo ( "build -v" )
28
27
. without_status ( )
29
- . with_stderr_contains (
30
- "[RUNNING] `rustc --crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]" ,
28
+ . with_stderr_data (
29
+ "\
30
+ ...
31
+ [RUNNING] `rustc --crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]
32
+ ..." ,
31
33
)
32
34
. run ( ) ;
33
35
}
@@ -66,11 +68,17 @@ fn build_script_extra_link_arg_bin_single() {
66
68
67
69
p. cargo ( "build -v" )
68
70
. without_status ( )
69
- . with_stderr_contains (
70
- "[RUNNING] `rustc --crate-name foo [..]-C link-arg=--bogus-flag-all -C link-arg=--bogus-flag-foo[..]" ,
71
+ . with_stderr_data (
72
+ "\
73
+ ...
74
+ [RUNNING] `rustc --crate-name foo [..]-C link-arg=--bogus-flag-all -C link-arg=--bogus-flag-foo[..]
75
+ ..." ,
71
76
)
72
- . with_stderr_contains (
73
- "[RUNNING] `rustc --crate-name bar [..]-C link-arg=--bogus-flag-all -C link-arg=--bogus-flag-bar[..]" ,
77
+ . with_stderr_data (
78
+ "\
79
+ ...
80
+ [RUNNING] `rustc --crate-name bar [..]-C link-arg=--bogus-flag-all -C link-arg=--bogus-flag-bar[..]
81
+ ..." ,
74
82
)
75
83
. run ( ) ;
76
84
}
@@ -92,8 +100,11 @@ fn build_script_extra_link_arg() {
92
100
93
101
p. cargo ( "build -v" )
94
102
. without_status ( )
95
- . with_stderr_contains (
96
- "[RUNNING] `rustc --crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]" ,
103
+ . with_stderr_data (
104
+ "\
105
+ ...
106
+ [RUNNING] `rustc --crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]
107
+ ..." ,
97
108
)
98
109
. run ( ) ;
99
110
}
@@ -127,11 +138,12 @@ fn link_arg_missing_target() {
127
138
128
139
p. cargo ( "check" )
129
140
. with_status ( 101 )
130
- . with_stderr ( " \
131
- [COMPILING] foo [..]
132
- error: invalid instruction `cargo::rustc-link-arg-bins` from build script of `foo v0.0.1 ([ROOT]/foo)`
141
+ . with_stderr_data ( str! [ [ r#"
142
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
143
+ [ERROR] invalid instruction `cargo::rustc-link-arg-bins` from build script of `foo v0.0.1 ([ROOT]/foo)`
133
144
The package foo v0.0.1 ([ROOT]/foo) does not have a bin target.
134
- " )
145
+
146
+ "# ] ] )
135
147
. run ( ) ;
136
148
137
149
p. change_file (
@@ -141,13 +153,12 @@ The package foo v0.0.1 ([ROOT]/foo) does not have a bin target.
141
153
142
154
p. cargo ( "check" )
143
155
. with_status ( 101 )
144
- . with_stderr (
145
- "\
146
- [COMPILING] foo [..]
147
- error: invalid instruction `cargo::rustc-link-arg-bin` from build script of `foo v0.0.1 ([ROOT]/foo)`
156
+ . with_stderr_data ( str![ [ r#"
157
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
158
+ [ERROR] invalid instruction `cargo::rustc-link-arg-bin` from build script of `foo v0.0.1 ([ROOT]/foo)`
148
159
The package foo v0.0.1 ([ROOT]/foo) does not have a bin target with the name `abc`.
149
- " ,
150
- )
160
+
161
+ "# ] ] )
151
162
. run ( ) ;
152
163
153
164
p. change_file (
@@ -157,13 +168,12 @@ The package foo v0.0.1 ([ROOT]/foo) does not have a bin target with the name `ab
157
168
158
169
p. cargo ( "check" )
159
170
. with_status ( 101 )
160
- . with_stderr (
161
- "\
162
- [COMPILING] foo [..]
163
- error: invalid instruction `cargo::rustc-link-arg-bin=abc` from build script of `foo v0.0.1 ([ROOT]/foo)`
171
+ . with_stderr_data ( str![ [ r#"
172
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
173
+ [ERROR] invalid instruction `cargo::rustc-link-arg-bin=abc` from build script of `foo v0.0.1 ([ROOT]/foo)`
164
174
The instruction should have the form cargo::rustc-link-arg-bin=BIN=ARG
165
- " ,
166
- )
175
+
176
+ "# ] ] )
167
177
. run ( ) ;
168
178
}
169
179
@@ -203,24 +213,26 @@ fn cdylib_link_arg_transitive() {
203
213
. build ( ) ;
204
214
p. cargo ( "build -v" )
205
215
. without_status ( )
206
- . with_stderr_contains (
216
+ . with_stderr_data (
207
217
"\
208
- [COMPILING] bar v1.0.0 [..]
218
+ ...
219
+ [COMPILING] bar v1.0.0 ([ROOT]/foo/bar)
209
220
[RUNNING] `rustc --crate-name build_script_build --edition=2015 bar/build.rs [..]
210
- [RUNNING] `[..] build- script-build[..]
211
- warning: [email protected] : cargo::rustc-link-arg-cdylib was specified in the build script of bar v1.0.0 \
221
+ [RUNNING] `[ROOT]/foo/target/debug/ build/bar-[HASH]/build- script-build`
222
+ [WARNING] [email protected] : cargo::rustc-link-arg-cdylib was specified in the build script of bar v1.0.0 \
212
223
([ROOT]/foo/bar), but that package does not contain a cdylib target
213
224
214
225
Allowing this was an unintended change in the 1.50 release, and may become an error in \
215
226
the future. For more information, see <https://github.com/rust-lang/cargo/issues/9562>.
216
227
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]
217
- [COMPILING] foo v0.1.0 [..]
228
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
218
229
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]-C link-arg=--bogus[..]`
219
- " ,
230
+ ... ",
220
231
)
221
232
. run ( ) ;
222
233
}
223
234
235
+ #[ allow( deprecated) ]
224
236
#[ cargo_test]
225
237
fn link_arg_transitive_not_allowed ( ) {
226
238
// Verify that transitive dependencies don't pass link args.
@@ -260,21 +272,20 @@ fn link_arg_transitive_not_allowed() {
260
272
. build ( ) ;
261
273
262
274
p. cargo ( "build -v" )
263
- . with_stderr (
264
- "\
265
- [UPDATING] [..]
275
+ . with_stderr_data ( str![ [ r#"
276
+ [UPDATING] `dummy-registry` index
266
277
[LOCKING] 2 packages to latest compatible versions
267
- [DOWNLOADING] [..]
268
- [DOWNLOADED] [..]
278
+ [DOWNLOADING] crates ...
279
+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
269
280
[COMPILING] bar v1.0.0
270
281
[RUNNING] `rustc --crate-name build_script_build [..]
271
- [RUNNING] `[..]/ build- script-build[..]
282
+ [RUNNING] `[ROOT]/foo/target/debug/ build/bar-[HASH]/build- script-build`
272
283
[RUNNING] `rustc --crate-name bar [..]
273
- [COMPILING] foo v0.1.0 [..]
284
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
274
285
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]
275
- [FINISHED] `dev` profile [..]
276
- " ,
277
- )
286
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
287
+
288
+ "# ] ] )
278
289
. with_stderr_does_not_contain ( "--bogus" )
279
290
. run ( ) ;
280
291
}
@@ -303,8 +314,11 @@ fn link_arg_with_doctest() {
303
314
304
315
p. cargo ( "test --doc -v" )
305
316
. without_status ( )
306
- . with_stderr_contains (
307
- "[RUNNING] `rustdoc [..]--crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]" ,
317
+ . with_stderr_data (
318
+ "\
319
+ ...
320
+ [RUNNING] `rustdoc [..]--crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]
321
+ ..." ,
308
322
)
309
323
. run ( ) ;
310
324
}
@@ -327,8 +341,11 @@ fn build_script_extra_link_arg_tests() {
327
341
328
342
p. cargo ( "test -v" )
329
343
. without_status ( )
330
- . with_stderr_contains (
331
- "[RUNNING] `rustc --crate-name test_foo [..]-C link-arg=--this-is-a-bogus-flag[..]" ,
344
+ . with_stderr_data (
345
+ "\
346
+ ...
347
+ [RUNNING] `rustc --crate-name test_foo [..]-C link-arg=--this-is-a-bogus-flag[..]
348
+ ..." ,
332
349
)
333
350
. run ( ) ;
334
351
}
@@ -351,8 +368,11 @@ fn build_script_extra_link_arg_benches() {
351
368
352
369
p. cargo ( "bench -v" )
353
370
. without_status ( )
354
- . with_stderr_contains (
355
- "[RUNNING] `rustc --crate-name bench_foo [..]-C link-arg=--this-is-a-bogus-flag[..]" ,
371
+ . with_stderr_data (
372
+ "\
373
+ ...
374
+ [RUNNING] `rustc --crate-name bench_foo [..]-C link-arg=--this-is-a-bogus-flag[..]
375
+ ..." ,
356
376
)
357
377
. run ( ) ;
358
378
}
@@ -375,8 +395,11 @@ fn build_script_extra_link_arg_examples() {
375
395
376
396
p. cargo ( "build -v --examples" )
377
397
. without_status ( )
378
- . with_stderr_contains (
379
- "[RUNNING] `rustc --crate-name example_foo [..]-C link-arg=--this-is-a-bogus-flag[..]" ,
398
+ . with_stderr_data (
399
+ "\
400
+ ...
401
+ [RUNNING] `rustc --crate-name example_foo [..]-C link-arg=--this-is-a-bogus-flag[..]
402
+ ..." ,
380
403
)
381
404
. run ( ) ;
382
405
}
0 commit comments