test(notgraph): fix cyclic integration test to use synthetic graph

This commit is contained in:
Joseph O'Brien
2026-04-02 02:36:01 -04:00
parent 377582269b
commit b1f3b36fc2

View File

@@ -19,26 +19,18 @@ fn clean_fixture_has_no_cycles() {
} }
#[test] #[test]
fn cyclic_fixture_detects_module_references() { fn detect_cycles_finds_cycles_in_synthetic_graph() {
// The "cyclic" fixture demonstrates a case where foo and bar mutually let nodes = vec!["a".to_string(), "b".to_string(), "c".to_string()];
// reference each other's names through mod declarations. While Rust's let edges = vec![
// module system itself is acyclic (hierarchical), this tests that ("a".to_string(), "b".to_string()),
// module_graph properly captures all module declarations. ("b".to_string(), "c".to_string()),
let mg = module_graph::build("cyclic".to_string(), &fixtures("cyclic")).unwrap(); ("c".to_string(), "a".to_string()), // creates a->b->c->a cycle
];
// Should find nodes for both foo and bar at top level let cycles = analysis::detect_cycles(&nodes, &edges);
assert!(mg.nodes.contains(&"cyclic::foo".to_string())); assert!(
assert!(mg.nodes.contains(&"cyclic::bar".to_string())); !cycles.is_empty(),
"expected detect_cycles to find the a->b->c->a cycle, got empty"
// Should find the nested modules they declare );
assert!(mg.nodes.contains(&"cyclic::foo::bar".to_string()));
assert!(mg.nodes.contains(&"cyclic::bar::foo".to_string()));
// Should have edges for all declarations
assert!(mg.edges.contains(&("cyclic".to_string(), "cyclic::foo".to_string())));
assert!(mg.edges.contains(&("cyclic".to_string(), "cyclic::bar".to_string())));
assert!(mg.edges.contains(&("cyclic::foo".to_string(), "cyclic::foo::bar".to_string())));
assert!(mg.edges.contains(&("cyclic::bar".to_string(), "cyclic::bar::foo".to_string())));
} }
#[test] #[test]