diff --git a/src/tests/AGENTS.md b/src/tests/AGENTS.md index 3afd1d56..aa026ced 100644 --- a/src/tests/AGENTS.md +++ b/src/tests/AGENTS.md @@ -16,6 +16,7 @@ Top-level test harness and source-tree tests for ShellSpy/Punk. Tests here exerc - Tests use `tcltest` unless a child AGENTS.md documents a different local harness. - `runtests.tcl` excludes `AGENTS.md` and `*.tcl` helper files when discovering `.test` files. - `runtests.tcl` defaults tcltest `-tmpdir` (the `makeFile`/`makeDirectory` location) to a fresh directory under the system temp area, deleted before exit, so test helper files never land in the source tree (aborted core exec.test runs previously littered `src/tests`). A `-tmpdir` supplied via `-tcltestoptions` overrides this. Applies to single-process mode; multi-process mode does not yet forward tcltest options to child processes. +- The testinterp auto_path (replaced wholesale) also includes the running kit's internal `lib`/`lib_tcl` trees (zipfs app mount, tclkit `::tcl::kitpath`, cookfs `//cookit:/` — mirroring `src/vfs/_config/punk_main.tcl`), so kit-bundled packages (e.g. tcllib's `tcl::chan::fifo2`, needed by the shellrun harness) resolve when the project tree doesn't supply them. `tclPkgUnknown` scans only an entry plus immediate children, so the kit lib dirs must be explicit entries. No-op under a native tclsh. - The single-process testinterp runs `package prefer latest` so alpha-versioned dev modules (`999999.0a1.0`) are preferred over stable bootsupport/vendored copies on unversioned `package require`. - The testinterp module path includes `src/vendormodules` (and `src/vendormodules_tcl` when present) so vendored dependencies such as `voo` resolve in tests. - Tests should run against source modules and libraries from `src/`, not installed packages or root-level build outputs. diff --git a/src/tests/runtests.tcl b/src/tests/runtests.tcl index 9f9ae976..b0b42e62 100644 --- a/src/tests/runtests.tcl +++ b/src/tests/runtests.tcl @@ -308,6 +308,35 @@ lappend test_auto_path [info library] #but we replace auto_path wholesale in the testinterp, and not every project carries a #root lib_tcl/ runtime payload that would otherwise supply Thread. lappend test_auto_path [file dirname [info library]] +#kit-internal library trees: when running under a kit/zipkit executable the wholesale +#auto_path replacement above would otherwise hide packages bundled in the kit's lib trees +#(e.g tcllib's tcl::chan::fifo2, needed by the shellrun harness) - tclPkgUnknown only scans +#an auto_path entry and its immediate children, so [file dirname [info library]] (e.g +#//zipfs:/app) cannot reach //zipfs:/app/lib_tcl/. Mirrors the internal-path +#classification in src/vfs/_config/punk_main.tcl: zipfs app mount, tclkit ::tcl::kitpath +#(exe path dir-shadow), cookfs //cookit:/ volume (mount name is compile-configurable; +#only the known default is supported - as per punk_main.tcl). +set kit_lib_bases [list] +if {[info commands tcl::zipfs::root] ne "" && [llength [tcl::zipfs::mount]]} { + set zipbase [file join [tcl::zipfs::root] app] + if {"$zipbase" in [tcl::zipfs::mount]} { + lappend kit_lib_bases $zipbase + } +} +if {[info exists ::tcl::kitpath] && $::tcl::kitpath ne ""} { + lappend kit_lib_bases [file normalize $::tcl::kitpath] +} +if {"//cookit:/" in [file volumes]} { + lappend kit_lib_bases //cookit:/ +} +foreach kit_base $kit_lib_bases { + foreach p [list lib lib_tcl$tcl_major] { + set kit_libdir [file join $kit_base $p] + if {[file isdirectory $kit_libdir] && $kit_libdir ni $test_auto_path} { + lappend test_auto_path $kit_libdir + } + } +} #------------------------------------