/tests/testsuite/metadata.rs
https://gitlab.com/frewsxcv/cargo · Rust · 1533 lines · 1502 code · 30 blank · 1 comment · 0 complexity · 54dbe2b6f42c3077e82ffddb847d2570 MD5 · raw file
- //! Tests for the `cargo metadata` command.
- use cargo_test_support::install::cargo_home;
- use cargo_test_support::paths::CargoPathExt;
- use cargo_test_support::registry::Package;
- use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, main_file, project, rustc_host};
- use serde_json::json;
- #[cargo_test]
- fn cargo_metadata_simple() {
- let p = project()
- .file("src/foo.rs", "")
- .file("Cargo.toml", &basic_bin_manifest("foo"))
- .build();
- p.cargo("metadata")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [
- "wycats@example.com"
- ],
- "categories": [],
- "default_run": null,
- "name": "foo",
- "version": "0.5.0",
- "id": "foo[..]",
- "keywords": [],
- "source": null,
- "dependencies": [],
- "edition": "2015",
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "homepage": null,
- "documentation": null,
- "targets": [
- {
- "kind": [
- "bin"
- ],
- "crate_types": [
- "bin"
- ],
- "doc": true,
- "doctest": false,
- "test": true,
- "edition": "2015",
- "name": "foo",
- "src_path": "[..]/foo/src/foo.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
- "resolve": {
- "nodes": [
- {
- "dependencies": [],
- "deps": [],
- "features": [],
- "id": "foo 0.5.0 (path+file:[..]foo)"
- }
- ],
- "root": "foo 0.5.0 (path+file:[..]foo)"
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn cargo_metadata_warns_on_implicit_version() {
- let p = project()
- .file("src/foo.rs", "")
- .file("Cargo.toml", &basic_bin_manifest("foo"))
- .build();
- p.cargo("metadata").with_stderr("[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems").run();
- p.cargo("metadata --format-version 1").with_stderr("").run();
- }
- #[cargo_test]
- fn library_with_several_crate_types() {
- let p = project()
- .file("src/lib.rs", "")
- .file(
- "Cargo.toml",
- r#"
- [package]
- name = "foo"
- version = "0.5.0"
- [lib]
- crate-type = ["lib", "staticlib"]
- "#,
- )
- .build();
- p.cargo("metadata")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "name": "foo",
- "readme": null,
- "repository": null,
- "homepage": null,
- "documentation": null,
- "version": "0.5.0",
- "rust_version": null,
- "id": "foo[..]",
- "keywords": [],
- "source": null,
- "dependencies": [],
- "edition": "2015",
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "targets": [
- {
- "kind": [
- "lib",
- "staticlib"
- ],
- "crate_types": [
- "lib",
- "staticlib"
- ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "foo",
- "src_path": "[..]/foo/src/lib.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
- "resolve": {
- "nodes": [
- {
- "dependencies": [],
- "deps": [],
- "features": [],
- "id": "foo 0.5.0 (path+file:[..]foo)"
- }
- ],
- "root": "foo 0.5.0 (path+file:[..]foo)"
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn library_with_features() {
- let p = project()
- .file("src/lib.rs", "")
- .file(
- "Cargo.toml",
- r#"
- [package]
- name = "foo"
- version = "0.5.0"
- [features]
- default = ["default_feat"]
- default_feat = []
- optional_feat = []
- "#,
- )
- .build();
- p.cargo("metadata")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "name": "foo",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "version": "0.5.0",
- "id": "foo[..]",
- "keywords": [],
- "source": null,
- "dependencies": [],
- "edition": "2015",
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "targets": [
- {
- "kind": [
- "lib"
- ],
- "crate_types": [
- "lib"
- ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "foo",
- "src_path": "[..]/foo/src/lib.rs"
- }
- ],
- "features": {
- "default": [
- "default_feat"
- ],
- "default_feat": [],
- "optional_feat": []
- },
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
- "resolve": {
- "nodes": [
- {
- "dependencies": [],
- "deps": [],
- "features": [
- "default",
- "default_feat"
- ],
- "id": "foo 0.5.0 (path+file:[..]foo)"
- }
- ],
- "root": "foo 0.5.0 (path+file:[..]foo)"
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn cargo_metadata_with_deps_and_version() {
- let p = project()
- .file("src/foo.rs", "")
- .file(
- "Cargo.toml",
- r#"
- [project]
- name = "foo"
- version = "0.5.0"
- authors = []
- license = "MIT"
- description = "foo"
- [[bin]]
- name = "foo"
- [dependencies]
- bar = "*"
- [dev-dependencies]
- foobar = "*"
- "#,
- )
- .build();
- Package::new("baz", "0.0.1").publish();
- Package::new("foobar", "0.0.1").publish();
- Package::new("bar", "0.0.1").dep("baz", "0.0.1").publish();
- p.cargo("metadata -q --format-version 1")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [
- {
- "features": [],
- "kind": null,
- "name": "baz",
- "optional": false,
- "registry": null,
- "rename": null,
- "req": "^0.0.1",
- "source": "registry+https://github.com/rust-lang/crates.io-index",
- "target": null,
- "uses_default_features": true
- }
- ],
- "description": null,
- "edition": "2015",
- "features": {},
- "id": "bar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null,
- "name": "bar",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "source": "registry+https://github.com/rust-lang/crates.io-index",
- "targets": [
- {
- "crate_types": [
- "lib"
- ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "kind": [
- "lib"
- ],
- "name": "bar",
- "src_path": "[..]src/lib.rs"
- }
- ],
- "version": "0.0.1"
- },
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [],
- "description": null,
- "edition": "2015",
- "features": {},
- "id": "baz 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null,
- "name": "baz",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "source": "registry+https://github.com/rust-lang/crates.io-index",
- "targets": [
- {
- "crate_types": [
- "lib"
- ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "kind": [
- "lib"
- ],
- "name": "baz",
- "src_path": "[..]src/lib.rs"
- }
- ],
- "version": "0.0.1"
- },
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [
- {
- "features": [],
- "kind": null,
- "name": "bar",
- "optional": false,
- "registry": null,
- "rename": null,
- "req": "*",
- "source": "registry+https://github.com/rust-lang/crates.io-index",
- "target": null,
- "uses_default_features": true
- },
- {
- "features": [],
- "kind": "dev",
- "name": "foobar",
- "optional": false,
- "registry": null,
- "rename": null,
- "req": "*",
- "source": "registry+https://github.com/rust-lang/crates.io-index",
- "target": null,
- "uses_default_features": true
- }
- ],
- "description": "foo",
- "edition": "2015",
- "features": {},
- "id": "foo 0.5.0 (path+file:[..]foo)",
- "keywords": [],
- "license": "MIT",
- "license_file": null,
- "links": null,
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null,
- "name": "foo",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "source": null,
- "targets": [
- {
- "crate_types": [
- "bin"
- ],
- "doc": true,
- "doctest": false,
- "test": true,
- "edition": "2015",
- "kind": [
- "bin"
- ],
- "name": "foo",
- "src_path": "[..]src/foo.rs"
- }
- ],
- "version": "0.5.0"
- },
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [],
- "description": null,
- "edition": "2015",
- "features": {},
- "id": "foobar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null,
- "name": "foobar",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "source": "registry+https://github.com/rust-lang/crates.io-index",
- "targets": [
- {
- "crate_types": [
- "lib"
- ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "kind": [
- "lib"
- ],
- "name": "foobar",
- "src_path": "[..]src/lib.rs"
- }
- ],
- "version": "0.0.1"
- }
- ],
- "resolve": {
- "nodes": [
- {
- "dependencies": [
- "baz 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- ],
- "deps": [
- {
- "dep_kinds": [
- {
- "kind": null,
- "target": null
- }
- ],
- "name": "baz",
- "pkg": "baz 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- }
- ],
- "features": [],
- "id": "bar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- },
- {
- "dependencies": [],
- "deps": [],
- "features": [],
- "id": "baz 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- },
- {
- "dependencies": [
- "bar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "foobar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- ],
- "deps": [
- {
- "dep_kinds": [
- {
- "kind": null,
- "target": null
- }
- ],
- "name": "bar",
- "pkg": "bar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- },
- {
- "dep_kinds": [
- {
- "kind": "dev",
- "target": null
- }
- ],
- "name": "foobar",
- "pkg": "foobar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- }
- ],
- "features": [],
- "id": "foo 0.5.0 (path+file:[..]foo)"
- },
- {
- "dependencies": [],
- "deps": [],
- "features": [],
- "id": "foobar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)"
- }
- ],
- "root": "foo 0.5.0 (path+file:[..]foo)"
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_members": [
- "foo 0.5.0 (path+file:[..]foo)"
- ],
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn example() {
- let p = project()
- .file("src/lib.rs", "")
- .file("examples/ex.rs", "")
- .file(
- "Cargo.toml",
- r#"
- [package]
- name = "foo"
- version = "0.1.0"
- [[example]]
- name = "ex"
- "#,
- )
- .build();
- p.cargo("metadata")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "name": "foo",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "version": "0.1.0",
- "id": "foo[..]",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "edition": "2015",
- "source": null,
- "dependencies": [],
- "targets": [
- {
- "kind": [ "lib" ],
- "crate_types": [ "lib" ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "foo",
- "src_path": "[..]/foo/src/lib.rs"
- },
- {
- "kind": [ "example" ],
- "crate_types": [ "bin" ],
- "doc": false,
- "doctest": false,
- "test": false,
- "edition": "2015",
- "name": "ex",
- "src_path": "[..]/foo/examples/ex.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": [
- "foo 0.1.0 (path+file:[..]foo)"
- ],
- "resolve": {
- "root": "foo 0.1.0 (path+file://[..]foo)",
- "nodes": [
- {
- "id": "foo 0.1.0 (path+file:[..]foo)",
- "features": [],
- "dependencies": [],
- "deps": []
- }
- ]
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn example_lib() {
- let p = project()
- .file("src/lib.rs", "")
- .file("examples/ex.rs", "")
- .file(
- "Cargo.toml",
- r#"
- [package]
- name = "foo"
- version = "0.1.0"
- [[example]]
- name = "ex"
- crate-type = ["rlib", "dylib"]
- "#,
- )
- .build();
- p.cargo("metadata")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "name": "foo",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "version": "0.1.0",
- "id": "foo[..]",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "edition": "2015",
- "source": null,
- "dependencies": [],
- "targets": [
- {
- "kind": [ "lib" ],
- "crate_types": [ "lib" ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "foo",
- "src_path": "[..]/foo/src/lib.rs"
- },
- {
- "kind": [ "example" ],
- "crate_types": [ "rlib", "dylib" ],
- "doc": false,
- "doctest": false,
- "test": false,
- "edition": "2015",
- "name": "ex",
- "src_path": "[..]/foo/examples/ex.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": [
- "foo 0.1.0 (path+file:[..]foo)"
- ],
- "resolve": {
- "root": "foo 0.1.0 (path+file://[..]foo)",
- "nodes": [
- {
- "id": "foo 0.1.0 (path+file:[..]foo)",
- "features": [],
- "dependencies": [],
- "deps": []
- }
- ]
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn workspace_metadata() {
- let p = project()
- .file(
- "Cargo.toml",
- r#"
- [workspace]
- members = ["bar", "baz"]
- [workspace.metadata]
- tool1 = "hello"
- tool2 = [1, 2, 3]
- [workspace.metadata.foo]
- bar = 3
- "#,
- )
- .file("bar/Cargo.toml", &basic_lib_manifest("bar"))
- .file("bar/src/lib.rs", "")
- .file("baz/Cargo.toml", &basic_lib_manifest("baz"))
- .file("baz/src/lib.rs", "")
- .build();
- p.cargo("metadata")
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [
- "wycats@example.com"
- ],
- "categories": [],
- "default_run": null,
- "name": "bar",
- "version": "0.5.0",
- "id": "bar[..]",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "keywords": [],
- "source": null,
- "dependencies": [],
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "edition": "2015",
- "targets": [
- {
- "kind": [ "lib" ],
- "crate_types": [ "lib" ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "bar",
- "src_path": "[..]bar/src/lib.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]bar/Cargo.toml",
- "metadata": null,
- "publish": null
- },
- {
- "authors": [
- "wycats@example.com"
- ],
- "categories": [],
- "default_run": null,
- "name": "baz",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "version": "0.5.0",
- "id": "baz[..]",
- "keywords": [],
- "source": null,
- "dependencies": [],
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "edition": "2015",
- "targets": [
- {
- "kind": [ "lib" ],
- "crate_types": [ "lib" ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "baz",
- "src_path": "[..]baz/src/lib.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]baz/Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": ["bar 0.5.0 (path+file:[..]bar)", "baz 0.5.0 (path+file:[..]baz)"],
- "resolve": {
- "nodes": [
- {
- "dependencies": [],
- "deps": [],
- "features": [],
- "id": "bar 0.5.0 (path+file:[..]bar)"
- },
- {
- "dependencies": [],
- "deps": [],
- "features": [],
- "id": "baz 0.5.0 (path+file:[..]baz)"
- }
- ],
- "root": null
- },
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": {
- "tool1": "hello",
- "tool2": [1, 2, 3],
- "foo": {
- "bar": 3
- }
- }
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn workspace_metadata_with_dependencies_no_deps() {
- let p = project()
- // NOTE that 'artifact' isn't mentioned in the workspace here, yet it shows up as member.
- .file(
- "Cargo.toml",
- r#"
- [workspace]
- members = ["bar", "baz"]
- "#,
- )
- .file(
- "bar/Cargo.toml",
- r#"
- [package]
- name = "bar"
- version = "0.5.0"
- authors = ["wycats@example.com"]
-
- [dependencies]
- baz = { path = "../baz/" }
- artifact = { path = "../artifact/", artifact = "bin" }
- "#,
- )
- .file("bar/src/lib.rs", "")
- .file("baz/Cargo.toml", &basic_lib_manifest("baz"))
- .file("baz/src/lib.rs", "")
- .file("artifact/Cargo.toml", &basic_bin_manifest("artifact"))
- .file("artifact/src/main.rs", "fn main() {}")
- .build();
- p.cargo("metadata --no-deps -Z bindeps")
- .masquerade_as_nightly_cargo()
- .with_json(
- r#"
- {
- "packages": [
- {
- "authors": [
- "wycats@example.com"
- ],
- "categories": [],
- "default_run": null,
- "name": "bar",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "version": "0.5.0",
- "id": "bar[..]",
- "keywords": [],
- "source": null,
- "license": null,
- "dependencies": [
- {
- "features": [],
- "kind": null,
- "name": "artifact",
- "optional": false,
- "path": "[..]/foo/artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true,
- "artifact": {
- "kinds": [
- "bin"
- ],
- "lib": false,
- "target": null
- }
- },
- {
- "features": [],
- "kind": null,
- "name": "baz",
- "optional": false,
- "path": "[..]/foo/baz",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- }
- ],
- "license_file": null,
- "links": null,
- "description": null,
- "edition": "2015",
- "targets": [
- {
- "kind": [ "lib" ],
- "crate_types": [ "lib" ],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "bar",
- "src_path": "[..]bar/src/lib.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]bar/Cargo.toml",
- "metadata": null,
- "publish": null
- },
- {
- "authors": [
- "wycats@example.com"
- ],
- "categories": [],
- "default_run": null,
- "dependencies": [],
- "description": null,
- "documentation": null,
- "edition": "2015",
- "features": {},
- "homepage": null,
- "id": "artifact 0.5.0 (path+file:[..]/foo/artifact)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]/foo/artifact/Cargo.toml",
- "metadata": null,
- "name": "artifact",
- "publish": null,
- "readme": null,
- "repository": null,
- "rust_version": null,
- "source": null,
- "targets": [
- {
- "crate_types": [
- "bin"
- ],
- "doc": true,
- "doctest": false,
- "edition": "2015",
- "kind": [
- "bin"
- ],
- "name": "artifact",
- "src_path": "[..]/foo/artifact/src/main.rs",
- "test": true
- }
- ],
- "version": "0.5.0"
- },
- {
- "authors": [
- "wycats@example.com"
- ],
- "categories": [],
- "default_run": null,
- "name": "baz",
- "readme": null,
- "repository": null,
- "rust_version": null,
- "homepage": null,
- "documentation": null,
- "version": "0.5.0",
- "id": "baz[..]",
- "keywords": [],
- "source": null,
- "dependencies": [],
- "license": null,
- "license_file": null,
- "links": null,
- "description": null,
- "edition": "2015",
- "targets": [
- {
- "kind": [ "lib" ],
- "crate_types": ["lib"],
- "doc": true,
- "doctest": true,
- "test": true,
- "edition": "2015",
- "name": "baz",
- "src_path": "[..]baz/src/lib.rs"
- }
- ],
- "features": {},
- "manifest_path": "[..]baz/Cargo.toml",
- "metadata": null,
- "publish": null
- }
- ],
- "workspace_members": [
- "bar 0.5.0 (path+file:[..]bar)",
- "artifact 0.5.0 (path+file:[..]/foo/artifact)",
- "baz 0.5.0 (path+file:[..]baz)"
- ],
- "resolve": null,
- "target_directory": "[..]foo/target",
- "version": 1,
- "workspace_root": "[..]/foo",
- "metadata": null
- }"#,
- )
- .run();
- }
- #[cargo_test]
- fn workspace_metadata_with_dependencies_and_resolve() {
- let alt_target = "wasm32-unknown-unknown";
- let p = project()
- .file(
- "Cargo.toml",
- r#"
- [workspace]
- members = ["bar", "artifact", "non-artifact", "bin-only-artifact"]
- "#,
- )
- .file(
- "bar/Cargo.toml",
- &r#"
- [package]
- name = "bar"
- version = "0.5.0"
- authors = []
-
- [build-dependencies]
- artifact = { path = "../artifact/", artifact = "bin", target = "target" }
- bin-only-artifact = { path = "../bin-only-artifact/", artifact = "bin", target = "$ALT_TARGET" }
- non-artifact = { path = "../non-artifact" }
-
- [dependencies]
- artifact = { path = "../artifact/", artifact = ["cdylib", "staticlib", "bin:baz-name"], lib = true, target = "$ALT_TARGET" }
- bin-only-artifact = { path = "../bin-only-artifact/", artifact = "bin:a-name" }
- non-artifact = { path = "../non-artifact" }
-
- [dev-dependencies]
- artifact = { path = "../artifact/" }
- non-artifact = { path = "../non-artifact" }
- bin-only-artifact = { path = "../bin-only-artifact/", artifact = "bin:b-name" }
- "#.replace("$ALT_TARGET", alt_target),
- )
- .file("bar/src/lib.rs", "")
- .file("bar/build.rs", "fn main() {}")
- .file(
- "artifact/Cargo.toml",
- r#"
- [package]
- name = "artifact"
- version = "0.5.0"
- authors = []
-
- [lib]
- crate-type = ["staticlib", "cdylib", "rlib"]
-
- [[bin]]
- name = "bar-name"
-
- [[bin]]
- name = "baz-name"
- "#,
- )
- .file("artifact/src/main.rs", "fn main() {}")
- .file("artifact/src/lib.rs", "")
- .file(
- "bin-only-artifact/Cargo.toml",
- r#"
- [package]
- name = "bin-only-artifact"
- version = "0.5.0"
- authors = []
-
- [[bin]]
- name = "a-name"
-
- [[bin]]
- name = "b-name"
- "#,
- )
- .file("bin-only-artifact/src/main.rs", "fn main() {}")
- .file("non-artifact/Cargo.toml",
- r#"
- [package]
- name = "non-artifact"
- version = "0.5.0"
- authors = []
- "#,
- )
- .file("non-artifact/src/lib.rs", "")
- .build();
- p.cargo("metadata -Z bindeps")
- .masquerade_as_nightly_cargo()
- .with_json(
- r#"
- {
- "metadata": null,
- "packages": [
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [],
- "description": null,
- "documentation": null,
- "edition": "2015",
- "features": {},
- "homepage": null,
- "id": "artifact 0.5.0 (path+file://[..]/foo/artifact)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]/foo/artifact/Cargo.toml",
- "metadata": null,
- "name": "artifact",
- "publish": null,
- "readme": null,
- "repository": null,
- "rust_version": null,
- "source": null,
- "targets": [
- {
- "crate_types": [
- "staticlib",
- "cdylib",
- "rlib"
- ],
- "doc": true,
- "doctest": true,
- "edition": "2015",
- "kind": [
- "staticlib",
- "cdylib",
- "rlib"
- ],
- "name": "artifact",
- "src_path": "[..]/foo/artifact/src/lib.rs",
- "test": true
- },
- {
- "crate_types": [
- "bin"
- ],
- "doc": true,
- "doctest": false,
- "edition": "2015",
- "kind": [
- "bin"
- ],
- "name": "bar-name",
- "src_path": "[..]/foo/artifact/src/main.rs",
- "test": true
- },
- {
- "crate_types": [
- "bin"
- ],
- "doc": true,
- "doctest": false,
- "edition": "2015",
- "kind": [
- "bin"
- ],
- "name": "baz-name",
- "src_path": "[..]/foo/artifact/src/main.rs",
- "test": true
- }
- ],
- "version": "0.5.0"
- },
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [
- {
- "artifact": {
- "kinds": [
- "cdylib",
- "staticlib",
- "bin:baz-name"
- ],
- "lib": true,
- "target": "wasm32-unknown-unknown"
- },
- "features": [],
- "kind": null,
- "name": "artifact",
- "optional": false,
- "path": "[..]/foo/artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "artifact": {
- "kinds": [
- "bin:a-name"
- ],
- "lib": false,
- "target": null
- },
- "features": [],
- "kind": null,
- "name": "bin-only-artifact",
- "optional": false,
- "path": "[..]/foo/bin-only-artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "features": [],
- "kind": null,
- "name": "non-artifact",
- "optional": false,
- "path": "[..]/foo/non-artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "features": [],
- "kind": "dev",
- "name": "artifact",
- "optional": false,
- "path": "[..]/foo/artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "artifact": {
- "kinds": [
- "bin:b-name"
- ],
- "lib": false,
- "target": null
- },
- "features": [],
- "kind": "dev",
- "name": "bin-only-artifact",
- "optional": false,
- "path": "[..]/foo/bin-only-artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "features": [],
- "kind": "dev",
- "name": "non-artifact",
- "optional": false,
- "path": "[..]/foo/non-artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "artifact": {
- "kinds": [
- "bin"
- ],
- "lib": false,
- "target": "target"
- },
- "features": [],
- "kind": "build",
- "name": "artifact",
- "optional": false,
- "path": "[..]/foo/artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "artifact": {
- "kinds": [
- "bin"
- ],
- "lib": false,
- "target": "wasm32-unknown-unknown"
- },
- "features": [],
- "kind": "build",
- "name": "bin-only-artifact",
- "optional": false,
- "path": "[..]/foo/bin-only-artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- },
- {
- "features": [],
- "kind": "build",
- "name": "non-artifact",
- "optional": false,
- "path": "[..]/foo/non-artifact",
- "registry": null,
- "rename": null,
- "req": "*",
- "source": null,
- "target": null,
- "uses_default_features": true
- }
- ],
- "description": null,
- "documentation": null,
- "edition": "2015",
- "features": {},
- "homepage": null,
- "id": "bar 0.5.0 (path+file://[..]/foo/bar)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]/foo/bar/Cargo.toml",
- "metadata": null,
- "name": "bar",
- "publish": null,
- "readme": null,
- "repository": null,
- "rust_version": null,
- "source": null,
- "targets": [
- {
- "crate_types": [
- "lib"
- ],
- "doc": true,
- "doctest": true,
- "edition": "2015",
- "kind": [
- "lib"
- ],
- "name": "bar",
- "src_path": "[..]/foo/bar/src/lib.rs",
- "test": true
- },
- {
- "crate_types": [
- "bin"
- ],
- "doc": false,
- "doctest": false,
- "edition": "2015",
- "kind": [
- "custom-build"
- ],
- "name": "build-script-build",
- "src_path": "[..]/foo/bar/build.rs",
- "test": false
- }
- ],
- "version": "0.5.0"
- },
- {
- "authors": [],
- "categories": [],
- "default_run": null,
- "dependencies": [],
- "description": null,
- "documentation": null,
- "edition": "2015",
- "features": {},
- "homepage": null,
- "id": "bin-only-artifact 0.5.0 (path+file://[..]/foo/bin-only-artifact)",
- "keywords": [],
- "license": null,
- "license_file": null,
- "links": null,
- "manifest_path": "[..]/foo/bin-only-artifact/Cargo.toml",
- "metadata": null,
- "name": "bin-only-artifact",
- "publish": null,
- "readme": null,
- "repository": null,