Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/wpt/run.zig
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
\\console.log = function () {
\\ console.push(...arguments);
\\};
\\console.debug = function () {
\\ console.push("debug", ...arguments);
\\};
;
res = try evalJS(js_env, alloc, init, "init");
if (!res.success) {
return res;
}
res.deinit(alloc);

// loop hover the scripts.
const doc = parser.documentHTMLToDocument(html_doc);
Expand All @@ -121,6 +125,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
if (!res.success) {
return res;
}
res.deinit(alloc);
}

// If the script as a source text, execute it.
Expand All @@ -131,6 +136,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
if (!res.success) {
return res;
}
res.deinit(alloc);
}

// Mark tests as ready to run.
Expand All @@ -143,20 +149,26 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
loadevt,
);

// wait for all async executions
res = try js_env.waitTryCatch(alloc);
if (!res.success) {
return res;
}
res.deinit(alloc);

// Check the final test status.
res = try evalJS(js_env, alloc, "report.status;", "teststatus");
if (!res.success) {
return res;
}
res.deinit(alloc);

// return the detailed result.
return try evalJS(js_env, alloc, "report.log", "teststatus");
}

fn evalJS(env: jsruntime.Env, alloc: std.mem.Allocator, script: []const u8, name: ?[]const u8) !jsruntime.JSResult {
var res = jsruntime.JSResult{};
try env.run(alloc, script, name, &res, null);
return res;
return try env.execTryCatch(alloc, script, name);
}

// browse the path to find the tests list.
Expand Down
2 changes: 1 addition & 1 deletion vendor/zig-js-runtime