From 38d48d7515783d2cd3f5074c8bd9cb727e3fcaac Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 23 May 2024 15:11:08 +0200 Subject: [PATCH 1/3] upgrade zig-js-runtime --- vendor/zig-js-runtime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/zig-js-runtime b/vendor/zig-js-runtime index d4a2eaefd..bb0160936 160000 --- a/vendor/zig-js-runtime +++ b/vendor/zig-js-runtime @@ -1 +1 @@ -Subproject commit d4a2eaefd8390b9483e5ad58d2992dc381632559 +Subproject commit bb01609365509322e340e8a7cfa06e67e0a8478b From b4f445183ca7a89191001234ed35de75b02bd99b Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 23 May 2024 15:09:53 +0200 Subject: [PATCH 2/3] wpt: add log.debug method in pure JS --- src/wpt/run.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wpt/run.zig b/src/wpt/run.zig index 4322ee401..1dc8797f6 100644 --- a/src/wpt/run.zig +++ b/src/wpt/run.zig @@ -96,6 +96,9 @@ 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) { From 77bf332f13fd157fbc9d6e48ac0989c0c3bee903 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 23 May 2024 15:10:28 +0200 Subject: [PATCH 3/3] wpt: split script exec and wait loop --- src/wpt/run.zig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wpt/run.zig b/src/wpt/run.zig index 1dc8797f6..3625fdf70 100644 --- a/src/wpt/run.zig +++ b/src/wpt/run.zig @@ -104,6 +104,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const if (!res.success) { return res; } + res.deinit(alloc); // loop hover the scripts. const doc = parser.documentHTMLToDocument(html_doc); @@ -124,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. @@ -134,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. @@ -146,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.