11//! Tests for `[source]` table (source replacement).
22
3- #![ allow( deprecated) ]
4-
53use std:: fs;
64
75use cargo_test_support:: registry:: { Package , RegistryBuilder , TestRegistry } ;
8- use cargo_test_support:: { cargo_process, paths, project, t} ;
6+ use cargo_test_support:: { cargo_process, paths, project, str , t} ;
97
108fn setup_replacement ( config : & str ) -> TestRegistry {
119 let crates_io = RegistryBuilder :: new ( )
@@ -52,7 +50,10 @@ fn crates_io_token_not_sent_to_replacement() {
5250
5351 p. cargo ( "publish --no-verify --registry crates-io" )
5452 . replace_crates_io ( crates_io. index_url ( ) )
55- . with_stderr_contains ( "[UPDATING] crates.io index" )
53+ . with_stderr_data ( str![ [ r#"
54+ [UPDATING] crates.io index
55+ ...
56+ "# ] ] )
5657 . run ( ) ;
5758}
5859
@@ -69,22 +70,20 @@ fn token_sent_to_correct_registry() {
6970
7071 cargo_process ( "yank [email protected] --registry crates-io" ) 7172 . replace_crates_io ( crates_io. index_url ( ) )
72- . with_stderr (
73- "\
73+ . with_stderr_data ( str![ [ r#"
7474[UPDATING] crates.io index
757576- " ,
77- )
76+
77+ "# ] ] )
7878 . run ( ) ;
7979
8080 cargo_process ( "yank [email protected] --registry alternative" ) 8181 . replace_crates_io ( crates_io. index_url ( ) )
82- . with_stderr (
83- "\
82+ . with_stderr_data ( str![ [ r#"
8483[UPDATING] `alternative` index
858486- " ,
87- )
85+
86+ "# ] ] )
8887 . run ( ) ;
8988}
9089
@@ -107,12 +106,11 @@ fn ambiguous_registry() {
107106 cargo_process ( "yank [email protected] " ) 108107 . replace_crates_io ( crates_io. index_url ( ) )
109108 . with_status ( 101 )
110- . with_stderr (
111- "\
112- error: crates-io is replaced with remote registry alternative;
109+ . with_stderr_data ( str![ [ r#"
110+ [ERROR] crates-io is replaced with remote registry alternative;
113111include `--registry alternative` or `--registry crates-io`
114- " ,
115- )
112+
113+ "# ] ] )
116114 . run ( ) ;
117115}
118116
@@ -132,12 +130,11 @@ fn yank_with_default_crates_io() {
132130
133131 cargo_process ( "yank [email protected] " ) 134132 . replace_crates_io ( crates_io. index_url ( ) )
135- . with_stderr (
136- "\
133+ . with_stderr_data ( str![ [ r#"
137134[UPDATING] crates.io index
138135139- " ,
140- )
136+
137+ "# ] ] )
141138 . run ( ) ;
142139}
143140
@@ -157,12 +154,11 @@ fn yank_with_default_alternative() {
157154
158155 cargo_process ( "yank [email protected] " ) 159156 . replace_crates_io ( crates_io. index_url ( ) )
160- . with_stderr (
161- "\
157+ . with_stderr_data ( str![ [ r#"
162158[UPDATING] `alternative` index
163159164- " ,
165- )
160+
161+ "# ] ] )
166162 . run ( ) ;
167163}
168164
@@ -209,27 +205,26 @@ fn publish_with_replacement() {
209205 // for the verification step.
210206 p. cargo ( "publish --registry crates-io" )
211207 . replace_crates_io ( crates_io. index_url ( ) )
212- . with_stderr (
213- "\
208+ . with_stderr_data ( str![ [ r#"
214209[UPDATING] crates.io index
215210[WARNING] manifest has no documentation, homepage or repository.
216211See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
217- [PACKAGING] foo v0.0.1 ([..] )
218- [PACKAGED] [..]
219- [VERIFYING] foo v0.0.1 ([..] )
212+ [PACKAGING] foo v0.0.1 ([ROOT]/foo )
213+ [PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
214+ [VERIFYING] foo v0.0.1 ([ROOT]/foo )
220215[UPDATING] `alternative` index
221216[DOWNLOADING] crates ...
222217[DOWNLOADED] bar v1.0.0 (registry `alternative`)
223218[COMPILING] bar v1.0.0
224- [COMPILING] foo v0.0.1 ([..] foo-0.0.1)
225- [FINISHED] `dev` profile [..]
226- [UPLOADING] foo v0.0.1 ([..] )
219+ [COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/ foo-0.0.1)
220+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
221+ [UPLOADING] foo v0.0.1 ([ROOT]/foo )
227222[UPLOADED] foo v0.0.1 to registry `crates-io`
228223[NOTE] waiting for `foo v0.0.1` to be available at registry `crates-io`.
229224You may press ctrl-c to skip waiting; the crate should be available shortly.
230225[PUBLISHED] foo v0.0.1 at registry `crates-io`
231- " ,
232- )
226+
227+ "# ] ] )
233228 . run ( ) ;
234229}
235230
@@ -246,10 +241,10 @@ fn undefined_default() {
246241 cargo_process ( "yank [email protected] " ) 247242 . replace_crates_io ( crates_io. index_url ( ) )
248243 . with_status ( 101 )
249- . with_stderr (
250- " [ERROR] registry index was not found in any configuration: `undefined`
251- " ,
252- )
244+ . with_stderr_data ( str! [ [ r#"
245+ [ERROR] registry index was not found in any configuration: `undefined`
246+
247+ "# ] ] )
253248 . run ( ) ;
254249}
255250
@@ -286,16 +281,15 @@ fn source_replacement_with_registry_url() {
286281
287282 p. cargo ( "check" )
288283 . replace_crates_io ( crates_io. index_url ( ) )
289- . with_stderr (
290- "\
284+ . with_stderr_data ( str![ [ r#"
291285[UPDATING] `using-registry-url` index
292286[LOCKING] 2 packages to latest compatible versions
293287[DOWNLOADING] crates ...
294288[DOWNLOADED] bar v0.0.1 (registry `using-registry-url`)
295289[CHECKING] bar v0.0.1
296- [CHECKING] foo v0.0.1 ([CWD] )
297- [FINISHED] `dev` profile [..]
298- " ,
299- )
290+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
291+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
292+
293+ "# ] ] )
300294 . run ( ) ;
301295}
0 commit comments