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 ( )
@@ -53,10 +53,10 @@ fn features() {
53
53
p. cargo ( "check -v" )
54
54
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "feature" with "f_a" "f_b" ) )
55
55
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
56
- . with_stderr_does_not_contain ( "[..]-Zunstable-options[..]" )
57
56
. run ( ) ;
58
57
}
59
58
59
+ #[ allow( deprecated) ]
60
60
#[ cargo_test]
61
61
fn features_with_deps ( ) {
62
62
let p = project ( )
@@ -87,6 +87,7 @@ fn features_with_deps() {
87
87
. run ( ) ;
88
88
}
89
89
90
+ #[ allow( deprecated) ]
90
91
#[ cargo_test]
91
92
fn features_with_opt_deps ( ) {
92
93
let p = project ( )
@@ -118,6 +119,7 @@ fn features_with_opt_deps() {
118
119
. run ( ) ;
119
120
}
120
121
122
+ #[ allow( deprecated) ]
121
123
#[ cargo_test]
122
124
fn features_with_namespaced_features ( ) {
123
125
let p = project ( )
@@ -148,6 +150,7 @@ fn features_with_namespaced_features() {
148
150
. run ( ) ;
149
151
}
150
152
153
+ #[ allow( deprecated) ]
151
154
#[ cargo_test]
152
155
fn features_fingerprint ( ) {
153
156
let p = project ( )
@@ -210,14 +213,22 @@ fn features_fingerprint() {
210
213
211
214
p. cargo ( "check -v" )
212
215
// we check that the fingerprint is indeed dirty
213
- . with_stderr_contains ( "[..]Dirty[..]the list of declared features changed" )
214
216
// 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
217
// and that we indeed found a new warning from the unexpected_cfgs lint
217
- . with_stderr_contains ( "[..]unexpected_cfgs[..]" )
218
+ . with_stderr_data ( format ! (
219
+ "\
220
+ [DIRTY] foo v0.1.0 ([ROOT]/foo): the list of declared features changed
221
+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
222
+ {running_rustc}
223
+ [WARNING] unexpected `cfg` condition value: `f_b`
224
+ ...
225
+ " ,
226
+ running_rustc = x!( "rustc" => "cfg" of "feature" with "f_a" )
227
+ ) )
218
228
. run ( ) ;
219
229
}
220
230
231
+ #[ allow( deprecated) ]
221
232
#[ cargo_test]
222
233
fn well_known_names_values ( ) {
223
234
let p = project ( )
@@ -231,6 +242,7 @@ fn well_known_names_values() {
231
242
. run ( ) ;
232
243
}
233
244
245
+ #[ allow( deprecated) ]
234
246
#[ cargo_test]
235
247
fn features_test ( ) {
236
248
let p = project ( )
@@ -256,6 +268,7 @@ fn features_test() {
256
268
. run ( ) ;
257
269
}
258
270
271
+ #[ allow( deprecated) ]
259
272
#[ cargo_test]
260
273
fn features_doctest ( ) {
261
274
let p = project ( )
@@ -281,10 +294,10 @@ fn features_doctest() {
281
294
. with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "feature" with "default" "f_a" "f_b" ) )
282
295
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
283
296
. with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "docsrs" ) )
284
- . with_stderr_does_not_contain ( "[..]-Zunstable-options[..]" )
285
297
. run ( ) ;
286
298
}
287
299
300
+ #[ allow( deprecated) ]
288
301
#[ cargo_test]
289
302
fn well_known_names_values_test ( ) {
290
303
let p = project ( )
@@ -298,6 +311,7 @@ fn well_known_names_values_test() {
298
311
. run ( ) ;
299
312
}
300
313
314
+ #[ allow( deprecated) ]
301
315
#[ cargo_test]
302
316
fn well_known_names_values_doctest ( ) {
303
317
let p = project ( )
@@ -313,6 +327,7 @@ fn well_known_names_values_doctest() {
313
327
. run ( ) ;
314
328
}
315
329
330
+ #[ allow( deprecated) ]
316
331
#[ cargo_test]
317
332
fn features_doc ( ) {
318
333
let p = project ( )
@@ -336,10 +351,10 @@ fn features_doc() {
336
351
p. cargo ( "doc -v" )
337
352
. with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "feature" with "default" "f_a" "f_b" ) )
338
353
. with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "docsrs" ) )
339
- . with_stderr_does_not_contain ( "[..]-Zunstable-options[..]" )
340
354
. run ( ) ;
341
355
}
342
356
357
+ #[ allow( deprecated) ]
343
358
#[ cargo_test]
344
359
fn build_script_feedback ( ) {
345
360
let p = project ( )
@@ -364,10 +379,10 @@ fn build_script_feedback() {
364
379
p. cargo ( "check -v" )
365
380
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "foo" ) )
366
381
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
367
- . with_stderr_does_not_contain ( "[..]-Zunstable-options[..]" )
368
382
. run ( ) ;
369
383
}
370
384
385
+ #[ allow( deprecated) ]
371
386
#[ cargo_test]
372
387
fn build_script_doc ( ) {
373
388
let p = project ( )
@@ -391,21 +406,22 @@ fn build_script_doc() {
391
406
392
407
p. cargo ( "doc -v" )
393
408
. with_stderr_does_not_contain ( "rustc [..] --check-cfg [..]" )
394
- . with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "foo" ) )
395
- . with_stderr (
409
+ . with_stderr_data ( format ! (
396
410
"\
397
- [COMPILING] foo v0.0.1 ([CWD] )
411
+ [COMPILING] foo v0.0.1 ([ROOT]/foo )
398
412
[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
413
+ [RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH ]/build-script-build`
414
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
415
+ {running_rustdoc}
416
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
417
+ [GENERATED] [ROOT]/foo /target/doc/foo/index.html
404
418
" ,
405
- )
419
+ running_rustdoc = x!( "rustdoc" => "cfg" of "foo" )
420
+ ) )
406
421
. run ( ) ;
407
422
}
408
423
424
+ #[ allow( deprecated) ]
409
425
#[ cargo_test]
410
426
fn build_script_override ( ) {
411
427
let target = cargo_test_support:: rustc_host ( ) ;
@@ -491,14 +507,31 @@ fn build_script_test() {
491
507
. build ( ) ;
492
508
493
509
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 )
510
+ . with_stderr_data (
511
+ format ! (
512
+ "\
513
+ {running_rustc}
514
+ {running_rustdoc}
515
+ ...
516
+ " ,
517
+ running_rustc = x!( "rustc" => "cfg" of "foo" ) ,
518
+ running_rustdoc = x!( "rustdoc" => "cfg" of "foo" )
519
+ )
520
+ . unordered ( ) ,
521
+ )
522
+ . with_stdout_data (
523
+ str![ [ r#"
524
+ test test_foo ... ok
525
+ test test_bar ... ok
526
+ test [..] ... ok
527
+ ...
528
+ "# ] ]
529
+ . unordered ( ) ,
530
+ )
499
531
. run ( ) ;
500
532
}
501
533
534
+ #[ allow( deprecated) ]
502
535
#[ cargo_test]
503
536
fn config_simple ( ) {
504
537
let p = project ( )
@@ -524,6 +557,7 @@ fn config_simple() {
524
557
. run ( ) ;
525
558
}
526
559
560
+ #[ allow( deprecated) ]
527
561
#[ cargo_test]
528
562
fn config_workspace ( ) {
529
563
let p = project ( )
@@ -553,11 +587,19 @@ fn config_workspace() {
553
587
. build ( ) ;
554
588
555
589
p. cargo ( "check -v" )
556
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "has_foo" ) )
590
+ . with_stderr_data ( format ! (
591
+ "\
592
+ ...
593
+ {running_rustc}
594
+ ...
595
+ " ,
596
+ running_rustc = x!( "rustc" => "cfg" of "has_foo" )
597
+ ) )
557
598
. with_stderr_does_not_contain ( "unexpected_cfgs" )
558
599
. run ( ) ;
559
600
}
560
601
602
+ #[ allow( deprecated) ]
561
603
#[ cargo_test]
562
604
fn config_workspace_not_inherited ( ) {
563
605
let p = project ( )
@@ -589,6 +631,7 @@ fn config_workspace_not_inherited() {
589
631
. run ( ) ;
590
632
}
591
633
634
+ #[ allow( deprecated) ]
592
635
#[ cargo_test]
593
636
fn config_invalid_position ( ) {
594
637
let p = project ( )
@@ -608,7 +651,10 @@ fn config_invalid_position() {
608
651
. build ( ) ;
609
652
610
653
p. cargo ( "check -v" )
611
- . with_stderr_contains ( "[..]unused manifest key: `lints.rust.use_bracket.check-cfg`[..]" )
654
+ . with_stderr_data ( str![ [ r#"
655
+ [WARNING] unused manifest key: `lints.rust.use_bracket.check-cfg`
656
+ ...
657
+ "# ] ] )
612
658
. with_stderr_does_not_contain ( x ! ( "rustc" => "cfg" of "has_foo" ) )
613
659
. run ( ) ;
614
660
}
@@ -633,7 +679,10 @@ fn config_invalid_empty() {
633
679
634
680
p. cargo ( "check" )
635
681
. with_status ( 101 )
636
- . with_stderr_contains ( "[..]missing field `level`[..]" )
682
+ . with_stderr_data ( str![ [ r#"
683
+ [ERROR] missing field `level`
684
+ ...
685
+ "# ] ] )
637
686
. run ( ) ;
638
687
}
639
688
@@ -657,9 +706,10 @@ fn config_invalid_not_list() {
657
706
658
707
p. cargo ( "check" )
659
708
. with_status ( 101 )
660
- . with_stderr_contains (
661
- "[ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string" ,
662
- )
709
+ . with_stderr_data ( str![ [ r#"
710
+ [ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string
711
+ ...
712
+ "# ] ] )
663
713
. run ( ) ;
664
714
}
665
715
@@ -683,12 +733,14 @@ fn config_invalid_not_list_string() {
683
733
684
734
p. cargo ( "check" )
685
735
. with_status ( 101 )
686
- . with_stderr_contains (
687
- "[ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string" ,
688
- )
736
+ . with_stderr_data ( str![ [ r#"
737
+ [ERROR] `lints.rust.unexpected_cfgs.check-cfg` must be a list of string
738
+ ...
739
+ "# ] ] )
689
740
. run ( ) ;
690
741
}
691
742
743
+ #[ allow( deprecated) ]
692
744
#[ cargo_test]
693
745
fn config_and_features ( ) {
694
746
let p = project ( )
@@ -737,7 +789,14 @@ fn config_with_cargo_doc() {
737
789
. build ( ) ;
738
790
739
791
p. cargo ( "doc -v" )
740
- . with_stderr_contains ( x ! ( "rustdoc" => "cfg" of "has_foo" ) )
792
+ . with_stderr_data ( format ! (
793
+ "\
794
+ ...
795
+ {running_rustdoc}
796
+ ...
797
+ " ,
798
+ running_rustdoc = x!( "rustdoc" => "cfg" of "has_foo" )
799
+ ) )
741
800
. run ( ) ;
742
801
}
743
802
@@ -760,10 +819,18 @@ fn config_with_cargo_test() {
760
819
. build ( ) ;
761
820
762
821
p. cargo ( "test -v" )
763
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "has_foo" ) )
822
+ . with_stderr_data ( format ! (
823
+ "\
824
+ ...
825
+ {running_rustc}
826
+ ...
827
+ " ,
828
+ running_rustc = x!( "rustc" => "cfg" of "has_foo" )
829
+ ) )
764
830
. run ( ) ;
765
831
}
766
832
833
+ #[ allow( deprecated) ]
767
834
#[ cargo_test]
768
835
fn config_and_build_script ( ) {
769
836
let p = project ( )
@@ -793,6 +860,7 @@ fn config_and_build_script() {
793
860
. run ( ) ;
794
861
}
795
862
863
+ #[ allow( deprecated) ]
796
864
#[ cargo_test]
797
865
fn config_features_and_build_script ( ) {
798
866
let p = project ( )
@@ -828,6 +896,7 @@ fn config_features_and_build_script() {
828
896
. run ( ) ;
829
897
}
830
898
899
+ #[ allow( deprecated) ]
831
900
#[ cargo_test]
832
901
fn config_fingerprint ( ) {
833
902
let p = project ( )
0 commit comments