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
40
41
42
43
44
45
//! Shared helpers for CLI integration tests.
use ;
use Duration;
use Command;
/// Per-test unique pipe name counter.
static TEST_COUNTER: AtomicU32 = new;
/// Maximum time to wait for any single `flow` command to complete.
pub const COMMAND_TIMEOUT: Duration = from_secs;
/// Environment variable name for the pipe path (must match `ipc::message::PIPE_ENV`).
const PIPE_ENV: &str = "FLOW_PIPE_NAME";
/// Generate a unique pipe name for this test run.
///
/// Each call returns a different name like `\\.\pipe\flow-test-0`, `\\.\pipe\flow-test-1`, etc.
/// Tests that use separate pipe names can run in parallel without interference.
/// Build an [`assert_cmd::Command`] for the `flow` CLI binary pre-configured with the given
/// pipe name and a default command timeout.
///
/// Suitable for CLI commands that do **not** spawn a daemon (`stop`,
/// `reload-config`, etc.). For spawning the daemon in tests, use
/// [`crate::test_desktop::start_test_daemon`] which runs it on an isolated
/// desktop.
/// Ensure the daemon for the given pipe is stopped, ignoring errors if it was not running.
///
/// Call this at the start and end of each test to guarantee a clean slate
/// and avoid leaving a daemon process running after a test failure.