add missing try/catch around loop wait for wpt tests

This commit is contained in:
Karl Seguin
2025-04-16 19:20:35 +08:00
parent 753a093689
commit d688d8812d
2 changed files with 15 additions and 4 deletions

View File

@@ -138,8 +138,9 @@ pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(alloc);
defer arena.deinit();
const res = wpt.run(arena.allocator(), wpt_dir, tc, &loader) catch |err| {
const suite = try Suite.init(alloc, tc, false, @errorName(err));
var msg_out: ?[]const u8 = null;
const res = wpt.run(arena.allocator(), wpt_dir, tc, &loader, &msg_out) catch |err| {
const suite = try Suite.init(alloc, tc, false, if (msg_out) |msg| msg else @errorName(err));
try results.append(suite);
if (out == .text) {

View File

@@ -30,7 +30,7 @@ const polyfill = @import("../browser/polyfill/polyfill.zig");
// runWPT parses the given HTML file, starts a js env and run the first script
// tags containing javascript sources.
// It loads first the js libs files.
pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *FileLoader) ![]const u8 {
pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *FileLoader, msg_out: *?[]const u8) ![]const u8 {
// document
const html = blk: {
const file = try std.fs.cwd().openFile(f, .{});
@@ -98,7 +98,17 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
);
// wait for all async executions
try runner.loop.run();
{
var try_catch: Env.TryCatch = undefined;
try_catch.init(runner.executor);
defer try_catch.deinit();
runner.loop.run() catch |err| {
if (try try_catch.err(arena)) |msg| {
msg_out.* = msg;
}
return err;
};
}
// Check the final test status.
try runner.exec("report.status;");