config: &'cfg Config,
// This path is a path to where the current cargo subcommand was invoked
- // from. That is, this is the `--manifest-path` argument to Cargo, and
+ // from. That is the `--manifest-path` argument to Cargo, and
// points to the "main crate" that we're going to worry about.
current_manifest: PathBuf,
}
for path in paths::ancestors(manifest_path).skip(2) {
+ if path.ends_with("target/package") {
+ break;
+ }
+
let ances_manifest_path = path.join("Cargo.toml");
debug!("find_root - trying {}", ances_manifest_path.display());
if ances_manifest_path.exists() {
),
);
}
+
+#[test]
+fn cargo_metadata_path_to_cargo_toml_project() {
+ let p = project("foo")
+ .file(
+ "Cargo.toml",
+ r#"
+ [workspace]
+ members = ["bar"]
+ "#,
+ )
+ .file("bar/Cargo.toml", &basic_lib_manifest("bar"))
+ .file("bar/src/lib.rs", "")
+ .build();
+
+ assert_that(
+ p.cargo("package")
+ .arg("--manifest-path")
+ .arg(p.root().join("bar/Cargo.toml"))
+ .cwd(p.root().parent().unwrap()),
+ execs().with_status(0)
+ );
+
+ assert_that(
+ p.cargo("metadata")
+ .arg("--manifest-path")
+ .arg(p.root().join("target/package/bar-0.5.0/Cargo.toml")),
+ execs().with_status(0).with_json(
+ r#"
+ {
+ "packages": [
+ {
+ "authors": [
+ "wycats@example.com"
+ ],
+ "categories": [],
+ "dependencies": [],
+ "description": null,
+ "features": {},
+ "id": "bar 0.5.0 ([..])",
+ "keywords": [],
+ "license": null,
+ "license_file": null,
+ "manifest_path": "[..]Cargo.toml",
+ "metadata": null,
+ "name": "bar",
+ "readme": null,
+ "repository": null,
+ "source": null,
+ "targets": [
+ {
+ "crate_types": [
+ "lib"
+ ],
+ "kind": [
+ "lib"
+ ],
+ "name": "bar",
+ "src_path": "[..]src[/]lib.rs"
+ }
+ ],
+ "version": "0.5.0"
+ }
+ ],
+ "resolve": {
+ "nodes": [
+ {
+ "dependencies": [],
+ "features": [],
+ "id": "bar 0.5.0 ([..])"
+ }
+ ],
+ "root": "bar 0.5.0 (path+file:[..])"
+ },
+ "target_directory": "[..]",
+ "version": 1,
+ "workspace_members": [
+ "bar 0.5.0 (path+file:[..])"
+ ],
+ "workspace_root": "[..]"
+ }
+"#
+),
+ );
+}
+
+