Skip to content

Commit

Permalink
Adding feature tests to publish and package
Browse files Browse the repository at this point in the history
  • Loading branch information
spacekookie committed Dec 29, 2018
1 parent 256fc39 commit 142bafb
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 64 deletions.
64 changes: 64 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,3 +1298,67 @@ To proceed despite this, pass the `--no-verify` flag.",

p.cargo("package --no-verify").run();
}

#[test]
fn package_with_select_features() {
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["alternative-registries"]
[project]
name = "foo"
version = "0.0.1"
authors = []
license = "MIT"
description = "foo"
[features]
required = []
optional = []
"#,
).file(
"src/main.rs",
"#[cfg(not(feature = \"required\"))]
compile_error!(\"This crate requires `required` feature!\");
fn main() {}",
).build();

p.cargo("package --features required")
.masquerade_as_nightly_cargo()
.with_status(0)
.run();
}

#[test]
fn package_with_all_features() {
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["alternative-registries"]
[project]
name = "foo"
version = "0.0.1"
authors = []
license = "MIT"
description = "foo"
[features]
required = []
optional = []
"#,
).file(
"src/main.rs",
"#[cfg(not(feature = \"required\"))]
compile_error!(\"This crate requires `required` feature!\");
fn main() {}",
).build();

p.cargo("package --all-features")
.masquerade_as_nightly_cargo()
.with_status(0)
.run();
}
Loading

0 comments on commit 142bafb

Please sign in to comment.