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

@@ -32,6 +32,7 @@ static const char *usage =
" foo.ww literal file\n"
" foo search cwd, -I dirs, then $WW_LIB 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";
static char *self_dir; /* directory containing this binary */
@@ -1689,6 +1690,29 @@ do_test(int argc, char **argv)
fprintf(stderr, "ww test: -S needs -o\n");
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. */
size_t tlen = strlen(target);
if (strcmp(target, "...") == 0 ||
(tlen >= 4 && strcmp(target + tlen - 4, "/...") == 0)) {
if (outstem[0]) {
fprintf(stderr,
"ww test: -c/-S/-o need a single test file\n");
return 2;
}
if (workdir[0]) {
fprintf(stderr,
"ww test: -w needs a single test file\n");
return 2;
}
if (pattern) {
fprintf(stderr,
"ww test: pattern needs a single test file\n");
return 2;
}
return exec_package_tests(argc, argv, src, NULL, 0);
}
struct stat st;
if (stat(target, &st) != 0) {
/* not a literal path — try module resolution and run as