Browse Source
The module hard-required opt, cmdline and tepam at load time, so on a punkshell build
without tcllib 'package require argparsingtest' died outright with "can't find package
opt". A harness whose whole job is comparing parser libraries is useless precisely on the
runtime you wanted to measure, and the module already had the right pattern for this:
argp, parse_args and argparse degrade to a not_loaded row rather than taking the module
down with them. The three tcllib parsers were the odd ones out. Reproduced before the
change with punk module paths only and an emptied auto_path, which is where tcllib's
pkgIndex-based packages come from.
Every parser this module compares is now optional. Their roster entries become
{optional opt}, {optional cmdline} and {optional tepam}, so discover_parsers reports
not_loaded when the package is absent and nothing in the harness calls them. punk::args
and Tcl 8.6- remain hard requires - the harness itself is built on those.
The guard differs by package because the dependency does:
cmdline is only ever called INSIDE proc bodies, so the catch-guarded require at the top
is the whole story - the wrapper procs stay defined and are simply never invoked.
opt and tepam are used at DEFINITION time: tcl::OptProc and tepam::procedure are the
commands that create the wrapper procs. Their seven definition sites (four opt, across
opts/tkstyle/tclstyle/sandwich; three tepam) are each additionally guarded, so with the
package absent the proc does not exist at all.
Those sites test 'package present' rather than wrapping the definition in a bare catch.
Both tolerate absence, but a presence test still lets a genuine error in a spec raise
loudly on a runtime that does have the package, where a catch would swallow it. The
pre-existing argp registration site keeps its original catch idiom - working code, not
part of this change.
Pinned by module_loads_without_optional_parser_packages: a child interp with an emptied
auto_path that asserts the module loads, that each absent package's parser reports
not_loaded, and that the opt and tepam wrapper procs genuinely do not exist. Where a
runtime supplies one of the three as a .tm on a module path the test degrades to
asserting the module still loads, which is the main claim anyway.
Tests that name parsers explicitly (first_call_library_backed, first_call_positional_styles,
sandwich_strictness) now filter through a loaded_parsers helper, and the tclstyle
cmdline_typed status assertion derives its expectation from package presence: those
parsers can now legitimately be missing.
Verification: 26/26 pass under the 32-bit luck-test2 runtime with no skips, 24 pass +
2 skip under native Tcl 9.0.3. With opt and tepam hidden, the built 1.3.0 module loads,
reports both as not_loaded, and compare lists them in its "not loaded:" footer instead of
the whole module failing to load.
Claude-Session: https://claude.ai/code/session_01Q82VuBXzgeKsAwMYHrbpP1
Assisted-by: harness=claude; primary-model=claude-opus-5[1m]; api-location=anthropic.com
master
3 changed files with 272 additions and 155 deletions
Loading…
Reference in new issue