wpt: if no test case found, the suite fails

This commit is contained in:
Pierre Tachoire
2024-06-21 15:18:28 +02:00
parent 522b293149
commit ab31cc0a18
2 changed files with 13 additions and 2 deletions

View File

@@ -323,7 +323,7 @@ fn runSafe(
if (c.pass) pass += 1;
}
}
const status = if (pass == all) "Pass" else "Fail";
const status = if (all > 0 and pass == all) "Pass" else "Fail";
std.debug.print("{s} {d}/{d}", .{ status, pass, all });
continue;
@@ -366,7 +366,8 @@ fn runSafe(
if (c.pass) pass += 1;
}
}
std.debug.print("{d}/{d}\n\n", .{ pass, all });
const status = if (all > 0 and pass == all) "Pass" else "Fail";
std.debug.print("{s} {d}/{d}\n\n", .{ status, pass, all });
}
if (out == .json) {

View File

@@ -137,6 +137,16 @@ pub const Suite = struct {
try cases.append(case);
}
if (cases.items.len == 0) {
// no test case, create a failed one.
suite.pass = false;
try cases.append(.{
.pass = false,
.name = "no test case",
.message = "no test case",
});
}
suite.cases = try cases.toOwnedSlice();
return suite;