1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Tests for supervising-process detection from lock metadata.
//!
//! Purpose:
//! - Tests for supervising-process detection from lock metadata.
//!
//! Responsibilities:
//! - Ensure supervising labels are detected from lock owner metadata.
//!
//! Scope:
//! - Limited to this file's owning feature boundary.
//!
//! Not covered here:
//! - Lock acquisition semantics (see `lock_test.rs` and `task_lock_coexistence_test.rs`).
//! - CLI workflows that create or clear locks.
//!
//!
//! Usage:
//! - Used through the crate module tree or integration test harness.
//!
//! Invariants/assumptions:
//! - Lock owner file is a simple key/value text file.
//! - Labels are compared using the supervising label list (e.g., `run one`, `run loop`).
use anyhow::Result;
use cueloop::lock;
use tempfile::TempDir;
#[test]
fn supervising_process_detects_run_loop_label() -> Result<()> {
let temp_dir = TempDir::new()?;
let lock_dir = temp_dir.path().join("lock");
std::fs::create_dir_all(&lock_dir)?;
let owner_path = lock_dir.join("owner");
let owner = "pid: 123\nstarted_at: now\ncommand: cueloop run loop\nlabel: run loop\n";
std::fs::write(&owner_path, owner)?;
assert!(lock::is_supervising_process(&lock_dir)?);
Ok(())
}