1
1
//! Tests for cfg() expressions.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_test_support:: registry:: Package ;
6
4
use cargo_test_support:: rustc_host;
7
- use cargo_test_support:: { basic_manifest, project} ;
5
+ use cargo_test_support:: { basic_manifest, project, str } ;
8
6
9
7
#[ cargo_test]
10
8
fn cfg_easy ( ) {
@@ -56,13 +54,12 @@ fn dont_include() {
56
54
. file ( "b/src/lib.rs" , "" )
57
55
. build ( ) ;
58
56
p. cargo ( "check" )
59
- . with_stderr (
60
- "\
57
+ . with_stderr_data ( str![ [ r#"
61
58
[LOCKING] 2 packages to latest compatible versions
62
- [CHECKING] a v0.0.1 ([..] )
63
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
64
- " ,
65
- )
59
+ [CHECKING] a v0.0.1 ([ROOT]/foo )
60
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
61
+
62
+ "# ] ] )
66
63
. run ( ) ;
67
64
}
68
65
@@ -95,19 +92,18 @@ fn works_through_the_registry() {
95
92
. build ( ) ;
96
93
97
94
p. cargo ( "check" )
98
- . with_stderr (
99
- "\
100
- [UPDATING] [..] index
95
+ . with_stderr_data ( str![ [ r#"
96
+ [UPDATING] `dummy-registry` index
101
97
[LOCKING] 3 packages to latest compatible versions
102
98
[DOWNLOADING] crates ...
103
- [DOWNLOADED] [..]
104
- [DOWNLOADED] [..]
99
+ [DOWNLOADED] baz v0.1.0 (registry `dummy-registry`)
100
+ [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
105
101
[CHECKING] baz v0.1.0
106
102
[CHECKING] bar v0.1.0
107
- [CHECKING] foo v0.0.1 ([..] )
108
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
109
- " ,
110
- )
103
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
104
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
105
+
106
+ "# ] ] )
111
107
. run ( ) ;
112
108
}
113
109
@@ -145,18 +141,17 @@ fn ignore_version_from_other_platform() {
145
141
. build ( ) ;
146
142
147
143
p. cargo ( "check" )
148
- . with_stderr (
149
- "\
150
- [UPDATING] [..] index
144
+ . with_stderr_data ( str![ [ r#"
145
+ [UPDATING] `dummy-registry` index
151
146
[LOCKING] 3 packages to latest compatible versions
152
147
[ADDING] bar v0.1.0 (latest: v0.2.0)
153
148
[DOWNLOADING] crates ...
154
- [DOWNLOADED] [..]
149
+ [DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
155
150
[CHECKING] bar v0.1.0
156
- [CHECKING] foo v0.0.1 ([..] )
157
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
158
- " ,
159
- )
151
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
152
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
153
+
154
+ "# ] ] )
160
155
. run ( ) ;
161
156
}
162
157
@@ -181,14 +176,13 @@ fn bad_target_spec() {
181
176
182
177
p. cargo ( "check" )
183
178
. with_status ( 101 )
184
- . with_stderr (
185
- "\
186
- [ERROR] failed to parse manifest at `[..]`
179
+ . with_stderr_data ( str![ [ r#"
180
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
187
181
188
182
Caused by:
189
- failed to parse `4` as a cfg expression: unexpected character `4` in cfg, [..]
190
- " ,
191
- )
183
+ failed to parse `4` as a cfg expression: unexpected character `4` in cfg, expected parens, a comma, an identifier, or a string
184
+
185
+ "# ] ] )
192
186
. run ( ) ;
193
187
}
194
188
@@ -213,14 +207,13 @@ fn bad_target_spec2() {
213
207
214
208
p. cargo ( "check" )
215
209
. with_status ( 101 )
216
- . with_stderr (
217
- "\
218
- [ERROR] failed to parse manifest at `[..]`
210
+ . with_stderr_data ( str![ [ r#"
211
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
219
212
220
213
Caused by:
221
214
failed to parse `bar =` as a cfg expression: expected a string, but cfg expression ended
222
- " ,
223
- )
215
+
216
+ "# ] ] )
224
217
. run ( ) ;
225
218
}
226
219
@@ -404,95 +397,89 @@ fn bad_cfg_discovery() {
404
397
. env ( "RUSTC" , & funky_rustc)
405
398
. env ( "FUNKY_MODE" , "bad-version" )
406
399
. with_status ( 101 )
407
- . with_stderr (
408
- "\
400
+ . with_stderr_data ( str![ [ r#"
409
401
[ERROR] `rustc -vV` didn't have a line for `host:`, got:
410
402
foo
411
403
412
- " ,
413
- )
404
+
405
+ "# ] ] )
414
406
. run ( ) ;
415
407
416
408
p. cargo ( "check" )
417
409
. env ( "RUSTC" , & funky_rustc)
418
410
. env ( "FUNKY_MODE" , "no-crate-types" )
419
411
. with_status ( 101 )
420
- . with_stderr (
421
- "\
412
+ . with_stderr_data ( str![ [ r#"
422
413
[ERROR] malformed output when learning about crate-type bin information
423
- command was: `[..] compiler[..] --crate-name ___ [..]`
414
+ command was: `[ROOT]/compiler/target/debug/ compiler[..] --crate-name ___ [..]`
424
415
(no output received)
425
- " ,
426
- )
416
+
417
+ "# ] ] )
427
418
. run ( ) ;
428
419
429
420
p. cargo ( "check" )
430
421
. env ( "RUSTC" , & funky_rustc)
431
422
. env ( "FUNKY_MODE" , "no-sysroot" )
432
423
. with_status ( 101 )
433
- . with_stderr (
434
- "\
424
+ . with_stderr_data ( str![ [ r#"
435
425
[ERROR] output of --print=sysroot missing when learning about target-specific information from rustc
436
- command was: `[..] compiler[..]--crate-type [..]`
426
+ command was: `[ROOT]/compiler/target/debug/ compiler[..]--crate-type [..]`
437
427
438
428
--- stdout
439
- [..] ___[.. ]
440
- [..]___[..]
441
- [..]___[..]
442
- [..]___[..]
443
- [..]___[..]
444
- [..]___[..]
445
-
446
- " ,
447
- )
429
+ ___[EXE ]
430
+ lib___.rlib
431
+ [..]___. [..]
432
+ [..]___. [..]
433
+ [..]___. [..]
434
+ [..]___. [..]
435
+
436
+
437
+ "# ] ] )
448
438
. run ( ) ;
449
439
450
440
p. cargo ( "check" )
451
441
. env ( "RUSTC" , & funky_rustc)
452
442
. env ( "FUNKY_MODE" , "no-split-debuginfo" )
453
443
. with_status ( 101 )
454
- . with_stderr (
455
- "\
444
+ . with_stderr_data ( str![ [ r#"
456
445
[ERROR] output of --print=split-debuginfo missing when learning about target-specific information from rustc
457
- command was: `[..] compiler[..]--crate-type [..]`
446
+ command was: `[ROOT]/compiler/target/debug/ compiler[..]--crate-type [..]`
458
447
459
448
--- stdout
460
- [..] ___[.. ]
461
- [..]___[..]
462
- [..]___[..]
463
- [..]___[..]
464
- [..]___[..]
465
- [..]___[..]
466
- [..]
467
-
468
- " ,
469
- )
449
+ ___[EXE ]
450
+ lib___.rlib
451
+ [..]___. [..]
452
+ [..]___. [..]
453
+ [..]___. [..]
454
+ [..]___. [..]
455
+ [..]rust[..]
456
+
457
+
458
+ "# ] ] )
470
459
. run ( ) ;
471
460
472
461
p. cargo ( "check" )
473
462
. env ( "RUSTC" , & funky_rustc)
474
463
. env ( "FUNKY_MODE" , "bad-cfg" )
475
464
. with_status ( 101 )
476
- . with_stderr (
477
- "\
465
+ . with_stderr_data ( str![ [ r#"
478
466
[ERROR] failed to parse the cfg from `rustc --print=cfg`, got:
479
- [..] ___[..]
480
- [..]___[..]
481
- [..]___[..]
482
- [..]___[..]
483
- [..]___[..]
484
- [..]___[..]
485
- [..]
486
- [..],[..]
467
+ ___
468
+ lib___.rlib
469
+ [..]___. [..]
470
+ [..]___. [..]
471
+ [..]___. [..]
472
+ [..]___. [..]
473
+ [..]rust[..]
474
+ off,packed,unpacked,
487
475
___
488
476
123
489
477
490
478
491
479
Caused by:
492
- failed to parse `123` as a cfg expression: unexpected character `1` in cfg, \
493
- expected parens, a comma, an identifier, or a string
494
- " ,
495
- )
480
+ failed to parse `123` as a cfg expression: unexpected character `1` in cfg, expected parens, a comma, an identifier, or a string
481
+
482
+ "# ] ] )
496
483
. run ( ) ;
497
484
}
498
485
@@ -526,6 +513,10 @@ fn exclusive_dep_kinds() {
526
513
p. cargo ( "check" )
527
514
. with_status ( 101 )
528
515
// can't find crate for `bar`
529
- . with_stderr_contains ( "[..]E0463[..]" )
516
+ . with_stderr_data ( str![ [ r#"
517
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
518
+ error[E0463]: can't find crate for `bar`
519
+ ...
520
+ "# ] ] )
530
521
. run ( ) ;
531
522
}
0 commit comments