Skip to content

Commit

Permalink
Add support for new manifest_path dep field
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Gjengset committed Dec 18, 2020
1 parent cffb203 commit 6074232
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use semver::VersionReq;
use serde::{Deserialize, Deserializer, Serialize};
use std::path::PathBuf;

#[derive(Eq, PartialEq, Clone, Debug, Copy, Hash, Serialize, Deserialize)]
/// Dependencies can come in three kinds
Expand Down Expand Up @@ -65,6 +66,10 @@ pub struct Dependency {
///
/// If None, the dependency is from crates.io.
pub registry: Option<String>,
/// The file system path for a local path dependency.
///
/// Only produced on cargo 1.50+
pub path: Option<PathBuf>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
Expand Down
10 changes: 9 additions & 1 deletion tests/test_samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate semver;
extern crate serde_json;

use cargo_metadata::{CargoOpt, DependencyKind, Metadata, MetadataCommand};
use std::path::PathBuf;
use std::path::{Path, PathBuf};

#[test]
fn old_minimal() {
Expand Down Expand Up @@ -169,6 +169,7 @@ fn all_the_fields() {
// test added in 1.47
// homepage added in 1.49
// documentation added in 1.49
// path added in 1.50
eprintln!("Skipping all_the_fields test, cargo {} is too old.", ver);
return;
}
Expand Down Expand Up @@ -224,6 +225,13 @@ fn all_the_fields() {
assert_eq!(path_dep.source, None);
assert_eq!(path_dep.kind, DependencyKind::Normal);
assert_eq!(path_dep.req, semver::VersionReq::parse("*").unwrap());
assert_eq!(
path_dep
.path
.as_deref()
.map(|p| p.ends_with("path-dep/Cargo.toml")),
Some(true),
);

all.dependencies
.iter()
Expand Down

0 comments on commit 6074232

Please sign in to comment.