feat: Support passing workspace to --manifest-path (#1246)

Previously it will load the root `Cargo.toml` and treat it as the
manifest for the crate, now it will check its `package.name` and would
search for the workspace if the `package.name` does not match the crate
name.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-08-04 07:12:06 +10:00 committed by GitHub
parent b4cf580e4f
commit aeacebcf83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 30 deletions

View file

@ -1,12 +1,14 @@
use binstalk::ops::resolve::load_manifest_path;
use cargo_toml::Product;
use std::path::PathBuf;
#[test]
fn parse_meta() {
let mut manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
manifest_dir.push_str("/tests/parse-meta.Cargo.toml");
let mut manifest_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap());
manifest_dir.push("tests/parse-meta.Cargo.toml");
let manifest = load_manifest_path(&manifest_dir).expect("Error parsing metadata");
let manifest =
load_manifest_path(&manifest_dir, "cargo-binstall-test").expect("Error parsing metadata");
let package = manifest.package.unwrap();
let meta = package.metadata.and_then(|m| m.binstall).unwrap();