1
1
//! Tests for Cargo usage of rustc `--check-cfg`.
2
2
3
- #![ allow( deprecated) ]
4
-
5
- use cargo_test_support:: { basic_manifest, project} ;
3
+ use cargo_test_support:: prelude:: * ;
4
+ use cargo_test_support:: { basic_manifest, project, str} ;
6
5
7
6
macro_rules! x {
8
7
( $tool: tt => $what: tt $( of $who: tt) ?) => { {
@@ -31,6 +30,7 @@ macro_rules! x {
31
30
} } ;
32
31
}
33
32
33
+ #[ allow( deprecated) ]
34
34
#[ cargo_test]
35
35
fn features ( ) {
36
36
let p = project ( )
@@ -57,6 +57,7 @@ fn features() {
57
57
. run ( ) ;
58
58
}
59
59
60
+ #[ allow( deprecated) ]
60
61
#[ cargo_test]
61
62
fn features_with_deps ( ) {
62
63
let p = project ( )
@@ -87,6 +88,7 @@ fn features_with_deps() {
87
88
. run ( ) ;
88
89
}
89
90
91
+ #[ allow( deprecated) ]
90
92
#[ cargo_test]
91
93
fn features_with_opt_deps ( ) {
92
94
let p = project ( )
@@ -118,6 +120,7 @@ fn features_with_opt_deps() {
118
120
. run ( ) ;
119
121
}
120
122
123
+ #[ allow( deprecated) ]
121
124
#[ cargo_test]
122
125
fn features_with_namespaced_features ( ) {
123
126
let p = project ( )
@@ -148,6 +151,7 @@ fn features_with_namespaced_features() {
148
151
. run ( ) ;
149
152
}
150
153
154
+ #[ allow( deprecated) ]
151
155
#[ cargo_test]
152
156
fn features_fingerprint ( ) {
153
157
let p = project ( )
@@ -210,14 +214,22 @@ fn features_fingerprint() {
210
214
211
215
p. cargo ( "check -v" )
212
216
// we check that the fingerprint is indeed dirty
213
- . with_stderr_contains ( "[..]Dirty[..]the list of declared features changed" )
214
217
// that is cause rustc to be called again with the new check-cfg args
215
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "feature" with "f_a" ) )
216
218
// and that we indeed found a new warning from the unexpected_cfgs lint
217
- . with_stderr_contains ( "[..]unexpected_cfgs[..]" )
219
+ . with_stderr_data ( format ! (
220
+ "\
221
+ [DIRTY] foo v0.1.0 ([ROOT]/foo): the list of declared features changed
222
+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
223
+ {running_rustc}
224
+ [WARNING] unexpected `cfg` condition value: `f_b`
225
+ ...
226
+ " ,
227
+ running_rustc = x!( "rustc" => "cfg" of "feature" with "f_a" )
228
+ ) )
218
229
. run ( ) ;
219
230
}
220
231
232
+ #[ allow( deprecated) ]
221
233
#[ cargo_test]
222
234
fn well_known_names_values ( ) {
223
235
let p = project ( )
@@ -231,6 +243,7 @@ fn well_known_names_values() {
231
243
. run ( ) ;
232
244
}
233
245
246
+ #[ allow( deprecated) ]
234
247
#[ cargo_test]
235
248
fn features_test ( ) {
236
249
let p = project ( )
@@ -256,6 +269,7 @@ fn features_test() {
256
269
. run ( ) ;
257
270
}
258
271
272
+ #[ allow( deprecated) ]
259
273
#[ cargo_test]
260
274
fn features_doctest ( ) {
261
275
let p = project ( )
@@ -285,6 +299,7 @@ fn features_doctest() {
285
299
. run ( ) ;
286
300
}
287
301
302
+ #[ allow( deprecated) ]
288
303
#[ cargo_test]
289
304
fn well_known_names_values_test ( ) {
290
305
let p = project ( )
@@ -298,6 +313,7 @@ fn well_known_names_values_test() {
298
313
. run ( ) ;
299
314
}
300
315
316
+ #[ allow( deprecated) ]
301
317
#[ cargo_test]
302
318
fn well_known_names_values_doctest ( ) {
303
319
let p = project ( )
@@ -313,6 +329,7 @@ fn well_known_names_values_doctest() {
313
329
. run ( ) ;
314
330
}
315
331
332
+ #[ allow( deprecated) ]
316
333
#[ cargo_test]
317
334
fn features_doc ( ) {
318
335
let p = project ( )
@@ -340,6 +357,7 @@ fn features_doc() {
340
357
. run ( ) ;
341
358
}
342
359
360
+ #[ allow( deprecated) ]
343
361
#[ cargo_test]
344
362
fn build_script_feedback ( ) {
345
363
let p = project ( )
@@ -368,6 +386,7 @@ fn build_script_feedback() {
368
386
. run ( ) ;
369
387
}
370
388
389
+ #[ allow( deprecated) ]
371
390
#[ cargo_test]
372
391
fn build_script_doc ( ) {
373
392
let p = project ( )
@@ -391,21 +410,22 @@ fn build_script_doc() {
391
410
392
411
p. cargo ( "doc -v" )
393
412
. with_stderr_does_not_contain ( "rustc [..] --check-cfg [..]" )
394
- . with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "foo" ) )
395
- . with_stderr (
413
+ . with_stderr_data ( format ! (
396
414
"\
397
- [COMPILING] foo v0.0.1 ([CWD] )
415
+ [COMPILING] foo v0.0.1 ([ROOT]/foo )
398
416
[RUNNING] `rustc [..] build.rs [..]`
399
- [RUNNING] `[.. ]/build-script-build`
400
- [DOCUMENTING] foo [..]
401
- [RUNNING] `rustdoc [..] src/main.rs [..]
402
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
403
- [GENERATED] [CWD] /target/doc/foo/index.html
417
+ [RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH ]/build-script-build`
418
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
419
+ {running_rustdoc}
420
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
421
+ [GENERATED] [ROOT]/foo /target/doc/foo/index.html
404
422
" ,
405
- )
423
+ running_rustdoc = x!( "rustdoc" => "cfg" of "foo" )
424
+ ) )
406
425
. run ( ) ;
407
426
}
408
427
428
+ #[ allow( deprecated) ]
409
429
#[ cargo_test]
410
430
fn build_script_override ( ) {
411
431
let target = cargo_test_support:: rustc_host ( ) ;
@@ -491,14 +511,31 @@ fn build_script_test() {
491
511
. build ( ) ;
492
512
493
513
p. cargo ( "test -v" )
494
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "foo" ) )
495
- . with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "foo" ) )
496
- . with_stdout_contains ( "test test_foo ... ok" )
497
- . with_stdout_contains ( "test test_bar ... ok" )
498
- . with_stdout_contains_n ( "test [..] ... ok" , 3 )
514
+ . with_stderr_data (
515
+ format ! (
516
+ "\
517
+ {running_rustc}
518
+ {running_rustdoc}
519
+ ...
520
+ " ,
521
+ running_rustc = x!( "rustc" => "cfg" of "foo" ) ,
522
+ running_rustdoc = x!( "rustdoc" => "cfg" of "foo" )
523
+ )
524
+ . unordered ( ) ,
525
+ )
526
+ . with_stdout_data (
527
+ str![ [ r#"
528
+ test test_foo ... ok
529
+ test test_bar ... ok
530
+ test [..] ... ok
531
+ ...
532
+ "# ] ]
533
+ . unordered ( ) ,
534
+ )
499
535
. run ( ) ;
500
536
}
501
537
538
+ #[ allow( deprecated) ]
502
539
#[ cargo_test]
503
540
fn config_simple ( ) {
504
541
let p = project ( )
@@ -524,6 +561,7 @@ fn config_simple() {
524
561
. run ( ) ;
525
562
}
526
563
564
+ #[ allow( deprecated) ]
527
565
#[ cargo_test]
528
566
fn config_workspace ( ) {
529
567
let p = project ( )
@@ -553,11 +591,19 @@ fn config_workspace() {
553
591
. build ( ) ;
554
592
555
593
p. cargo ( "check -v" )
556
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "has_foo" ) )
594
+ . with_stderr_data ( format ! (
595
+ "\
596
+ ...
597
+ {running_rustc}
598
+ ...
599
+ " ,
600
+ running_rustc = x!( "rustc" => "cfg" of "has_foo" )
601
+ ) )
557
602
. with_stderr_does_not_contain ( "unexpected_cfgs" )
558
603
. run ( ) ;
559
604
}
560
605
606
+ #[ allow( deprecated) ]
561
607
#[ cargo_test]
562
608
fn config_workspace_not_inherited ( ) {
563
609
let p = project ( )
@@ -589,6 +635,7 @@ fn config_workspace_not_inherited() {
589
635
. run ( ) ;
590
636
}
591
637
638
+ #[ allow( deprecated) ]
592
639
#[ cargo_test]
593
640
fn config_invalid_position ( ) {
594
641
let p = project ( )
@@ -608,7 +655,10 @@ fn config_invalid_position() {
608
655
. build ( ) ;
609
656
610
657
p. cargo ( "check -v" )
611
- . with_stderr_contains ( "[..]unused manifest key: `lints.rust.use_bracket.check-cfg`[..]" )
658
+ . with_stderr_data ( str![ [ r#"
659
+ [WARNING] unused manifest key: `lints.rust.use_bracket.check-cfg`
660
+ ...
661
+ "# ] ] )
612
662
. with_stderr_does_not_contain ( x ! ( "rustc" => "cfg" of "has_foo" ) )
613
663
. run ( ) ;
614
664
}
@@ -633,7 +683,10 @@ fn config_invalid_empty() {
633
683
634
684
p. cargo ( "check" )
635
685
. with_status ( 101 )
636
- . with_stderr_contains ( "[..]missing field `level`[..]" )
686
+ . with_stderr_data ( str![ [ r#"
687
+ [ERROR] missing field `level`
688
+ ...
689
+ "# ] ] )
637
690
. run ( ) ;
638
691
}
639
692
@@ -657,9 +710,10 @@ fn config_invalid_not_list() {
657
710
658
711
p. cargo ( "check" )
659
712
. with_status ( 101 )
660
- . with_stderr_contains (
661
- "[ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string" ,
662
- )
713
+ . with_stderr_data ( str![ [ r#"
714
+ [ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string
715
+ ...
716
+ "# ] ] )
663
717
. run ( ) ;
664
718
}
665
719
@@ -683,12 +737,14 @@ fn config_invalid_not_list_string() {
683
737
684
738
p. cargo ( "check" )
685
739
. with_status ( 101 )
686
- . with_stderr_contains (
687
- "[ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string" ,
688
- )
740
+ . with_stderr_data ( str![ [ r#"
741
+ [ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string
742
+ ...
743
+ "# ] ] )
689
744
. run ( ) ;
690
745
}
691
746
747
+ #[ allow( deprecated) ]
692
748
#[ cargo_test]
693
749
fn config_and_features ( ) {
694
750
let p = project ( )
@@ -737,7 +793,14 @@ fn config_with_cargo_doc() {
737
793
. build ( ) ;
738
794
739
795
p. cargo ( "doc -v" )
740
- . with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "has_foo" ) )
796
+ . with_stderr_data ( format ! (
797
+ "\
798
+ ...
799
+ {running_rustdoc}
800
+ ...
801
+ " ,
802
+ running_rustdoc = x!( "rustdoc" => "cfg" of "has_foo" )
803
+ ) )
741
804
. run ( ) ;
742
805
}
743
806
@@ -760,10 +823,18 @@ fn config_with_cargo_test() {
760
823
. build ( ) ;
761
824
762
825
p. cargo ( "test -v" )
763
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "has_foo" ) )
826
+ . with_stderr_data ( format ! (
827
+ "\
828
+ ...
829
+ {running_rustc}
830
+ ...
831
+ " ,
832
+ running_rustc = x!( "rustc" => "cfg" of "has_foo" )
833
+ ) )
764
834
. run ( ) ;
765
835
}
766
836
837
+ #[ allow( deprecated) ]
767
838
#[ cargo_test]
768
839
fn config_and_build_script ( ) {
769
840
let p = project ( )
@@ -793,6 +864,7 @@ fn config_and_build_script() {
793
864
. run ( ) ;
794
865
}
795
866
867
+ #[ allow( deprecated) ]
796
868
#[ cargo_test]
797
869
fn config_features_and_build_script ( ) {
798
870
let p = project ( )
@@ -828,6 +900,7 @@ fn config_features_and_build_script() {
828
900
. run ( ) ;
829
901
}
830
902
903
+ #[ allow( deprecated) ]
831
904
#[ cargo_test]
832
905
fn config_fingerprint ( ) {
833
906
let p = project ( )
0 commit comments