MCPcopy Create free account
hub / github.com/Qovery/engine / test_command_with_abort

Function test_command_with_abort

lib-engine/src/cmd/command.rs:472–493  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

470
471 #[test]
472 fn test_command_with_abort() {
473 let mut cmd = QoveryCommand::new("sleep", &["120"], &[]);
474 let should_kill = Arc::new(AtomicAbortStatus::new(AbortStatus::None));
475 let should_kill2 = should_kill.clone();
476 let barrier = Arc::new(Barrier::new(2));
477
478 let _ = thread::spawn({
479 let barrier = barrier.clone();
480 move || {
481 barrier.wait();
482 thread::sleep(Duration::from_secs(2));
483 should_kill.store(AbortStatus::Requested, Ordering::Release);
484 }
485 });
486
487 let cmd_killer = move || should_kill2.load(Ordering::Acquire);
488 let cmd_killer = CommandKiller::from_cancelable(&cmd_killer);
489 barrier.wait();
490 let ret = cmd.exec_with_abort(&mut |_| {}, &mut |_| {}, &cmd_killer);
491
492 assert!(matches!(ret, Err(CommandError::Killed(_))));
493 }
494}

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.45
exec_with_abortMethod · 0.45

Tested by

no test coverage detected