ww: recursive DIR/... package discovery for ww test

This commit is contained in:
2026-08-08 13:35:34 +09:00
parent 81e7f95548
commit 0f0fd36563
5 changed files with 193 additions and 10 deletions

View File

@@ -2044,7 +2044,7 @@ fn resolvemodule(selfdir: *u8, name: *u8, incs: *u8, isdir: *i32) *u8 = {
// ---- Subcommand handlers ----------------------------------------------
fn writeusage(fd: i32) void = {
let s: str = "usage: ww [-V] <subcommand> [args...]\n -V print version and exit\n build [-S] [-w DIR] [-o FILE] [path] compile module; -S stops after package asm\n run [path] ... build then exec, passing extra args to the program\n test [-S -o STEM] [-w DIR] [options] [path] build/run tests; -S emits package asm\n version print version and exit\n\n path forms:\n foo.ww literal file\n foo search cwd, -I dirs, then $WW_LIB-equiv for foo.ww or foo/foo.ww\n lib/foo directory: build lib/foo/foo.ww\n . build the cwd's <basename>.ww\n";
let s: str = "usage: ww [-V] <subcommand> [args...]\n -V print version and exit\n build [-S] [-w DIR] [-o FILE] [path] compile module; -S stops after package asm\n run [path] ... build then exec, passing extra args to the program\n test [-S -o STEM] [-w DIR] [options] [path] build/run tests; -S emits package asm\n version print version and exit\n\n path forms:\n foo.ww literal file\n foo search cwd, -I dirs, then $WW_LIB-equiv for foo.ww or foo/foo.ww\n lib/foo directory: build lib/foo/foo.ww\n lib/... every package under lib, recursively (test only)\n . build the cwd's <basename>.ww\n";
os.write(fd, s.ptr, s.len: u64);
};
@@ -2672,6 +2672,34 @@ fn dotest(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
return 2;
};
// Go's ./... form: a trailing "..." element is a package-tree
// request for the coordinator, never a literal path — recognized
// before stat, with the directory-mode rejects.
let tlen: u64 = cstrlen(target);
let istree: bool = cstreqlit(target, "...");
if (!istree && tlen >= 4u64) {
istree = target[tlen - 4u64] == '/'
&& target[tlen - 3u64] == '.'
&& target[tlen - 2u64] == '.'
&& target[tlen - 1u64] == '.';
};
if (istree) {
if (outstem != nil) {
cerr("ww test: -c/-S/-o need a single test file\n");
return 2;
};
if (workdir != nil) {
cerr("ww test: -w needs a single test file\n");
return 2;
};
if (patarg != nil) {
cerr("ww test: pattern needs a single test file\n");
return 2;
};
return execpackagetests(selfdir, argv, argc, start,
targetindex, nil, false);
};
let resolved: *u8 = target;
let isdir: i32 = 0;
let found: bool = false;