Skip to content

Commit 6100f2b

Browse files
committed
reinstate commented-out test as an end-to-end test
1 parent eb028c9 commit 6100f2b

2 files changed

Lines changed: 15 additions & 28 deletions

File tree

cargo-auditable/src/auditable_from_metadata.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -237,31 +237,3 @@ fn strongest_dep_kind(deps: &[cargo_metadata::DepKindInfo]) -> PrivateDepKind {
237237
.max()
238238
.unwrap_or(PrivateDepKind::Runtime) // for compatibility with Rust earlier than 1.41
239239
}
240-
241-
#[cfg(test)]
242-
mod tests {
243-
#![allow(unused_imports)] // otherwise conditional compilation emits warnings
244-
use super::*;
245-
use std::fs;
246-
use std::{
247-
convert::TryInto,
248-
path::{Path, PathBuf},
249-
str::FromStr,
250-
};
251-
252-
fn load_metadata(cargo_toml_path: &Path) -> cargo_metadata::Metadata {
253-
let mut cmd = cargo_metadata::MetadataCommand::new();
254-
cmd.manifest_path(cargo_toml_path);
255-
cmd.exec().unwrap()
256-
}
257-
258-
// #[test]
259-
// fn dependency_cycle() {
260-
// let cargo_toml_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
261-
// .join("tests/fixtures/cargo-audit-dep-cycle/Cargo.toml");
262-
// let metadata = load_metadata(&cargo_toml_path);
263-
// let version_info_struct: VersionInfo = encode_audit_data(&metadata).unwrap();
264-
// let json = serde_json::to_string(&version_info_struct).unwrap();
265-
// VersionInfo::from_str(&json).unwrap(); // <- the part we care about succeeding
266-
// }
267-
}

cargo-auditable/tests/it.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,18 @@ fn test_dependency_unification() {
484484
.iter()
485485
.any(|p| p.name == "optional_transitive_dep"));
486486
}
487+
488+
#[test]
489+
fn test_dep_cycle() {
490+
// Path to workspace fixture Cargo.toml. See that file for overview of workspace members and their dependencies.
491+
let workspace_cargo_toml = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
492+
.join("tests/fixtures/cargo-audit-dep-cycle/Cargo.toml");
493+
// Run in workspace root with default features
494+
let bins = run_cargo_auditable(workspace_cargo_toml, &[], &[]);
495+
eprintln!("Test fixture binary map: {bins:?}");
496+
497+
let toplevel_crate_bin = &bins.get("cargo-audit-dep-cycle").unwrap()[0];
498+
// Deserialization checks for cycles, so we only need to verify that it succeeds
499+
let dep_info = get_dependency_info(toplevel_crate_bin);
500+
eprintln!("{toplevel_crate_bin} dependency info: {dep_info:?}");
501+
}

0 commit comments

Comments
 (0)