use cargo_test_support::registry::{Dependency, Package};
use cargo_test_support::{project, publish};
-#[cargo_test]
-fn gated() {
- // Need namespaced-features to use `dep:` syntax.
- Package::new("bar", "1.0.0").publish();
- let p = project()
- .file(
- "Cargo.toml",
- r#"
- [package]
- name = "foo"
- version = "0.1.0"
-
- [dependencies]
- bar = { version = "1.0", optional = true }
-
- [features]
- foo = ["dep:bar"]
- "#,
- )
- .file("src/lib.rs", "")
- .build();
-
- p.cargo("check")
- .with_status(101)
- .with_stderr(
- "\
-[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
-
-Caused by:
- namespaced features with the `dep:` prefix are only allowed on the nightly channel \
- and requires the `-Z namespaced-features` flag on the command-line
-",
- )
- .run();
-}
-
-#[cargo_test]
-fn dependency_gate_ignored() {
- // Dependencies with `dep:` features are ignored in the registry if not on nightly.
- Package::new("baz", "1.0.0").publish();
- Package::new("bar", "1.0.0")
- .add_dep(Dependency::new("baz", "1.0").optional(true))
- .feature("feat", &["dep:baz"])
- .publish();
- let p = project()
- .file(
- "Cargo.toml",
- r#"
- [package]
- name = "foo"
- version = "0.1.0"
-
- [dependencies]
- bar = "1.0"
- "#,
- )
- .file("src/lib.rs", "")
- .build();
-
- p.cargo("check")
- .masquerade_as_nightly_cargo()
- .with_status(101)
- .with_stderr(
- "\
-[UPDATING] [..]
-[ERROR] no matching package named `bar` found
-location searched: registry `crates-io`
-required by package `foo v0.1.0 ([..]/foo)`
-",
- )
- .run();
-
- // Publish a version without namespaced features, it should ignore 1.0.0
- // and use this instead.
- Package::new("bar", "1.0.1")
- .add_dep(Dependency::new("baz", "1.0").optional(true))
- .feature("feat", &["baz"])
- .publish();
- p.cargo("check")
- .masquerade_as_nightly_cargo()
- .with_stderr(
- "\
-[UPDATING] [..]
-[DOWNLOADING] crates ...
-[DOWNLOADED] bar [..]
-[CHECKING] bar v1.0.1
-[CHECKING] foo v0.1.0 [..]
-[FINISHED] [..]
-",
- )
- .run();
-}
-
#[cargo_test]
fn dependency_with_crate_syntax() {
// Registry dependency uses dep: syntax.
.file("src/lib.rs", "")
.build();
- p.cargo("check -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("check")
.with_stderr(
"\
[UPDATING] [..]
.file("src/main.rs", "")
.build();
- p.cargo("build -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("build")
.with_status(101)
.with_stderr(
"\
.file("src/main.rs", "")
.build();
- p.cargo("build -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("build")
.with_status(101)
.with_stderr(
"\
.file("src/main.rs", "")
.build();
- p.cargo("build -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("build")
+
.with_status(101)
.with_stderr(
"\
.file("src/main.rs", "fn main() {}")
.build();
- p.cargo("check -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("check")
.with_stderr(
"\
[UPDATING] [..]
",
)
.run();
- p.cargo("check -Z namespaced-features --features baz")
- .masquerade_as_nightly_cargo()
+ p.cargo("check --features baz")
.with_stderr(
"\
[DOWNLOADING] crates ...
.file("src/main.rs", "fn main() {}")
.build();
- p.cargo("build -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("build")
.with_status(101)
.with_stderr(
"\
.file("src/lib.rs", "")
.build();
- p.cargo("check -Z namespaced-features")
- .masquerade_as_nightly_cargo()
- .run();
+ p.cargo("check").run();
}
#[cargo_test]
.file("src/main.rs", "fn main() {}")
.build();
- p.cargo("build -Z namespaced-features").masquerade_as_nightly_cargo().with_status(101).with_stderr(
+ p.cargo("build").with_status(101).with_stderr(
"\
[ERROR] failed to parse manifest at `[..]`
)
.build();
- p.cargo("run -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("run")
.with_stderr(
"\
[UPDATING] [..]
.with_stdout("")
.run();
- p.cargo("run -Z namespaced-features --features baz")
- .masquerade_as_nightly_cargo()
+ p.cargo("run --features baz")
.with_stderr(
"\
[DOWNLOADING] crates ...
)
.build();
- p.cargo("run -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("run")
.with_stderr(
"\
[UPDATING] [..]
.with_stdout("")
.run();
- p.cargo("run -Z namespaced-features --features regex")
- .masquerade_as_nightly_cargo()
+ p.cargo("run --features regex")
.with_stderr_unordered(
"\
[DOWNLOADING] crates ...
.with_stdout("regex")
.run();
- p.cargo("run -Z namespaced-features --features lazy_static")
- .masquerade_as_nightly_cargo()
+ p.cargo("run --features lazy_static")
.with_stderr(
"\
[ERROR] Package `foo v0.1.0 [..]` does not have feature `lazy_static`. \
.file("src/lib.rs", "")
.build();
- p.cargo("check -Z namespaced-features --features dep:bar")
- .masquerade_as_nightly_cargo()
+ p.cargo("check --features dep:bar")
.with_status(101)
.with_stderr(
"\
.file("src/lib.rs", "")
.build();
- p.cargo("check -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("check")
.with_status(101)
.with_stderr(
"\
.file("src/lib.rs", "")
.build();
- p.cargo("check -Z namespaced-features --features dep:bar")
- .masquerade_as_nightly_cargo()
+ p.cargo("check --features dep:bar")
.with_status(101)
.with_stderr(
"\
.run();
switch_to_resolver_2(&p);
- p.cargo("check -Z namespaced-features --features dep:bar")
- .masquerade_as_nightly_cargo()
+ p.cargo("check --features dep:bar")
.with_status(101)
.with_stderr(
"\
.file("src/main.rs", "fn main() {}")
.build();
- p.cargo("check -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("check")
.with_status(101)
.with_stderr(
"\
.file("src/lib.rs", "")
.build();
- p.cargo("metadata -Z namespaced-features --no-deps")
- .masquerade_as_nightly_cargo()
+ p.cargo("metadata --no-deps")
.with_json(
r#"
{
)
.build();
- p.cargo("check -Z namespaced-features --features f1")
- .masquerade_as_nightly_cargo()
+ p.cargo("check --features f1")
.with_stderr(
"\
[UPDATING] [..]
.file("src/lib.rs", "")
.build();
- p.cargo("build -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("build")
.with_status(101)
.with_stderr(
"\
.file("src/lib.rs", "")
.build();
- p.cargo("tree -e features -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features")
.with_stdout("foo v0.1.0 ([ROOT]/foo)")
.run();
- p.cargo("tree -e features --features a -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features --features a")
.with_stdout(
"\
foo v0.1.0 ([ROOT]/foo)
)
.run();
- p.cargo("tree -e features --features a -i bar -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features --features a -i bar")
.with_stdout(
"\
bar v1.0.0
)
.run();
- p.cargo("tree -e features --features bar -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features --features bar")
.with_stdout(
"\
foo v0.1.0 ([ROOT]/foo)
)
.run();
- p.cargo("tree -e features --features bar -i bar -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features --features bar -i bar")
.with_stdout(
"\
bar v1.0.0
.file("src/lib.rs", "")
.build();
- p.cargo("tree -e features -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features")
.with_stdout("foo v0.1.0 ([ROOT]/foo)")
.run();
- p.cargo("tree -e features --all-features -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features --all-features")
.with_stdout(
"\
foo v0.1.0 ([ROOT]/foo)
)
.run();
- p.cargo("tree -e features -i bar --all-features -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("tree -e features -i bar --all-features")
.with_stdout(
"\
bar v1.0.0
.file("src/lib.rs", "")
.build();
- p.cargo("publish --token sekrit -Z namespaced-features")
- .masquerade_as_nightly_cargo()
+ p.cargo("publish --token sekrit")
.with_stderr(
"\
[UPDATING] [..]