//! Tests for `cargo-features` definitions.
-use cargo_test_support::{project, registry};
+use cargo_test_support::{is_nightly, project, registry};
#[cargo_test]
fn feature_required() {
#[cargo_test]
fn allow_features() {
+ if !is_nightly() {
+ // -Zallow-features on rustc is nightly only
+ eprintln!("skipping test allow_features without nightly rustc");
+ return;
+ }
+
let p = project()
.file(
"Cargo.toml",
.file("src/lib.rs", "")
.build();
- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
-
p.cargo("-Zallow-features=test-dummy-unstable build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_stderr(
"\
[COMPILING] a [..]
p.cargo("-Zallow-features=test-dummy-unstable,print-im-a-teapot -Zprint-im-a-teapot build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_stdout("im-a-teapot = true")
.run();
p.cargo("-Zallow-features=test-dummy-unstable -Zprint-im-a-teapot build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_status(101)
.with_stderr(
"\
p.cargo("-Zallow-features= build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_status(101)
.with_stderr(
"\
#[cargo_test]
fn allow_features_to_rustc() {
+ if !is_nightly() {
+ // -Zallow-features on rustc is nightly only
+ eprintln!("skipping test allow_features_to_rustc without nightly rustc");
+ return;
+ }
+
let p = project()
.file(
"Cargo.toml",
)
.build();
- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
-
p.cargo("-Zallow-features= build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_status(101)
.with_stderr_contains("[..]E0725[..]")
.run();
p.cargo("-Zallow-features=test_2018_feature build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_stderr(
"\
[COMPILING] a [..]
#[cargo_test]
fn allow_features_in_cfg() {
+ if !is_nightly() {
+ // -Zallow-features on rustc is nightly only
+ eprintln!("skipping test allow_features_in_cfg without nightly rustc");
+ return;
+ }
+
let p = project()
.file(
"Cargo.toml",
.file("src/lib.rs", "")
.build();
- // NOTE: We need to use RUSTC_BOOTSTRAP here since we also need nightly rustc
-
p.cargo("build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_stderr(
"\
[COMPILING] a [..]
p.cargo("-Zprint-im-a-teapot build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_stdout("im-a-teapot = true")
.with_stderr("[FINISHED] [..]")
.run();
p.cargo("-Zunstable-options build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_status(101)
.with_stderr(
"\
// -Zallow-features overrides .cargo/config
p.cargo("-Zallow-features=test-dummy-unstable -Zprint-im-a-teapot build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_status(101)
.with_stderr(
"\
p.cargo("-Zallow-features= build")
.masquerade_as_nightly_cargo()
- .env("RUSTC_BOOTSTRAP", "1")
.with_status(101)
.with_stderr(
"\