MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_has_deadlock

Function test_has_deadlock

core/src/planning/mod.rs:589–608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

587
588 #[test]
589 fn test_has_deadlock() {
590 // Circular dependency: s1 depends on s2, s2 depends on s1
591 let mut plan = ExecutionPlan::new("Test", Complexity::Simple);
592 plan.add_step(Task::new("s1", "Step 1").with_dependencies(vec!["s2".to_string()]));
593 plan.add_step(Task::new("s2", "Step 2").with_dependencies(vec!["s1".to_string()]));
594
595 assert!(plan.has_deadlock());
596
597 // No deadlock when steps have no deps
598 let mut plan2 = ExecutionPlan::new("Test", Complexity::Simple);
599 plan2.add_step(Task::new("s1", "Step 1"));
600 assert!(!plan2.has_deadlock());
601
602 // Deadlock when dependency failed
603 let mut plan3 = ExecutionPlan::new("Test", Complexity::Simple);
604 plan3.add_step(Task::new("s1", "Step 1"));
605 plan3.add_step(Task::new("s2", "Step 2").with_dependencies(vec!["s1".to_string()]));
606 plan3.mark_status("s1", TaskStatus::Failed);
607 assert!(plan3.has_deadlock()); // s2 depends on s1 which failed, not completed
608 }
609
610 #[test]
611 fn test_get_ready_steps_parallel() {

Callers

nothing calls this directly

Calls 3

add_stepMethod · 0.80
with_dependenciesMethod · 0.80
mark_statusMethod · 0.80

Tested by

no test coverage detected