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:
7
test/package/dependency/dep/dep_test.ww
Normal file
7
test/package/dependency/dep/dep_test.ww
Normal 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);
|
||||
};
|
||||
@@ -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);
|
||||
};
|
||||
@@ -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")];
|
||||
|
||||
@@ -89,7 +89,7 @@ fn cmpsepwork(label: str, csdir: str, wwdir: str) void = {
|
||||
@test fn coloimport() void = {
|
||||
let td: str = testenv.fresh();
|
||||
let inc: str = strings.concat(testenv.repo(), "/test/wcc/data/colo98");
|
||||
let entry: str = strings.concat(inc, "/widget/widgettest.ww");
|
||||
let entry: str = strings.concat(inc, "/widget/widget_test.ww");
|
||||
let drvs: []str = ["ww", "ww_ww"];
|
||||
let tags: []str = ["cs", "ww"];
|
||||
let i: i32 = 0;
|
||||
|
||||
@@ -24,8 +24,9 @@ package direnum_test;
|
||||
// rejects — the authoritative loader-reject table over private trees:
|
||||
// root-conflict ("conflicting package names"), import-leaf ("does
|
||||
// not match import path"), root-missing and root-invalid ("invalid
|
||||
// or missing package clause"); per row both stages fail, carry the
|
||||
// needle, and their captured stderr is byte-identical.
|
||||
// or missing package clause"), attest-noncanon ("@test declaration
|
||||
// outside *_test.ww" — Go's test-file contract); per row both stages
|
||||
// fail, carry the needle, and their captured stderr is byte-identical.
|
||||
//
|
||||
// Dropped C machinery, not assertions: the ww_ww-absent skip gate
|
||||
// (the Make target declares both drivers) and the unlink/rmdir
|
||||
@@ -164,11 +165,13 @@ fn rejectpair(label: str, td: str, target: str, needle: str) void = {
|
||||
let wanted: str = strings.concat(importbad, "/wanted");
|
||||
let missing: str = strings.concat(td, "/missing");
|
||||
let invalid: str = strings.concat(td, "/invalid");
|
||||
let attbad: str = strings.concat(td, "/attbad");
|
||||
assert(os.mkdir(rootbad, 493) == 0);
|
||||
assert(os.mkdir(importbad, 493) == 0);
|
||||
assert(os.mkdir(wanted, 493) == 0);
|
||||
assert(os.mkdir(missing, 493) == 0);
|
||||
assert(os.mkdir(invalid, 493) == 0);
|
||||
assert(os.mkdir(attbad, 493) == 0);
|
||||
testenv.writefile(strings.concat(rootbad, "/a.ww"),
|
||||
"package rootbad;\nfn main() i32 = { return 0; };\n");
|
||||
testenv.writefile(strings.concat(rootbad, "/b.ww"),
|
||||
@@ -182,15 +185,21 @@ fn rejectpair(label: str, td: str, target: str, needle: str) void = {
|
||||
"fn main() i32 = { return 0; };\n");
|
||||
testenv.writefile(strings.concat(invalid, "/a.ww"),
|
||||
"package 7bad;\nfn main() i32 = { return 0; };\n");
|
||||
testenv.writefile(strings.concat(attbad, "/a.ww"),
|
||||
"package attbad;\nfn main() i32 = { return 0; };\n");
|
||||
testenv.writefile(strings.concat(attbad, "/t.ww"), strings.concat(
|
||||
"package attbad;\n",
|
||||
"@test fn hidden() void = { assert(false); };\n"));
|
||||
|
||||
let tags: []str = ["root-conflict", "import-leaf", "root-missing",
|
||||
"root-invalid"];
|
||||
"root-invalid", "attest-noncanon"];
|
||||
let targets: []str = [rootbad, strings.concat(importbad,
|
||||
"/entry.ww"), missing, invalid];
|
||||
"/entry.ww"), missing, invalid, attbad];
|
||||
let needles: []str = ["conflicting package names",
|
||||
"does not match import path",
|
||||
"invalid or missing package clause",
|
||||
"invalid or missing package clause"];
|
||||
"invalid or missing package clause",
|
||||
"@test declaration outside *_test.ww"];
|
||||
let r: i32 = 0;
|
||||
for (r < tags.len) {
|
||||
rejectpair(tags[r], td, targets[r], needles[r]);
|
||||
|
||||
Reference in New Issue
Block a user