Skip to content

Commit 54cb667

Browse files
Nemo157syphar
authored andcommitted
Use local dependency for get-features test
1 parent 05ca269 commit 54cb667

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/db/add_package.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -697,35 +697,48 @@ mod test {
697697
#[test_case(
698698
r#"
699699
[features]
700-
foo = []
700+
bar = []
701701
"#,
702-
[Feature::new("foo".into(), vec![])]
702+
[Feature::new("bar".into(), vec![])]
703703
)]
704704
#[test_case(
705705
r#"
706706
[dependencies]
707-
base64 = { optional = true, version = "=0.13.1" }
707+
bar = { optional = true, path = "bar" }
708708
"#,
709-
[Feature::new("base64".into(), vec!["dep:base64".into()])]
709+
[Feature::new("bar".into(), vec!["dep:bar".into()])]
710710
)]
711711
#[test_case(
712712
r#"
713713
[dependencies]
714-
base64 = { optional = true, version = "=0.13.1" }
714+
bar = { optional = true, path = "bar" }
715715
[features]
716-
not-base64 = ["dep:base64"]
716+
not-bar = ["dep:bar"]
717717
"#,
718-
[Feature::new("not-base64".into(), vec!["dep:base64".into()])]
718+
[Feature::new("not-bar".into(), vec!["dep:bar".into()])]
719719
)]
720720
fn test_get_features(extra: &str, expected: impl AsRef<[Feature]>) -> Result<()> {
721721
let dir = tempfile::tempdir()?;
722722

723723
std::fs::create_dir(dir.path().join("src"))?;
724724
std::fs::write(dir.path().join("src/lib.rs"), "")?;
725725

726+
std::fs::create_dir(dir.path().join("bar"))?;
727+
std::fs::create_dir(dir.path().join("bar/src"))?;
728+
std::fs::write(dir.path().join("bar/src/lib.rs"), "")?;
729+
730+
std::fs::write(
731+
dir.path().join("bar/Cargo.toml"),
732+
r#"
733+
[package]
734+
name = "bar"
735+
version = "0.0.0"
736+
"#,
737+
)?;
738+
726739
let base = r#"
727740
[package]
728-
name = "test"
741+
name = "foo"
729742
version = "0.0.0"
730743
"#;
731744

src/utils/cargo_metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ impl CargoMetadata {
3434
.output()?;
3535
let status = res.status;
3636
if !status.success() {
37-
bail!("error returned by `cargo metadata`: {status}")
37+
let stderr = std::str::from_utf8(&res.stderr).unwrap_or("");
38+
bail!("error returned by `cargo metadata`: {status}\n{stderr}")
3839
}
3940
Self::load_from_metadata(std::str::from_utf8(&res.stdout)?)
4041
}

0 commit comments

Comments
 (0)