44//! "fake" crates.io is used. Otherwise `vendor` would download the crates.io
55//! index from the network.
66
7- #![ allow( deprecated) ]
8-
97use std:: fs;
108
119use cargo_test_support:: compare:: assert_e2e;
1210use cargo_test_support:: git;
11+ use cargo_test_support:: prelude:: * ;
1312use cargo_test_support:: registry:: { self , Package , RegistryBuilder } ;
1413use cargo_test_support:: str;
1514use cargo_test_support:: { basic_lib_manifest, basic_manifest, paths, project, Project } ;
@@ -61,14 +60,14 @@ fn vendor_sample_config() {
6160 Package :: new ( "log" , "0.3.5" ) . publish ( ) ;
6261
6362 p. cargo ( "vendor --respect-source-config" )
64- . with_stdout (
65- r#" [source.crates-io]
63+ . with_stdout_data ( str! [ [ r#"
64+ [source.crates-io]
6665replace-with = "vendored-sources"
6766
6867[source.vendored-sources]
6968directory = "vendor"
70- "# ,
71- )
69+
70+ "# ] ] )
7271 . run ( ) ;
7372}
7473
@@ -93,7 +92,7 @@ fn vendor_sample_config_alt_registry() {
9392 Package :: new ( "log" , "0.3.5" ) . alternative ( true ) . publish ( ) ;
9493
9594 p. cargo ( "vendor --respect-source-config" )
96- . with_stdout ( format ! (
95+ . with_stdout_data ( format ! (
9796 r#"[source."{0}"]
9897registry = "{0}"
9998replace-with = "vendored-sources"
@@ -438,12 +437,14 @@ fn test_sync_argument() {
438437 Package :: new ( "bitflags" , "0.8.0" ) . publish ( ) ;
439438
440439 p. cargo ( "vendor --respect-source-config --manifest-path foo/Cargo.toml -s bar/Cargo.toml baz/Cargo.toml test_vendor" )
441- . with_stderr ( " \
442- error: unexpected argument 'test_vendor' found
440+ . with_stderr_data ( str! [ [ r#"
441+ [ERROR] unexpected argument 'test_vendor' found
443442
444- Usage: cargo[EXE] vendor [OPTIONS] [path]
443+ Usage: cargo vendor [OPTIONS] [path]
445444
446- For more information, try '--help'." ,
445+ For more information, try '--help'.
446+
447+ "# ] ]
447448 )
448449 . with_status ( 1 )
449450 . run ( ) ;
@@ -714,21 +715,21 @@ fn git_diff_rev() {
714715 . build ( ) ;
715716
716717 p. cargo ( "vendor --respect-source-config" )
717- . with_stdout (
718- r#" [source."git+file://[.. ]/git?rev=v0.1.0"]
719- git = [..]
718+ . with_stdout_data ( str! [ [ r#"
719+ [source."git+[ROOTURL ]/git?rev=v0.1.0"]
720+ git = "[ROOTURL]/git"
720721rev = "v0.1.0"
721722replace-with = "vendored-sources"
722723
723- [source."git+file://[.. ]/git?rev=v0.2.0"]
724- git = [..]
724+ [source."git+[ROOTURL ]/git?rev=v0.2.0"]
725+ git = "[ROOTURL]/git"
725726rev = "v0.2.0"
726727replace-with = "vendored-sources"
727728
728729[source.vendored-sources]
729730directory = "vendor"
730- "# ,
731- )
731+
732+ "# ] ] )
732733 . run ( ) ;
733734}
734735
@@ -773,22 +774,21 @@ fn git_duplicate() {
773774 Package :: new ( "b" , "0.5.0" ) . publish ( ) ;
774775
775776 p. cargo ( "vendor --respect-source-config" )
776- . with_stderr (
777- "\
778- [UPDATING] [..]
779- [UPDATING] [..]
777+ . with_stderr_data ( str![ [ r#"
778+ [UPDATING] git repository `[ROOTURL]/a`
779+ [UPDATING] `dummy-registry` index
780780[LOCKING] 4 packages to latest compatible versions
781- [DOWNLOADING] [..]
782- [DOWNLOADED] [..]
783- error: failed to sync
781+ [DOWNLOADING] crates ...
782+ [DOWNLOADED] b v0.5.0 (registry `dummy-registry`)
783+ [ERROR] failed to sync
784784
785785Caused by:
786786 found duplicate version of package `b v0.5.0` vendored from two sources:
787787
788- <tab> source 1: [..]
789- <tab> source 2: [..]
790- " ,
791- )
788+ source 1: registry `crates-io`
789+ source 2: [ROOTURL]/a# [..]
790+
791+ "# ] ] )
792792 . with_status ( 101 )
793793 . run ( ) ;
794794}
@@ -802,6 +802,7 @@ fn git_complex() {
802802 [package]
803803 name = "b"
804804 version = "0.1.0"
805+ edition = "2021"
805806
806807 [dependencies]
807808 dep_b = { path = 'dep_b' }
@@ -820,6 +821,7 @@ fn git_complex() {
820821 [package]
821822 name = "a"
822823 version = "0.1.0"
824+ edition = "2021"
823825
824826 [dependencies]
825827 b = {{ git = '{}' }}
@@ -841,6 +843,7 @@ fn git_complex() {
841843 [package]
842844 name = "foo"
843845 version = "0.1.0"
846+ edition = "2021"
844847
845848 [dependencies]
846849 a = {{ git = '{}' }}
@@ -859,10 +862,23 @@ fn git_complex() {
859862 p. change_file ( ".cargo/config.toml" , & output) ;
860863
861864 p. cargo ( "check -v" )
862- . with_stderr_contains ( "[..]foo/vendor/a/src/lib.rs[..]" )
863- . with_stderr_contains ( "[..]foo/vendor/dep_a/src/lib.rs[..]" )
864- . with_stderr_contains ( "[..]foo/vendor/b/src/lib.rs[..]" )
865- . with_stderr_contains ( "[..]foo/vendor/dep_b/src/lib.rs[..]" )
865+ . with_stderr_data (
866+ str![ [ r#"
867+ [CHECKING] dep_b v0.5.0 ([ROOTURL]/git_b#[..])
868+ [CHECKING] dep_a v0.5.0 ([ROOTURL]/git_a#[..])
869+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/dep_b/src/lib.rs [..]`
870+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/dep_a/src/lib.rs [..]`
871+ [CHECKING] b v0.1.0 ([ROOTURL]/git_b#[..])
872+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/b/src/lib.rs [..]`
873+ [CHECKING] a v0.1.0 ([ROOTURL]/git_a#[..])
874+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/a/src/lib.rs [..]`
875+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
876+ [RUNNING] `rustc [..] src/lib.rs [..]`
877+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
878+
879+ "# ] ]
880+ . unordered ( ) ,
881+ )
866882 . run ( ) ;
867883}
868884
@@ -1087,6 +1103,7 @@ fn config_instructions_works() {
10871103 [package]
10881104 name = "foo"
10891105 version = "0.1.0"
1106+ edition = "2021"
10901107
10911108 [dependencies]
10921109 dep = "0.1"
@@ -1106,9 +1123,21 @@ fn config_instructions_works() {
11061123 p. change_file ( ".cargo/config.toml" , & output) ;
11071124
11081125 p. cargo ( "check -v" )
1109- . with_stderr_contains ( "[..]foo/vendor/dep/src/lib.rs[..]" )
1110- . with_stderr_contains ( "[..]foo/vendor/altdep/src/lib.rs[..]" )
1111- . with_stderr_contains ( "[..]foo/vendor/gitdep/src/lib.rs[..]" )
1126+ . with_stderr_data (
1127+ str![ [ r#"
1128+ [CHECKING] altdep v0.1.0 (registry `alternative`)
1129+ [CHECKING] dep v0.1.0
1130+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/altdep/src/lib.rs [..]`
1131+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/gitdep/src/lib.rs [..]`
1132+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/dep/src/lib.rs [..]`
1133+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
1134+ [RUNNING] `rustc [..] src/lib.rs [..]`
1135+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1136+ [CHECKING] gitdep v0.5.0 ([ROOTURL]/gitdep#[..])
1137+
1138+ "# ] ]
1139+ . unordered ( ) ,
1140+ )
11121141 . run ( ) ;
11131142}
11141143
@@ -1214,11 +1243,11 @@ fn no_remote_dependency_no_vendor() {
12141243 . build ( ) ;
12151244
12161245 p. cargo ( "vendor" )
1217- . with_stderr (
1218- "\
1246+ . with_stderr_data ( str![ [ r#"
12191247[LOCKING] 2 packages to latest compatible versions
1220- There is no dependency to vendor in this project." ,
1221- )
1248+ There is no dependency to vendor in this project.
1249+
1250+ "# ] ] )
12221251 . run ( ) ;
12231252 assert ! ( !p. root( ) . join( "vendor" ) . exists( ) ) ;
12241253}
@@ -1241,6 +1270,7 @@ fn vendor_crate_with_ws_inherit() {
12411270 [package]
12421271 name = "bar"
12431272 version.workspace = true
1273+ edition = "2021"
12441274 "# ,
12451275 )
12461276 . file ( "bar/src/lib.rs" , "" )
@@ -1254,6 +1284,7 @@ fn vendor_crate_with_ws_inherit() {
12541284 [package]
12551285 name = "foo"
12561286 version = "0.1.0"
1287+ edition = "2021"
12571288
12581289 [dependencies]
12591290 bar = {{ git = '{}' }}
@@ -1282,6 +1313,13 @@ fn vendor_crate_with_ws_inherit() {
12821313 ) ;
12831314
12841315 p. cargo ( "check -v" )
1285- . with_stderr_contains ( "[..]foo/vendor/bar/src/lib.rs[..]" )
1316+ . with_stderr_data ( str![ [ r#"
1317+ [CHECKING] bar v0.1.0 ([ROOTURL]/ws#[..])
1318+ [RUNNING] `rustc [..] [ROOT]/foo/vendor/bar/src/lib.rs [..]`
1319+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
1320+ [RUNNING] `rustc [..] src/lib.rs [..]`
1321+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1322+
1323+ "# ] ] )
12861324 . run ( ) ;
12871325}
0 commit comments