11//! Tests for edition setting.
22
3- #![ allow( deprecated) ]
4-
53use cargo:: core:: Edition ;
6- use cargo_test_support:: { basic_lib_manifest, project} ;
4+ use cargo_test_support:: { basic_lib_manifest, project, str } ;
75
86#[ cargo_test]
97fn edition_works_for_build_script ( ) {
@@ -66,21 +64,17 @@ fn edition_unstable_gated() {
6664
6765 p. cargo ( "check" )
6866 . with_status ( 101 )
69- . with_stderr ( & format ! (
67+ . with_stderr_data ( format ! (
7068 "\
71- [ERROR] failed to parse manifest at `[.. ]/foo/Cargo.toml`
69+ [ERROR] failed to parse manifest at `[ROOT ]/foo/Cargo.toml`
7270
7371Caused by:
7472 feature `edition{next}` is required
7573
76- The package requires the Cargo feature called `edition{next}`, \
77- but that feature is not stabilized in this version of Cargo (1.[..]).
74+ The package requires the Cargo feature called `edition{next}`, but that feature is not stabilized in this version of Cargo (1.[..]).
7875 Consider trying a newer version of Cargo (this may require the nightly release).
79- See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} \
80- for more information about the status of this feature.
81- " ,
82- next = next
83- ) )
76+ See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} for more information about the status of this feature.
77+ " ) )
8478 . run ( ) ;
8579}
8680
@@ -116,12 +110,11 @@ fn edition_unstable() {
116110
117111 p. cargo ( "check" )
118112 . masquerade_as_nightly_cargo ( & [ "always_nightly" ] )
119- . with_stderr (
120- "\
121- [CHECKING] foo [..]
122- [FINISHED] [..]
123- " ,
124- )
113+ . with_stderr_data ( str![ [ r#"
114+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
115+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
116+
117+ "# ] ] )
125118 . run ( ) ;
126119}
127120
@@ -140,14 +133,13 @@ fn unset_edition_with_unset_rust_version() {
140133 . build ( ) ;
141134
142135 p. cargo ( "check -v" )
143- . with_stderr (
144- "\
136+ . with_stderr_data ( str![ [ r#"
145137[WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
146- [CHECKING] foo [..]
138+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
147139[RUNNING] `rustc [..] --edition=2015 [..]`
148- [FINISHED] [..]
149- " ,
150- )
140+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
141+
142+ "# ] ] )
151143 . run ( ) ;
152144}
153145
@@ -167,13 +159,12 @@ fn unset_edition_works_with_no_newer_compatible_edition() {
167159 . build ( ) ;
168160
169161 p. cargo ( "check -v" )
170- . with_stderr (
171- "\
172- [CHECKING] foo [..]
162+ . with_stderr_data ( str![ [ r#"
163+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
173164[RUNNING] `rustc [..] --edition=2015 [..]`
174- [FINISHED] [..]
175- " ,
176- )
165+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
166+
167+ "# ] ] )
177168 . run ( ) ;
178169}
179170
@@ -193,13 +184,12 @@ fn unset_edition_works_on_old_msrv() {
193184 . build ( ) ;
194185
195186 p. cargo ( "check -v" )
196- . with_stderr (
197- "\
187+ . with_stderr_data ( str![ [ r#"
198188[WARNING] no edition set: defaulting to the 2015 edition while 2018 is compatible with `rust-version`
199- [CHECKING] foo [..]
189+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
200190[RUNNING] `rustc [..] --edition=2015 [..]`
201- [FINISHED] [..]
202- " ,
203- )
191+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
192+
193+ "# ] ] )
204194 . run ( ) ;
205195}
0 commit comments