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

@@ -0,0 +1,7 @@
package dep;
// Go's contract: a package's *_test.ww sources are not part of the
// imported package. Must be excluded when dep is imported by root.
@test fn imported_dependency_test_must_not_leak() void = {
assert(false);
};

View File

@@ -1,7 +0,0 @@
package dep;
// Noncanonical migration spelling: the actual line-leading @test makes this
// test-only. It must be excluded when dep is imported by the root package.
@test fn imported_dependency_test_must_not_leak() void = {
assert(false);
};

View File

@@ -232,6 +232,26 @@ fn packagepath(relative: str) str = {
clean(root);
};
// Go's contract: only *_test.ww sources are test sources; a line-leading
// @test anywhere else fails classification loudly rather than run or
// drop silently.
@test fn noncanonical_attest_rejected() void = {
let root: str = fresh();
let pkgdir: str = strings.concat(root, "/noncanon");
assert(os.mkdir(pkgdir, 448i32) == 0);
writefile(strings.concat(pkgdir, "/noncanon.ww"), strings.concat(
"package noncanon;\n",
"@test fn hidden() void = { assert(false); };\n"));
let av: []str = [driver("ww"), "test", pkgdir];
let out: commandout;
runcommand(root, "noncanon", av,
(30i64 * (time.second: i64)): time.duration, &out);
expectexit(&out, 1);
assert(has(out.stderr, "@test declaration outside *_test.ww"));
assert(!has(out.stdout, "hidden"));
clean(root);
};
@test fn empty_and_invalid_package_classes() void = {
let root: str = fresh();
let av: []str = [driver("ww"), "test", packagepath("no_tests")];