11//! Tests for `cargo-features` definitions.
22
3- use cargo_test_support:: { project, registry} ;
3+ use cargo_test_support:: { is_nightly , project, registry} ;
44
55#[ cargo_test]
66fn feature_required ( ) {
@@ -115,6 +115,12 @@ release and is no longer necessary to be listed in the manifest
115115
116116#[ cargo_test]
117117fn allow_features ( ) {
118+ if !is_nightly ( ) {
119+ // -Zallow-features on rustc is nightly only
120+ eprintln ! ( "skipping test allow_features without nightly rustc" ) ;
121+ return ;
122+ }
123+
118124 let p = project ( )
119125 . file (
120126 "Cargo.toml" ,
@@ -131,11 +137,8 @@ fn allow_features() {
131137 . file ( "src/lib.rs" , "" )
132138 . build ( ) ;
133139
134- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
135-
136140 p. cargo ( "-Zallow-features=test-dummy-unstable build" )
137141 . masquerade_as_nightly_cargo ( )
138- . env ( "RUSTC_BOOTSTRAP" , "1" )
139142 . with_stderr (
140143 "\
141144 [COMPILING] a [..]
@@ -146,13 +149,11 @@ fn allow_features() {
146149
147150 p. cargo ( "-Zallow-features=test-dummy-unstable,print-im-a-teapot -Zprint-im-a-teapot build" )
148151 . masquerade_as_nightly_cargo ( )
149- . env ( "RUSTC_BOOTSTRAP" , "1" )
150152 . with_stdout ( "im-a-teapot = true" )
151153 . run ( ) ;
152154
153155 p. cargo ( "-Zallow-features=test-dummy-unstable -Zprint-im-a-teapot build" )
154156 . masquerade_as_nightly_cargo ( )
155- . env ( "RUSTC_BOOTSTRAP" , "1" )
156157 . with_status ( 101 )
157158 . with_stderr (
158159 "\
@@ -163,7 +164,6 @@ error: the feature `print-im-a-teapot` is not in the list of allowed features: [
163164
164165 p. cargo ( "-Zallow-features= build" )
165166 . masquerade_as_nightly_cargo ( )
166- . env ( "RUSTC_BOOTSTRAP" , "1" )
167167 . with_status ( 101 )
168168 . with_stderr (
169169 "\
@@ -178,6 +178,12 @@ Caused by:
178178
179179#[ cargo_test]
180180fn allow_features_to_rustc ( ) {
181+ if !is_nightly ( ) {
182+ // -Zallow-features on rustc is nightly only
183+ eprintln ! ( "skipping test allow_features_to_rustc without nightly rustc" ) ;
184+ return ;
185+ }
186+
181187 let p = project ( )
182188 . file (
183189 "Cargo.toml" ,
@@ -196,18 +202,14 @@ fn allow_features_to_rustc() {
196202 )
197203 . build ( ) ;
198204
199- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
200-
201205 p. cargo ( "-Zallow-features= build" )
202206 . masquerade_as_nightly_cargo ( )
203- . env ( "RUSTC_BOOTSTRAP" , "1" )
204207 . with_status ( 101 )
205208 . with_stderr_contains ( "[..]E0725[..]" )
206209 . run ( ) ;
207210
208211 p. cargo ( "-Zallow-features=test_2018_feature build" )
209212 . masquerade_as_nightly_cargo ( )
210- . env ( "RUSTC_BOOTSTRAP" , "1" )
211213 . with_stderr (
212214 "\
213215 [COMPILING] a [..]
@@ -219,6 +221,12 @@ fn allow_features_to_rustc() {
219221
220222#[ cargo_test]
221223fn allow_features_in_cfg ( ) {
224+ if !is_nightly ( ) {
225+ // -Zallow-features on rustc is nightly only
226+ eprintln ! ( "skipping test allow_features_in_cfg without nightly rustc" ) ;
227+ return ;
228+ }
229+
222230 let p = project ( )
223231 . file (
224232 "Cargo.toml" ,
@@ -242,11 +250,8 @@ fn allow_features_in_cfg() {
242250 . file ( "src/lib.rs" , "" )
243251 . build ( ) ;
244252
245- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
246-
247253 p. cargo ( "build" )
248254 . masquerade_as_nightly_cargo ( )
249- . env ( "RUSTC_BOOTSTRAP" , "1" )
250255 . with_stderr (
251256 "\
252257 [COMPILING] a [..]
@@ -257,14 +262,12 @@ fn allow_features_in_cfg() {
257262
258263 p. cargo ( "-Zprint-im-a-teapot build" )
259264 . masquerade_as_nightly_cargo ( )
260- . env ( "RUSTC_BOOTSTRAP" , "1" )
261265 . with_stdout ( "im-a-teapot = true" )
262266 . with_stderr ( "[FINISHED] [..]" )
263267 . run ( ) ;
264268
265269 p. cargo ( "-Zunstable-options build" )
266270 . masquerade_as_nightly_cargo ( )
267- . env ( "RUSTC_BOOTSTRAP" , "1" )
268271 . with_status ( 101 )
269272 . with_stderr (
270273 "\
@@ -276,7 +279,6 @@ error: the feature `unstable-options` is not in the list of allowed features: [p
276279 // -Zallow-features overrides .cargo/config
277280 p. cargo ( "-Zallow-features=test-dummy-unstable -Zprint-im-a-teapot build" )
278281 . masquerade_as_nightly_cargo ( )
279- . env ( "RUSTC_BOOTSTRAP" , "1" )
280282 . with_status ( 101 )
281283 . with_stderr (
282284 "\
@@ -287,7 +289,6 @@ error: the feature `print-im-a-teapot` is not in the list of allowed features: [
287289
288290 p. cargo ( "-Zallow-features= build" )
289291 . masquerade_as_nightly_cargo ( )
290- . env ( "RUSTC_BOOTSTRAP" , "1" )
291292 . with_status ( 101 )
292293 . with_stderr (
293294 "\
0 commit comments