]> git.proxmox.com Git - cargo.git/commitdiff
Move namespaced features tests to a separate file.
authorEric Huss <eric@huss.org>
Mon, 19 Oct 2020 23:51:02 +0000 (16:51 -0700)
committerEric Huss <eric@huss.org>
Fri, 23 Oct 2020 23:04:41 +0000 (16:04 -0700)
tests/testsuite/features.rs
tests/testsuite/features_namespaced.rs [new file with mode: 0644]
tests/testsuite/main.rs

index bb35bad4e02cbef83fa4fd048720fa3547851bd2..dc346e7fed7b30854fca24bd1bd3ae7ac44be341 100644 (file)
@@ -1353,277 +1353,6 @@ fn many_cli_features_comma_and_space_delimited() {
         .run();
 }
 
-#[cargo_test]
-fn namespaced_invalid_feature() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                bar = ["baz"]
-            "#,
-        )
-        .file("src/main.rs", "")
-        .build();
-
-    p.cargo("build")
-        .masquerade_as_nightly_cargo()
-        .with_status(101)
-        .with_stderr(
-            "\
-[ERROR] failed to parse manifest at `[..]`
-
-Caused by:
-  Feature `bar` includes `baz` which is not defined as a feature
-",
-        )
-        .run();
-}
-
-#[cargo_test]
-fn namespaced_invalid_dependency() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                bar = ["crate:baz"]
-            "#,
-        )
-        .file("src/main.rs", "")
-        .build();
-
-    p.cargo("build")
-        .masquerade_as_nightly_cargo()
-        .with_status(101)
-        .with_stderr(
-            "\
-[ERROR] failed to parse manifest at `[..]`
-
-Caused by:
-  Feature `bar` includes `crate:baz` which is not a known dependency
-",
-        )
-        .run();
-}
-
-#[cargo_test]
-fn namespaced_non_optional_dependency() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                bar = ["crate:baz"]
-
-                [dependencies]
-                baz = "0.1"
-            "#,
-        )
-        .file("src/main.rs", "")
-        .build();
-
-    p.cargo("build")
-        .masquerade_as_nightly_cargo()
-        .with_status(101)
-        .with_stderr(
-            "\
-[ERROR] failed to parse manifest at `[..]`
-
-Caused by:
-  Feature `bar` includes `crate:baz` which is not an optional dependency.
-  Consider adding `optional = true` to the dependency
-",
-        )
-        .run();
-}
-
-#[cargo_test]
-fn namespaced_implicit_feature() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                bar = ["baz"]
-
-                [dependencies]
-                baz = { version = "0.1", optional = true }
-            "#,
-        )
-        .file("src/main.rs", "fn main() {}")
-        .build();
-
-    p.cargo("build").masquerade_as_nightly_cargo().run();
-}
-
-#[cargo_test]
-fn namespaced_shadowed_dep() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                baz = []
-
-                [dependencies]
-                baz = { version = "0.1", optional = true }
-            "#,
-        )
-        .file("src/main.rs", "fn main() {}")
-        .build();
-
-    p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr(
-        "\
-[ERROR] failed to parse manifest at `[..]`
-
-Caused by:
-  Feature `baz` includes the optional dependency of the same name, but this is left implicit in the features included by this feature.
-  Consider adding `crate:baz` to this feature's requirements.
-",
-    )
-        .run();
-}
-
-#[cargo_test]
-fn namespaced_shadowed_non_optional() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                baz = []
-
-                [dependencies]
-                baz = "0.1"
-            "#,
-        )
-        .file("src/main.rs", "fn main() {}")
-        .build();
-
-    p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr(
-        "\
-[ERROR] failed to parse manifest at `[..]`
-
-Caused by:
-  Feature `baz` includes the dependency of the same name, but this is left implicit in the features included by this feature.
-  Additionally, the dependency must be marked as optional to be included in the feature definition.
-  Consider adding `crate:baz` to this feature's requirements and marking the dependency as `optional = true`
-",
-    )
-        .run();
-}
-
-#[cargo_test]
-fn namespaced_implicit_non_optional() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                bar = ["baz"]
-
-                [dependencies]
-                baz = "0.1"
-            "#,
-        )
-        .file("src/main.rs", "fn main() {}")
-        .build();
-
-    p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr(
-        "\
-[ERROR] failed to parse manifest at `[..]`
-
-Caused by:
-  Feature `bar` includes `baz` which is not defined as a feature.
-  A non-optional dependency of the same name is defined; consider adding `optional = true` to its definition
-",
-    ).run();
-}
-
-#[cargo_test]
-fn namespaced_same_name() {
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                cargo-features = ["namespaced-features"]
-
-                [project]
-                name = "foo"
-                version = "0.0.1"
-                authors = []
-                namespaced-features = true
-
-                [features]
-                baz = ["crate:baz"]
-
-                [dependencies]
-                baz = { version = "0.1", optional = true }
-            "#,
-        )
-        .file("src/main.rs", "fn main() {}")
-        .build();
-
-    p.cargo("build").masquerade_as_nightly_cargo().run();
-}
-
 #[cargo_test]
 fn only_dep_is_optional() {
     Package::new("bar", "0.1.0").publish();
diff --git a/tests/testsuite/features_namespaced.rs b/tests/testsuite/features_namespaced.rs
new file mode 100644 (file)
index 0000000..5cee06d
--- /dev/null
@@ -0,0 +1,274 @@
+//! Tests for namespaced features.
+
+use cargo_test_support::project;
+
+#[cargo_test]
+fn namespaced_invalid_feature() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                bar = ["baz"]
+            "#,
+        )
+        .file("src/main.rs", "")
+        .build();
+
+    p.cargo("build")
+        .masquerade_as_nightly_cargo()
+        .with_status(101)
+        .with_stderr(
+            "\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+  Feature `bar` includes `baz` which is not defined as a feature
+",
+        )
+        .run();
+}
+
+#[cargo_test]
+fn namespaced_invalid_dependency() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                bar = ["crate:baz"]
+            "#,
+        )
+        .file("src/main.rs", "")
+        .build();
+
+    p.cargo("build")
+        .masquerade_as_nightly_cargo()
+        .with_status(101)
+        .with_stderr(
+            "\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+  Feature `bar` includes `crate:baz` which is not a known dependency
+",
+        )
+        .run();
+}
+
+#[cargo_test]
+fn namespaced_non_optional_dependency() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                bar = ["crate:baz"]
+
+                [dependencies]
+                baz = "0.1"
+            "#,
+        )
+        .file("src/main.rs", "")
+        .build();
+
+    p.cargo("build")
+        .masquerade_as_nightly_cargo()
+        .with_status(101)
+        .with_stderr(
+            "\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+  Feature `bar` includes `crate:baz` which is not an optional dependency.
+  Consider adding `optional = true` to the dependency
+",
+        )
+        .run();
+}
+
+#[cargo_test]
+fn namespaced_implicit_feature() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                bar = ["baz"]
+
+                [dependencies]
+                baz = { version = "0.1", optional = true }
+            "#,
+        )
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    p.cargo("build").masquerade_as_nightly_cargo().run();
+}
+
+#[cargo_test]
+fn namespaced_shadowed_dep() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                baz = []
+
+                [dependencies]
+                baz = { version = "0.1", optional = true }
+            "#,
+        )
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr(
+        "\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+  Feature `baz` includes the optional dependency of the same name, but this is left implicit in the features included by this feature.
+  Consider adding `crate:baz` to this feature's requirements.
+",
+    )
+        .run();
+}
+
+#[cargo_test]
+fn namespaced_shadowed_non_optional() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                baz = []
+
+                [dependencies]
+                baz = "0.1"
+            "#,
+        )
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr(
+        "\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+  Feature `baz` includes the dependency of the same name, but this is left implicit in the features included by this feature.
+  Additionally, the dependency must be marked as optional to be included in the feature definition.
+  Consider adding `crate:baz` to this feature's requirements and marking the dependency as `optional = true`
+",
+    )
+        .run();
+}
+
+#[cargo_test]
+fn namespaced_implicit_non_optional() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                bar = ["baz"]
+
+                [dependencies]
+                baz = "0.1"
+            "#,
+        )
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr(
+        "\
+[ERROR] failed to parse manifest at `[..]`
+
+Caused by:
+  Feature `bar` includes `baz` which is not defined as a feature.
+  A non-optional dependency of the same name is defined; consider adding `optional = true` to its definition
+",
+    ).run();
+}
+
+#[cargo_test]
+fn namespaced_same_name() {
+    let p = project()
+        .file(
+            "Cargo.toml",
+            r#"
+                cargo-features = ["namespaced-features"]
+
+                [project]
+                name = "foo"
+                version = "0.0.1"
+                authors = []
+                namespaced-features = true
+
+                [features]
+                baz = ["crate:baz"]
+
+                [dependencies]
+                baz = { version = "0.1", optional = true }
+            "#,
+        )
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    p.cargo("build").masquerade_as_nightly_cargo().run();
+}
index 2b1767d41e965aa56c1e15c6016144686da33ebe..5c55e2cb4b4c13b790381640bdc4367b1f2cc66f 100644 (file)
@@ -45,6 +45,7 @@ mod edition;
 mod error;
 mod features;
 mod features2;
+mod features_namespaced;
 mod fetch;
 mod fix;
 mod freshness;