ww driver: zero discovered tests is a loud failure

rundirtests returned rc=0 when it discovered no tests — a typo'd
path or empty corpus read as success. Fail loudly, matching the
cstage driver.
This commit is contained in:
2026-06-13 10:20:46 +09:00
parent 675a0368cd
commit 8f370533bb
4 changed files with 178 additions and 0 deletions

View File

@@ -4394,6 +4394,7 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
let pass: i32 = 0;
let fail: i32 = 0;
let seen: i32 = 0; // #64: count *_test.ww matches for the zero-test gate
let buf: []u8 = alloc([], 8192u64)!;
buf.len = 8192;
let dirlen: u64 = cstrlen(dir);
@@ -4409,6 +4410,7 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
let reclen: u64 = blo + (bhi * 256u64);
let name: *u8 = buf.ptr + off + 19u64;
if (cstrendswithlit(name, "_test.ww")) {
seen += 1;
let nlen: u64 = cstrlen(name);
// path = <dir>/<name>
let path: []u8 = alloc([], (os.PATH_MAX: u64))!;
@@ -4458,6 +4460,15 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
n = os.getdents64(fd, buf.ptr, 8192u64);
};
os.close(fd);
// #64: a directory with no *_test.ww files is a loud failure, not a
// silent rc=0 false-green. Mirrors cstage do_test (cmd/ww/main.c:945)
// "ww test: no *_test.ww files in %s".
if (seen == 0) {
cerr("ww test: no *_test.ww files in ");
os.write(2, dir, dirlen);
cerr("\n");
return 1;
};
if (fail == 0) { return 0; };
return 1;
};

View File

@@ -1556,6 +1556,7 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
let pass: i32 = 0;
let fail: i32 = 0;
let seen: i32 = 0; // #64: count *_test.ww matches for the zero-test gate
let buf: []u8 = alloc([], 8192u64)!;
buf.len = 8192;
let dirlen: u64 = cstrlen(dir);
@@ -1571,6 +1572,7 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
let reclen: u64 = blo + (bhi * 256u64);
let name: *u8 = buf.ptr + off + 19u64;
if (cstrendswithlit(name, "_test.ww")) {
seen += 1;
let nlen: u64 = cstrlen(name);
// path = <dir>/<name>
let path: []u8 = alloc([], (os.PATH_MAX: u64))!;
@@ -1620,6 +1622,15 @@ fn rundirtests(selfdir: *u8, dir: *u8) i32 = {
n = os.getdents64(fd, buf.ptr, 8192u64);
};
os.close(fd);
// #64: a directory with no *_test.ww files is a loud failure, not a
// silent rc=0 false-green. Mirrors cstage do_test (cmd/ww/main.c:945)
// "ww test: no *_test.ww files in %s".
if (seen == 0) {
cerr("ww test: no *_test.ww files in ");
os.write(2, dir, dirlen);
cerr("\n");
return 1;
};
if (fail == 0) { return 0; };
return 1;
};