# src/tests/modules — Source Module Test Suites ## Purpose Unit tests for editable source modules under `src/modules/`, `src/modules_tcl8/`, and `src/modules_tcl9/`. These tests use `tcltest` and run against the uninstalled source tree through `src/tests/runtests.tcl`. ## Ownership - Agents should add or update tests here when changing module behavior in `src/modules/` or Tcl-version-specific module trees. - Installed-module test packages under `src/modules/test/` are packaging artifacts and are not the default place for source-tree behavior tests. - Do not delete, skip, or weaken existing tests without explicit user direction. ## Local Contracts - The directory hierarchy mirrors module namespace paths, such as `src/tests/modules/punk/args/` for `punk::args`. - Test files use `.test` extension and must `package require` any extra packages explicitly. - Test files must end with `tcltest::cleanupTests` so `src/tests/runtests.tcl` can produce trusted aggregate counts. - Test files may commonly use line-continuation backslashes, and existing Tcl expand-syntax structures in tests should not be refactored into line continuations. - Tests must exercise source modules as loaded by `src/tests/runtests.tcl`, not installed or built output modules. - `testsuites/dev/` may hold known-bug or expected-fail tests; guard them with disabled `tcltest` constraints so standard source-tree runs skip them by default. ## Work Guidance - Put new module tests under `src/tests/modules//testsuites//` following nearby layout. - For efficient agent runs, use `-report compact -show-passes 0` and include the narrowest namespace path plus file tail when known. - Prefer `try { ... } on error {result options} { ... }` for structured error capture in test bodies. - Focused verification should mirror production pipelines inside tests using Punk pipeline syntax when that parity matters. - Capture enough stderr or failure context to identify the failing command or assertion. ## Verification - Run targeted module tests with ` src/tests/runtests.tcl -report compact -show-passes 0 -include-paths modules//**`. - Run a single test by name with ` src/tests/runtests.tcl -report compact -show-passes 0 -tcltestoptions {-match } -include-paths modules//**`. - Run a specific test file by adding its file tail, such as ` src/tests/runtests.tcl -report compact -show-passes 0 -include-paths modules/punk/args/** parsekey.test`. - Use `-report markdown+json` when both detailed human-readable failure sections and a structured summary are useful. - If a compact result shows `reason=missing-cleanupTests`, add the missing `tcltest::cleanupTests` before trusting observed pass events. ## Child DOX Index - `opunk/console/` — ::opunk::Console backend subclass tests (`testsuites/console/backends.test`, G-001): virtual dispatch of subclass overrides through base-class calls and punk::console::console_spec_resolve (both unchanged), TestConsole determinism + probe-free at_eof, SshConsole capability/eof + the flagship size-via-ANSI-query-over-socket case (a scripted remote terminal answers CSI 6n), TkConsole widget size/eof (gated behind env PUNK_TEST_TK=1 - Tk in the shared testinterp has side effects; also verifiable standalone under a tk-capable kit e.g `punk91 src