ww test: @test name-filter via fnmatch (both stages)
`ww test <file> <pattern>` runs only the @test fns whose names match the fnmatch glob; no pattern runs all (byte-for-byte the pre-filter path); zero matches prints "No tests run" and exits 0 (Hare ground truth ref/hare/test/+test.ha:114-117). A pattern in directory mode is rejected "ww test: pattern needs a single test file" (rc 2), identical wording in both twins (cmd/ww/main.c do_test + selfhost/cmd/ww/main.ww dotest). Mechanism (a): rt/start.s stashes argc/argv into rt_argc/rt_argv getters (rt_envp twin shape, -T synth untouched so 990-997 byte-id holds); lib/os.args() rebuilds the []str view, build-once-cached; lib/test/run.ww imports fnmatch and filters av[1..] (argv[0] is the binary path). The driver forwards the 2nd positional as argv[1] via fork/execv (cstage) / procrun (wwstage) so glob metachars aren't shell-expanded. os.args() is the first `alloc`-caller in the base os module, so os.ww now imports rt — the `alloc` builtin's malloc lowers to rt_malloc only when the rt binding is bundled (mirror lib/strings/strings.ww:30); without it a plain `ww build` of any os-importing program links bare libc `malloc` (undefined). os is bundled by ~every program, so this is load-bearing. The lib/test floor rises os-only -> os+fnmatch+ascii+strings in every -T build; the bundled `ascii` module vs a `@test fn ascii` collision that exposed is closed by the preceding #30 promote commit. 989_test_filter pins the full matrix on both twins byte-identically; 949 gains the dir-mode reject row. (#17)
This commit is contained in:
23
rt/start.s
23
rt/start.s
@@ -25,6 +25,11 @@ TEXT _start,$0
|
||||
ADDQ SP, AX // AX = SP + argc*8
|
||||
ADDQ $16, AX // AX = SP + argc*8 + 16 = &argv[argc+1] = envp
|
||||
MOVQ AX, rt_envp_slot(SB)
|
||||
// argc/argv survive the envp calc (only AX was clobbered): stash both
|
||||
// so lib/os.args can rebuild the []str view after entry. Same DATAW-
|
||||
// slot + TEXT-getter shape as rt_envp below (task #17 fnmatch filter).
|
||||
MOVQ DI, rt_argc_slot(SB)
|
||||
MOVQ SI, rt_argv_slot(SB)
|
||||
CALL main(SB)
|
||||
MOVQ AX, DI
|
||||
MOVQ $60, AX
|
||||
@@ -46,3 +51,21 @@ TEXT rt_envp,$0
|
||||
// slot (w6a has no GLOBL; same shape as lib/log's silent/default/
|
||||
// global cells in lib/log/log.s).
|
||||
DATAW rt_envp_slot(SB),"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
|
||||
// rt_argc — getter returning the process argc captured at entry. Bound
|
||||
// from lib/os as `@symbol("rt_argc") fn rtargc() i64;` (rt_envp twin).
|
||||
TEXT rt_argc,$0
|
||||
MOVQ rt_argc_slot(SB), AX
|
||||
RET
|
||||
|
||||
// rt_argv — getter returning &argv[0], a NUL-terminated table of *u8
|
||||
// argument strings. Bound from lib/os as
|
||||
// `@symbol("rt_argv") fn rtargv() **u8;`.
|
||||
TEXT rt_argv,$0
|
||||
MOVQ rt_argv_slot(SB), AX
|
||||
RET
|
||||
|
||||
// rt_argc_slot / rt_argv_slot — 8-byte writable cells, zero in .data,
|
||||
// overwritten by _start before CALL main. Same shape as rt_envp_slot.
|
||||
DATAW rt_argc_slot(SB),"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
DATAW rt_argv_slot(SB),"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
|
||||
Reference in New Issue
Block a user