use semver::Version;
use serde::ser;
+use toml;
use url::Url;
use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
exclude: Vec<String>,
include: Vec<String>,
metadata: ManifestMetadata,
+ custom_metadata: Option<toml::Value>,
profiles: Profiles,
publish: Option<Vec<String>>,
publish_lockfile: bool,
include: Vec<String>,
links: Option<String>,
metadata: ManifestMetadata,
+ custom_metadata: Option<toml::Value>,
profiles: Profiles,
publish: Option<Vec<String>>,
publish_lockfile: bool,
include,
links,
metadata,
+ custom_metadata,
profiles,
publish,
replace,
pub fn edition(&self) -> Edition {
self.edition
}
+
+ pub fn custom_metadata(&self) -> Option<&toml::Value> {
+ self.custom_metadata.as_ref()
+ }
}
impl VirtualManifest {
-use hamcrest::assert_that;
use cargotest::support::registry::Package;
use cargotest::support::{basic_bin_manifest, basic_lib_manifest, execs, main_file, project};
+use hamcrest::assert_that;
#[test]
fn cargo_metadata_simple() {
}
],
"features": {},
- "manifest_path": "[..]Cargo.toml"
+ "manifest_path": "[..]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
}
],
"features": {},
- "manifest_path": "[..]Cargo.toml"
+ "manifest_path": "[..]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
"default_feat": [],
"optional_feat": []
},
- "manifest_path": "[..]Cargo.toml"
+ "manifest_path": "[..]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
"src_path": "[..]lib.rs"
}
],
- "version": "0.0.1"
+ "version": "0.0.1",
+ "metadata": null
},
{
"dependencies": [
"src_path": "[..]lib.rs"
}
],
- "version": "0.0.1"
+ "version": "0.0.1",
+ "metadata": null
},
{
"dependencies": [
"src_path": "[..]foo.rs"
}
],
- "version": "0.5.0"
+ "version": "0.5.0",
+ "metadata": null
}
],
"workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
}
],
"features": {},
- "manifest_path": "[..]Cargo.toml"
+ "manifest_path": "[..]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": [
}
],
"features": {},
- "manifest_path": "[..]Cargo.toml"
+ "manifest_path": "[..]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": [
}
],
"features": {},
- "manifest_path": "[..]bar[/]Cargo.toml"
+ "manifest_path": "[..]bar[/]Cargo.toml",
+ "metadata": null
},
{
"name": "baz",
}
],
"features": {},
- "manifest_path": "[..]baz[/]Cargo.toml"
+ "manifest_path": "[..]baz[/]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
}
],
"features": {},
- "manifest_path": "[..]bar[/]Cargo.toml"
+ "manifest_path": "[..]bar[/]Cargo.toml",
+ "metadata": null
},
{
"name": "baz",
}
],
"features": {},
- "manifest_path": "[..]baz[/]Cargo.toml"
+ "manifest_path": "[..]baz[/]Cargo.toml",
+ "metadata": null
}
],
"workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
)
}
-const MANIFEST_OUTPUT: &'static str = r#"
+const MANIFEST_OUTPUT: &str = r#"
{
"packages": [{
"name":"foo",
"src_path":"[..][/]foo[/]src[/]foo.rs"
}],
"features":{},
- "manifest_path":"[..]Cargo.toml"
+ "manifest_path":"[..]Cargo.toml",
+ "metadata": null
}],
"workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ],
"resolve": null,
execs().with_status(0),
);
}
+
+#[test]
+fn package_metadata() {
+ let p = project("foo")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [package.metadata.bar]
+ baz = "quux"
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ assert_that(
+ p.cargo("metadata").arg("--no-deps"),
+ execs().with_json(
+ r#"
+ {
+ "packages": [
+ {
+ "name": "foo",
+ "version": "0.1.0",
+ "id": "foo[..]",
+ "source": null,
+ "dependencies": [],
+ "license": null,
+ "license_file": null,
+ "description": null,
+ "targets": [
+ {
+ "kind": [ "lib" ],
+ "crate_types": [ "lib" ],
+ "name": "foo",
+ "src_path": "[..]foo[/]src[/]lib.rs"
+ }
+ ],
+ "features": {},
+ "manifest_path": "[..]foo[/]Cargo.toml",
+ "metadata": {
+ "bar": {
+ "baz": "quux"
+ }
+ }
+ }
+ ],
+ "workspace_members": ["foo[..]"],
+ "resolve": null,
+ "target_directory": "[..]foo[/]target",
+ "version": 1,
+ "workspace_root": "[..][/]foo"
+ }"#,
+ ),
+ );
+}