phase 5: port integration tests (negotiation, pipe, pty)
Port the integration test suite from alknet-tty-local/tests/ into
tests/ at the crate root, plus the shared ClientSide harness. The
inline unit tests (wire, negotiation, control, adapter, session,
channels) were already ported in Phases 1-2 alongside the production
code; this completes Phase 5 step 2 (integration tests) — Phase 5
step 3 (channels integration tests) landed inline in src/channels.rs
mod tests in Phase 2.
Tests:
- tests/common/mod.rs — ClientSide wire-protocol harness +
spawn_session helper + negotiate_pty_json / negotiate_pipe_json
builders. Imports renamed alknet_core::auth::Identity ->
alkcall::core::auth::Identity, alknet_tty::... -> alktty::...
- tests/negotiation.rs — 4 negotiation-error scenarios
(unknown_backend, malformed_negotiation x3, allocate_failed)
- tests/pipe.rs — 6 pipe-mode scenarios (echo, separate stderr,
SIGTERM, cancel cleanup, resize no-op, stdout sentinel). The 2
cancel-cleanup / SIGTERM tests are #[cfg(unix)].
- tests/pty.rs — 8 PTY-mode scenarios (echo, interactive cat,
resize, SIGINT, process-group signal, stdin-EOF sentinel,
cancel cleanup, exit-chunk-is-last). The 4 signal /
cancel-cleanup tests are #[cfg(unix)].
Each test file carries #![cfg(feature = "local")] so the default
crate (no features) skips the integration binaries and stays
wasm-buildable. The pty/pipe cancel-cleanup tests use
unsafe { libc::kill(pid, 0) } to probe the child — matching the
existing pattern in src/local/ (libc::kill is a safe libc crate
API wrapped in an unsafe block per Rust's foreign-function rules;
no new in-crate unsafe beyond what src/local/ already has).
Plan doc updated: Phase 5 marked landed 2026-08-17.
Verification:
- cargo test -> 80 lib tests pass
- cargo test --all-features -> 99 tests pass (80 lib +
5 negotiation + 6 pipe + 8 pty)
- cargo clippy --all-targets --all-features -- -D warnings -> clean
- cargo clippy --target wasm32-unknown-unknown -- -D warnings -> clean
- cargo fmt --check -> clean
This commit is contained in:
+41
-12
@@ -2,7 +2,7 @@
|
||||
|
||||
Status: draft (revised 2026-08-17 to reflect landed upstream changes;
|
||||
Phase 4 landed 2026-08-17 — architecture docs + BAST schema +
|
||||
renumbered ADRs)
|
||||
renumbered ADRs; Phase 5 landed 2026-08-17 — tests)
|
||||
Last updated: 2026-08-17
|
||||
|
||||
## Overview
|
||||
@@ -488,18 +488,47 @@ split (`STREAM_CTRL_IN` = 3, `STREAM_CTRL_OUT` = 4) is an amendment
|
||||
inside ADR-001, mirroring alknet (it was not a standalone ADR there
|
||||
either). `AGENTS.md` was updated to match this mapping.
|
||||
|
||||
### Phase 5: Tests
|
||||
### Phase 5: Tests — landed 2026-08-17
|
||||
|
||||
1. Port existing unit tests from `alknet-tty` (wire, negotiation,
|
||||
control, adapter) — these live inline in each `src/*.rs` module's
|
||||
`#[cfg(test)] mod tests`.
|
||||
2. Port integration tests from `alknet-tty-local/tests/` (negotiation,
|
||||
pipe, pty) into `tests/` at the crate root. The pty test stays
|
||||
`#[cfg(unix)]`.
|
||||
3. Add channels integration tests — end-to-end `register_openable` +
|
||||
`ChannelClient::open_channel` + `drive_session` round-trip. Use
|
||||
the in-memory `MockBackend` from `backend.rs` for the producer
|
||||
side so the test doesn't need a real PTY.
|
||||
1. Ported existing unit tests from `alknet-tty` (wire, negotiation,
|
||||
control, adapter) inline in each `src/*.rs` module's
|
||||
`#[cfg(test)] mod tests` — done in Phases 1–2 alongside the
|
||||
production code (80 lib tests, all passing).
|
||||
2. Ported integration tests from `alknet-tty-local/tests/` into
|
||||
`tests/` at the crate root:
|
||||
- [`tests/common/mod.rs`](../tests/common/mod.rs) — the
|
||||
`ClientSide` wire-protocol harness + `spawn_session` helper +
|
||||
`negotiate_pty_json` / `negotiate_pipe_json` builders. Imports
|
||||
renamed `alknet_core::auth::Identity` →
|
||||
`alkcall::core::auth::Identity`, `alknet_tty::...` →
|
||||
`alktty::...`.
|
||||
- [`tests/negotiation.rs`](../tests/negotiation.rs) — 4
|
||||
negotiation-error scenarios (unknown_backend,
|
||||
malformed_negotiation ×3, allocate_failed).
|
||||
- [`tests/pipe.rs`](../tests/pipe.rs) — 6 pipe-mode scenarios
|
||||
(echo happy path, separate stderr, SIGTERM, cancel cleanup,
|
||||
resize no-op, stdout sentinel). The 2 cancel-cleanup /
|
||||
SIGTERM tests are `#[cfg(unix)]`.
|
||||
- [`tests/pty.rs`](../tests/pty.rs) — 8 PTY-mode scenarios
|
||||
(echo, interactive cat, resize, SIGINT, process-group
|
||||
signal, stdin-EOF sentinel, cancel cleanup,
|
||||
exit-chunk-is-last). The 4 signal / cancel-cleanup tests
|
||||
are `#[cfg(unix)]`.
|
||||
Each test file carries `#![cfg(feature = "local")]` so the
|
||||
default crate (no features) skips the integration binaries
|
||||
and stays wasm-buildable; `cargo test --all-features` runs
|
||||
all 19 integration tests (5 + 6 + 8).
|
||||
3. Added channels integration tests inline in
|
||||
[`src/channels.rs`](../src/channels.rs) `mod tests` (done in
|
||||
Phase 2 alongside the producer code): `register_openable`
|
||||
registration, end-to-end `ChannelClient::call_open_op` returns
|
||||
`channel_id`, scope-gate denies without `tty:open`, and the
|
||||
`MockBackend` exit-code sanity check. Uses the in-memory
|
||||
`MockBackend` from `backend.rs` for the producer side so no
|
||||
real PTY is needed.
|
||||
|
||||
Total: 80 lib tests + 19 integration tests = 99 passing under
|
||||
`--all-features`; 80 lib tests under default (wasm-clean) build.
|
||||
|
||||
## Open Questions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user