1
1
//! Tests for `cargo-features` definitions.
2
2
3
- use cargo_test_support:: { project, registry} ;
3
+ use cargo_test_support:: { is_nightly , project, registry} ;
4
4
5
5
#[ cargo_test]
6
6
fn feature_required ( ) {
@@ -115,6 +115,12 @@ release and is no longer necessary to be listed in the manifest
115
115
116
116
#[ cargo_test]
117
117
fn 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
+
118
124
let p = project ( )
119
125
. file (
120
126
"Cargo.toml" ,
@@ -131,11 +137,8 @@ fn allow_features() {
131
137
. file ( "src/lib.rs" , "" )
132
138
. build ( ) ;
133
139
134
- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
135
-
136
140
p. cargo ( "-Zallow-features=test-dummy-unstable build" )
137
141
. masquerade_as_nightly_cargo ( )
138
- . env ( "RUSTC_BOOTSTRAP" , "1" )
139
142
. with_stderr (
140
143
"\
141
144
[COMPILING] a [..]
@@ -146,13 +149,11 @@ fn allow_features() {
146
149
147
150
p. cargo ( "-Zallow-features=test-dummy-unstable,print-im-a-teapot -Zprint-im-a-teapot build" )
148
151
. masquerade_as_nightly_cargo ( )
149
- . env ( "RUSTC_BOOTSTRAP" , "1" )
150
152
. with_stdout ( "im-a-teapot = true" )
151
153
. run ( ) ;
152
154
153
155
p. cargo ( "-Zallow-features=test-dummy-unstable -Zprint-im-a-teapot build" )
154
156
. masquerade_as_nightly_cargo ( )
155
- . env ( "RUSTC_BOOTSTRAP" , "1" )
156
157
. with_status ( 101 )
157
158
. with_stderr (
158
159
"\
@@ -163,7 +164,6 @@ error: the feature `print-im-a-teapot` is not in the list of allowed features: [
163
164
164
165
p. cargo ( "-Zallow-features= build" )
165
166
. masquerade_as_nightly_cargo ( )
166
- . env ( "RUSTC_BOOTSTRAP" , "1" )
167
167
. with_status ( 101 )
168
168
. with_stderr (
169
169
"\
@@ -178,6 +178,12 @@ Caused by:
178
178
179
179
#[ cargo_test]
180
180
fn 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
+
181
187
let p = project ( )
182
188
. file (
183
189
"Cargo.toml" ,
@@ -196,18 +202,14 @@ fn allow_features_to_rustc() {
196
202
)
197
203
. build ( ) ;
198
204
199
- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
200
-
201
205
p. cargo ( "-Zallow-features= build" )
202
206
. masquerade_as_nightly_cargo ( )
203
- . env ( "RUSTC_BOOTSTRAP" , "1" )
204
207
. with_status ( 101 )
205
208
. with_stderr_contains ( "[..]E0725[..]" )
206
209
. run ( ) ;
207
210
208
211
p. cargo ( "-Zallow-features=test_2018_feature build" )
209
212
. masquerade_as_nightly_cargo ( )
210
- . env ( "RUSTC_BOOTSTRAP" , "1" )
211
213
. with_stderr (
212
214
"\
213
215
[COMPILING] a [..]
@@ -219,6 +221,12 @@ fn allow_features_to_rustc() {
219
221
220
222
#[ cargo_test]
221
223
fn 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
+
222
230
let p = project ( )
223
231
. file (
224
232
"Cargo.toml" ,
@@ -242,11 +250,8 @@ fn allow_features_in_cfg() {
242
250
. file ( "src/lib.rs" , "" )
243
251
. build ( ) ;
244
252
245
- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
246
-
247
253
p. cargo ( "build" )
248
254
. masquerade_as_nightly_cargo ( )
249
- . env ( "RUSTC_BOOTSTRAP" , "1" )
250
255
. with_stderr (
251
256
"\
252
257
[COMPILING] a [..]
@@ -257,14 +262,12 @@ fn allow_features_in_cfg() {
257
262
258
263
p. cargo ( "-Zprint-im-a-teapot build" )
259
264
. masquerade_as_nightly_cargo ( )
260
- . env ( "RUSTC_BOOTSTRAP" , "1" )
261
265
. with_stdout ( "im-a-teapot = true" )
262
266
. with_stderr ( "[FINISHED] [..]" )
263
267
. run ( ) ;
264
268
265
269
p. cargo ( "-Zunstable-options build" )
266
270
. masquerade_as_nightly_cargo ( )
267
- . env ( "RUSTC_BOOTSTRAP" , "1" )
268
271
. with_status ( 101 )
269
272
. with_stderr (
270
273
"\
@@ -276,7 +279,6 @@ error: the feature `unstable-options` is not in the list of allowed features: [p
276
279
// -Zallow-features overrides .cargo/config
277
280
p. cargo ( "-Zallow-features=test-dummy-unstable -Zprint-im-a-teapot build" )
278
281
. masquerade_as_nightly_cargo ( )
279
- . env ( "RUSTC_BOOTSTRAP" , "1" )
280
282
. with_status ( 101 )
281
283
. with_stderr (
282
284
"\
@@ -287,7 +289,6 @@ error: the feature `print-im-a-teapot` is not in the list of allowed features: [
287
289
288
290
p. cargo ( "-Zallow-features= build" )
289
291
. masquerade_as_nightly_cargo ( )
290
- . env ( "RUSTC_BOOTSTRAP" , "1" )
291
292
. with_status ( 101 )
292
293
. with_stderr (
293
294
"\
0 commit comments