add Dart PTY wrapper and test-core harness

PtySession wraps the ptyc helper: socketpair + Process.start + recvmsg
with SCM_RIGHTS for master-fd transfer, a background isolate that
loops on blocking read() and posts byte chunks, plus write/resize/
kill/close. close() SIGTERMs the child so the PTY's EOF wakes the
reader naturally; SIGKILL + fd close + isolate kill cover the edge
where the shell ignores SIGTERM — avoids the known Linux quirk where
closing an fd doesn't unblock an in-flight read() on it.

Env defaults stamp TERM=xterm-256color, COLORTERM=truecolor,
CLICOLOR_FORCE=1 so shells + tmux + Claude emit 24-bit sequences
that xterm.dart can render. User env (HOME / USER / SHELL) still
inherits via mergePtyEnv().

ffi: 2.1.3 added as a runtime dep — the FFI bindings for socketpair,
recvmsg, read/write, and ioctl(TIOCSWINSZ) need an allocator we're
not writing by hand. Justified in pubspec + listed in licenses.yaml
per D-042.

make test-core (ci/test_core.sh) runs the Flutter-free core tests
under a 120s hard timeout with setsid + process-group kill, wired
ahead of the fast app tests in push-check so a hung PTY test can't
wedge a pre-push. Current core suite: 24 tests in ~1s.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-04-22 09:01:01 +02:00
co-authored by Claude
parent c94ad2c05b
commit edd8a20e0d
14 changed files with 973 additions and 7 deletions
+6 -2
View File
@@ -73,6 +73,10 @@ endif
test: ## Fast: analyze + format + unit + widget + golden (<60s).
ci/test.sh
.PHONY: test-core
test-core: ## Flutter-free core tests (IPC, daemon, PTY) with hard timeout.
ci/test_core.sh
.PHONY: test-a11y
test-a11y: ## A11y contract (semantic coverage + keyboard + contrast + i18n).
ci/test_a11y.sh
@@ -86,7 +90,7 @@ test-e2e: build ## Daemon subprocess + web WASM Playwright smoke.
ci/test_e2e.sh
.PHONY: test-all
test-all: test test-a11y test-integration test-e2e ## Everything, sequentially.
test-all: test-core test test-a11y test-integration test-e2e ## Everything, sequentially.
.PHONY: coverage
coverage: ## flutter test --coverage + lcov summary.
@@ -173,7 +177,7 @@ decisions-validate: ## Parser dry-run over decisions/*.md (cheap pre-push gate).
tools/scripts/plan decisions validate
.PHONY: push-check
push-check: decisions-validate test test-a11y ## Pre-push gate: decisions + fast unit + widget + golden + a11y (<90s).
push-check: decisions-validate test-core test test-a11y ## Pre-push gate: decisions + core + fast unit + widget + golden + a11y (<90s).
.PHONY: hooks
hooks: ## Install the repo's git hooks (points core.hooksPath at .githooks/).