ww: test sources are *_test.ww only (Go contract)

Go compiles only _test.go files as tests; discovery now keys on the
_test.ww suffix alone. The line-leading-@test compatibility allowance
(noncanonical filenames admitted as test sources) is removed from both
driver stages and the coordinator. An @test declaration outside a
*_test.ww file is rejected loudly ("@test declaration outside
*_test.ww", wording byte-identical cs/ww) instead of silently running
under compose or silently dropping in a non-T build (#6). Tree audit
found zero real carriers; the two allowance fixtures flip canonical
(dep_test.ww, widget_test.ww). New pins: direnum attest-noncanon
reject row (both-stage stderr parity) and the coordinator
noncanonical_attest_rejected package row.
This commit is contained in:
2026-08-08 20:38:02 +09:00
parent 0cf9643be8
commit 659e859f34
10 changed files with 109 additions and 47 deletions

View File

@@ -107,7 +107,7 @@ fn pkgfailpath(path: str, reason: str) void = {
fn pkgusage() void = {
let s: str = strings.concat(
"usage: wwtest package [-c] [-list] [-j N] [-I DIR] [-w DIR] [-run|-filter GLOB] [-timeout-ms=N] [DIR | DIR/...] [-- GLOB ...]\n",
" *_test.ww is canonical; noncanonical files require an actual @test declaration\n",
" *_test.ww is the sole test-source form; @test elsewhere is rejected\n",
" -c retains the compiled package binaries; -j N runs up to N package groups at once\n",
" -w DIR keys a persistent per-package-group build workdir under DIR\n");
pkgput(os.STDERR_FILENO, s);
@@ -846,8 +846,14 @@ export fn packagecommand(args: []str) int = {
s.dir = strings.dup(pkgdirname(ds.paths[i]));
s.pkg = strings.dup(pn);
s.attest = pkgattest(body);
s.test = strings.hassuffix(pkgbase(ds.paths[i]), "_test.ww")
|| s.attest;
s.test = strings.hassuffix(pkgbase(ds.paths[i]), "_test.ww");
// Go's contract: only *_test.ww is a test source; @test
// anywhere else fails loudly rather than run or drop silently.
if (s.attest && !s.test) {
pkgfailpath(ds.paths[i],
"@test declaration outside *_test.ww");
return 1;
};
append(srcs, s);
i += 1;
};