1
1
//! Tests for public/private dependencies.
2
2
3
- #![ allow( deprecated) ]
4
-
3
+ use cargo_test_support:: prelude:: * ;
5
4
use cargo_test_support:: project;
6
5
use cargo_test_support:: registry:: { Dependency , Package } ;
6
+ use cargo_test_support:: str;
7
7
8
8
#[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
9
9
fn exported_priv_warning ( ) {
@@ -37,11 +37,11 @@ fn exported_priv_warning() {
37
37
38
38
p. cargo ( "check --message-format=short" )
39
39
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
40
- . with_stderr_contains (
41
- " \
42
- src/lib.rs:3:13: warning: type `[..] FromPriv` from private dependency 'priv_dep' in public interface
43
- " ,
44
- )
40
+ . with_stderr_data ( str! [ [ r#"
41
+ ...
42
+ src/lib.rs:3:13: [WARNING] type `FromPriv` from private dependency 'priv_dep' in public interface
43
+ ...
44
+ "# ] ] )
45
45
. run ( )
46
46
}
47
47
@@ -77,17 +77,16 @@ fn exported_pub_dep() {
77
77
78
78
p. cargo ( "check --message-format=short" )
79
79
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
80
- . with_stderr (
81
- "\
82
- [UPDATING] `[..]` index
80
+ . with_stderr_data ( str![ [ r#"
81
+ [UPDATING] `dummy-registry` index
83
82
[LOCKING] 2 packages to latest compatible versions
84
83
[DOWNLOADING] crates ...
85
- [DOWNLOADED] pub_dep v0.1.0 ([..] )
84
+ [DOWNLOADED] pub_dep v0.1.0 (registry `dummy-registry` )
86
85
[CHECKING] pub_dep v0.1.0
87
- [CHECKING] foo v0.0.1 ([CWD] )
88
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
89
- " ,
90
- )
86
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
87
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
88
+
89
+ "# ] ] )
91
90
. run ( )
92
91
}
93
92
@@ -105,16 +104,15 @@ pub fn requires_nightly_cargo() {
105
104
106
105
p. cargo ( "check --message-format=short" )
107
106
. with_status ( 101 )
108
- . with_stderr (
109
- "\
110
- error: failed to parse manifest at `[..]`
107
+ . with_stderr_data ( str![ [ r#"
108
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
111
109
112
110
Caused by:
113
111
the cargo feature `public-dependency` requires a nightly version of Cargo, but this is the `stable` channel
114
112
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
115
113
See https://doc.rust-lang.org/[..]cargo/reference/unstable.html#public-dependency for more information about using this feature.
116
- "
117
- )
114
+
115
+ "# ] ] )
118
116
. run ( )
119
117
}
120
118
@@ -142,18 +140,17 @@ fn requires_feature() {
142
140
143
141
p. cargo ( "check --message-format=short" )
144
142
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
145
- . with_stderr (
146
- "\
143
+ . with_stderr_data ( str![ [ r#"
147
144
[WARNING] ignoring `public` on dependency pub_dep, pass `-Zpublic-dependency` to enable support for it
148
- [UPDATING] `[..] ` index
145
+ [UPDATING] `dummy-registry ` index
149
146
[LOCKING] 2 packages to latest compatible versions
150
147
[DOWNLOADING] crates ...
151
- [DOWNLOADED] pub_dep v0.1.0 ([..] )
148
+ [DOWNLOADED] pub_dep v0.1.0 (registry `dummy-registry` )
152
149
[CHECKING] pub_dep v0.1.0
153
- [CHECKING] foo v0.0.1 ([CWD] )
154
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
155
- " ,
156
- )
150
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
151
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
152
+
153
+ "# ] ] )
157
154
. run ( )
158
155
}
159
156
@@ -190,14 +187,13 @@ fn pub_dev_dependency() {
190
187
p. cargo ( "check --message-format=short" )
191
188
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
192
189
. with_status ( 101 )
193
- . with_stderr (
194
- "\
195
- error: failed to parse manifest at `[..]`
190
+ . with_stderr_data ( str![ [ r#"
191
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
196
192
197
193
Caused by:
198
194
'public' specifier can only be used on regular dependencies, not dev-dependencies
199
- " ,
200
- )
195
+
196
+ "# ] ] )
201
197
. run ( )
202
198
}
203
199
@@ -231,14 +227,13 @@ fn pub_dev_dependency_without_feature() {
231
227
232
228
p. cargo ( "check --message-format=short" )
233
229
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
234
- . with_stderr (
235
- "\
230
+ . with_stderr_data ( str![ [ r#"
236
231
[WARNING] 'public' specifier can only be used on regular dependencies, not dev-dependencies
237
- [UPDATING] `[..] ` index
232
+ [UPDATING] `dummy-registry ` index
238
233
[LOCKING] 2 packages to latest compatible versions
239
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
240
- " ,
241
- )
234
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
235
+
236
+ "# ] ] )
242
237
. run ( )
243
238
}
244
239
@@ -290,14 +285,13 @@ fn workspace_pub_disallowed() {
290
285
p. cargo ( "check" )
291
286
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
292
287
. with_status ( 101 )
293
- . with_stderr (
294
- "\
295
- error: failed to parse manifest at `[CWD]/Cargo.toml`
288
+ . with_stderr_data ( str![ [ r#"
289
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
296
290
297
291
Caused by:
298
292
foo2 is public, but workspace dependencies cannot be public
299
- " ,
300
- )
293
+
294
+ "# ] ] )
301
295
. run ( )
302
296
}
303
297
@@ -333,17 +327,16 @@ fn allow_priv_in_tests() {
333
327
334
328
p. cargo ( "check --tests --message-format=short" )
335
329
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
336
- . with_stderr (
337
- "\
338
- [UPDATING] `[..]` index
330
+ . with_stderr_data ( str![ [ r#"
331
+ [UPDATING] `dummy-registry` index
339
332
[LOCKING] 2 packages to latest compatible versions
340
333
[DOWNLOADING] crates ...
341
- [DOWNLOADED] priv_dep v0.1.0 ([..] )
334
+ [DOWNLOADED] priv_dep v0.1.0 (registry `dummy-registry` )
342
335
[CHECKING] priv_dep v0.1.0
343
- [CHECKING] foo v0.0.1 ([CWD] )
344
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
345
- " ,
346
- )
336
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
337
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
338
+
339
+ "# ] ] )
347
340
. run ( )
348
341
}
349
342
@@ -379,17 +372,16 @@ fn allow_priv_in_benchs() {
379
372
380
373
p. cargo ( "check --benches --message-format=short" )
381
374
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
382
- . with_stderr (
383
- "\
384
- [UPDATING] `[..]` index
375
+ . with_stderr_data ( str![ [ r#"
376
+ [UPDATING] `dummy-registry` index
385
377
[LOCKING] 2 packages to latest compatible versions
386
378
[DOWNLOADING] crates ...
387
- [DOWNLOADED] priv_dep v0.1.0 ([..] )
379
+ [DOWNLOADED] priv_dep v0.1.0 (registry `dummy-registry` )
388
380
[CHECKING] priv_dep v0.1.0
389
- [CHECKING] foo v0.0.1 ([CWD] )
390
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
391
- " ,
392
- )
381
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
382
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
383
+
384
+ "# ] ] )
393
385
. run ( )
394
386
}
395
387
@@ -426,17 +418,16 @@ fn allow_priv_in_bins() {
426
418
427
419
p. cargo ( "check --bins --message-format=short" )
428
420
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
429
- . with_stderr (
430
- "\
431
- [UPDATING] `[..]` index
421
+ . with_stderr_data ( str![ [ r#"
422
+ [UPDATING] `dummy-registry` index
432
423
[LOCKING] 2 packages to latest compatible versions
433
424
[DOWNLOADING] crates ...
434
- [DOWNLOADED] priv_dep v0.1.0 ([..] )
425
+ [DOWNLOADED] priv_dep v0.1.0 (registry `dummy-registry` )
435
426
[CHECKING] priv_dep v0.1.0
436
- [CHECKING] foo v0.0.1 ([CWD] )
437
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
438
- " ,
439
- )
427
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
428
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
429
+
430
+ "# ] ] )
440
431
. run ( )
441
432
}
442
433
@@ -473,17 +464,16 @@ fn allow_priv_in_examples() {
473
464
474
465
p. cargo ( "check --examples --message-format=short" )
475
466
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
476
- . with_stderr (
477
- "\
478
- [UPDATING] `[..]` index
467
+ . with_stderr_data ( str![ [ r#"
468
+ [UPDATING] `dummy-registry` index
479
469
[LOCKING] 2 packages to latest compatible versions
480
470
[DOWNLOADING] crates ...
481
- [DOWNLOADED] priv_dep v0.1.0 ([..] )
471
+ [DOWNLOADED] priv_dep v0.1.0 (registry `dummy-registry` )
482
472
[CHECKING] priv_dep v0.1.0
483
- [CHECKING] foo v0.0.1 ([CWD] )
484
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
485
- " ,
486
- )
473
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
474
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
475
+
476
+ "# ] ] )
487
477
. run ( )
488
478
}
489
479
@@ -521,17 +511,16 @@ fn allow_priv_in_custom_build() {
521
511
522
512
p. cargo ( "check --all-targets --message-format=short" )
523
513
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
524
- . with_stderr (
525
- "\
526
- [UPDATING] `[..]` index
514
+ . with_stderr_data ( str![ [ r#"
515
+ [UPDATING] `dummy-registry` index
527
516
[LOCKING] 2 packages to latest compatible versions
528
517
[DOWNLOADING] crates ...
529
- [DOWNLOADED] priv_dep v0.1.0 ([..] )
518
+ [DOWNLOADED] priv_dep v0.1.0 (registry `dummy-registry` )
530
519
[COMPILING] priv_dep v0.1.0
531
- [COMPILING] foo v0.0.1 ([CWD] )
532
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
533
- " ,
534
- )
520
+ [COMPILING] foo v0.0.1 ([ROOT]/foo )
521
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
522
+
523
+ "# ] ] )
535
524
. run ( )
536
525
}
537
526
@@ -576,19 +565,18 @@ fn publish_package_with_public_dependency() {
576
565
577
566
p. cargo ( "check --message-format=short" )
578
567
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
579
- . with_stderr (
580
- "\
581
- [UPDATING] `[..]` index
568
+ . with_stderr_data ( str![ [ r#"
569
+ [UPDATING] `dummy-registry` index
582
570
[LOCKING] 3 packages to latest compatible versions
583
571
[DOWNLOADING] crates ...
584
- [DOWNLOADED] pub_bar v0.1.0 ([..] )
585
- [DOWNLOADED] bar v0.1.0 ([..] )
572
+ [DOWNLOADED] pub_bar v0.1.0 (registry `dummy-registry` )
573
+ [DOWNLOADED] bar v0.1.0 (registry `dummy-registry` )
586
574
[CHECKING] pub_bar v0.1.0
587
575
[CHECKING] bar v0.1.0
588
- [CHECKING] foo v0.0.1 ([..] )
589
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
590
- " ,
591
- )
576
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
577
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
578
+
579
+ "# ] ] )
592
580
. run ( )
593
581
}
594
582
@@ -634,12 +622,12 @@ fn verify_mix_cargo_feature_z() {
634
622
635
623
p. cargo ( "check -Zpublic-dependency --message-format=short" )
636
624
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
637
- . with_stderr_contains (
638
- " \
639
- src/lib.rs:5:13: warning: type `FromDep` from private dependency 'dep' in public interface
640
- src/lib.rs:6:13: warning: type `FromPriv` from private dependency 'priv_dep' in public interface
641
- " ,
642
- )
625
+ . with_stderr_data ( str! [ [ r#"
626
+ ...
627
+ src/lib.rs:5:13: [WARNING] type `FromDep` from private dependency 'dep' in public interface
628
+ src/lib.rs:6:13: [WARNING] type `FromPriv` from private dependency 'priv_dep' in public interface
629
+ ...
630
+ "# ] ] )
643
631
. run ( ) ;
644
632
}
645
633
@@ -684,11 +672,14 @@ fn verify_z_public_dependency() {
684
672
685
673
p. cargo ( "check -Zpublic-dependency --message-format=short" )
686
674
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
687
- . with_stderr_contains (
688
- "\
689
- src/lib.rs:5:13: warning: type `FromDep` from private dependency 'dep' in public interface
690
- src/lib.rs:6:13: warning: type `FromPriv` from private dependency 'priv_dep' in public interface
691
- " ,
675
+ . with_stderr_data (
676
+ str![ [ r#"
677
+ ...
678
+ src/lib.rs:5:13: [WARNING] type `FromDep` from private dependency 'dep' in public interface
679
+ src/lib.rs:6:13: [WARNING] type `FromPriv` from private dependency 'priv_dep' in public interface
680
+ ...
681
+ "# ] ]
682
+ . unordered ( ) ,
692
683
)
693
684
. run ( ) ;
694
685
}
0 commit comments