Browse Source

runtests.tcl: expose kit-internal lib trees to the testinterp auto_path

The testinterp replaces auto_path wholesale (project src/lib dirs, root
lib_tcl<N>/<arch>, [info library] + parent). Under a kit executable that
parent is e.g //zipfs:/app, and tclPkgUnknown scans only an entry plus its
immediate children - so kit-bundled packages under //zipfs:/app/lib_tcl<N>/
<pkg> (e.g tcllib's tcl::chan::fifo2, required by the shellrun harness at
testinterp setup) were unreachable. Unnoticed in punkshell because the
project's own root lib_tcl9/win32-x86_64 carries tcllib2.0; projects
without that payload (e.g tomlish) failed every file at
'package require shellrun' when run under a punk kit exe.
Now the kit's internal lib/lib_tcl<N> dirs are appended when present,
mirroring the internal-path classification in src/vfs/_config/punk_main.tcl:
zipfs app mount, tclkit ::tcl::kitpath exe dir-shadow, cookfs //cookit:/
volume (default mount name only, as per punk_main.tcl). No-op under native
tclsh. Verified: punk902z + tclsh902z suites pass; classification probed OK
under tclkit 8.6.17, punk9cook (cookit), punk91 (zipfs 9.1), native Tcl903;
tomlish suite under punk902z/punk91 goes 0 -> 149/149 with the same edit.

Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com
master
Julian Noble 7 days ago
parent
commit
5fd3bf9330
  1. 1
      src/tests/AGENTS.md
  2. 29
      src/tests/runtests.tcl

1
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<N>` 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<major>` 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.

29
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<N>/<arch> 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<N>/<pkg>. 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
}
}
}
#------------------------------------

Loading…
Cancel
Save