test(tty): end-to-end integration tests for LocalTtyBackend + drive_session
Add 18 integration tests in crates/alknet-tty-local/tests/ exercising the full stack (LocalTtyBackend + TtyAdapter::drive_session over tokio::io::duplex, real commands), validating the two crates work together through the TtyBackend trait seam. Tests live in alknet-tty-local (not alknet-tty) per the feature-gate deviation: the cyclic dependency alknet-tty → alknet-tty-local → alknet-tty prevents alknet-tty from depending on alknet-tty-local, so the integration tests live in the crate that depends on both. Unix-only tests (signal, process-group) use #[cfg(unix)]. PTY mode (8): happy path echo, interactive cat round-trip, resize, SIGINT signal, process-group signal (REQ-TTY-02), stdin EOF sentinel, cancel cleanup (ADR-056), exit-chunk-is-last (ADR-055). Pipe mode (6): happy path echo, separate stderr, SIGTERM signal, cancel cleanup, resize no-op, stdout chunk + sentinel. Negotiation errors (5): unknown_backend, malformed_negotiation (bad JSON, carriage != raw, empty cmd), allocate_failed (nonexistent binary). A shared test harness (tests/common/mod.rs) provides the client-side wire protocol helpers: write_negotiation, write_chunk, write_control, try_read_chunk, read_chunk_timeout, read_error_frame (asserts the 0x00 first-byte framing-disambiguation invariant), read_until_exit, assert_no_more_chunks, close_write_half, plus spawn_session which wires drive_session over a duplex pair with a test identity carrying tty:open. Verification: cargo test -p alknet-tty-local (42 tests pass), cargo clippy -p alknet-tty-local -- -D warnings (clean), cargo fmt --check -p alknet-tty-local (clean).
This commit is contained in:
1 parent
558800c2dd
commit
45506ed77b
6 files changed
+898
-1
No files matched your search
@@ -25,7 +25,10 @@ thiserror = "2"
|
||||
libc = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
alknet-core = { path = "../alknet-core" }
|
||||
alknet-tty = { path = "../alknet-tty" }
|
||||
tokio = { version = "1", features = ["full", "test-util", "macros"] }
|
||||
tokio-stream = "0.1"
|
||||
serde_json = "1"
|
||||
tempfile = "3"
|
||||
tempfile = "3"
|
||||
bytes = "1"
|
||||
Reference in new issue
Block a user