wcc: reject exported/bodyless/duplicate @test shapes
Both frontends, byte-stable fragments; -T-mode checks, so the rows live in test/package (the fixture compile cell cannot reach -T).
This commit is contained in:
@@ -443,6 +443,52 @@ fn packagepath(relative: str) str = {
|
||||
clean(root);
|
||||
};
|
||||
|
||||
// Invalid @test attribute shapes reject at build with stable text on
|
||||
// BOTH frontends (the -T synth checker owns them; the fixture corpus
|
||||
// cannot reach -T, so these rows live here). Fragments only — the
|
||||
// stages' error-line prefixes legitimately differ (file:line:col vs
|
||||
// file:).
|
||||
@test fn invalid_test_shapes_reject() void = {
|
||||
let root: str = fresh();
|
||||
let shapes: []str = [
|
||||
"@test export fn t() void = { };",
|
||||
"@test fn t() void;",
|
||||
"@test fn t(x: i32) void = { };",
|
||||
"@test fn t() i32 = { return 0; };",
|
||||
"@test @test fn t() void = { };",
|
||||
];
|
||||
let frags: []str = [
|
||||
"@test fn 't' cannot be exported",
|
||||
"@test fn 't' needs a body",
|
||||
"@test fn 't' must be fn() void",
|
||||
"@test fn 't' must be fn() void",
|
||||
"duplicate @test on fn 't'",
|
||||
];
|
||||
let digits: []str = ["0", "1", "2", "3", "4"];
|
||||
let outc: commandout;
|
||||
let outw: commandout;
|
||||
let i: i32 = 0;
|
||||
for (i < shapes.len) {
|
||||
let dir: str = strings.concat(root, "/shape", digits[i]);
|
||||
assert(os.mkdir(dir, 448i32) == 0);
|
||||
let src: str = strings.concat(dir, "/bad_test.ww");
|
||||
writefile(src, strings.concat("package main;\n",
|
||||
shapes[i], "\n"));
|
||||
let avc: []str = [driver("ww"), "test", src];
|
||||
let avw: []str = [driver("ww_ww"), "test", src];
|
||||
runcommand(root, strings.concat("shape-c", digits[i]), avc,
|
||||
(30i64 * (time.second: i64)): time.duration, &outc);
|
||||
runcommand(root, strings.concat("shape-ww", digits[i]), avw,
|
||||
(30i64 * (time.second: i64)): time.duration, &outw);
|
||||
expectexit(&outc, 1);
|
||||
expectexit(&outw, 1);
|
||||
assert(has(outc.stderr, frags[i]));
|
||||
assert(has(outw.stderr, frags[i]));
|
||||
i += 1;
|
||||
};
|
||||
clean(root);
|
||||
};
|
||||
|
||||
// Go's ./... parity: a trailing "..." element walks the tree, one package
|
||||
// run per test-bearing directory, dot- and underscore-prefixed directory
|
||||
// names excluded. The excluded sentinels hold failing tests so a wrong
|
||||
|
||||
Reference in New Issue
Block a user