@@ -30,7 +30,7 @@ const polyfill = @import("../browser/polyfill/polyfill.zig");
3030// runWPT parses the given HTML file, starts a js env and run the first script
3131// tags containing javascript sources.
3232// It loads first the js libs files.
33- pub fn run (arena : Allocator , comptime dir : []const u8 , f : []const u8 , loader : * FileLoader , msg_out : * ? []const u8 ) ! []const u8 {
33+ pub fn run (arena : Allocator , comptime dir : []const u8 , f : []const u8 , loader : * FileLoader , err_msg : * ? []const u8 ) ! []const u8 {
3434 // document
3535 const html = blk : {
3636 const file = try std .fs .cwd ().openFile (f , .{});
@@ -48,7 +48,7 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
4848
4949 // display console logs
5050 defer {
51- const res = runner .eval ("console.join('\\ n');" ) catch unreachable ;
51+ const res = runner .eval ("console.join('\\ n');" , err_msg ) catch unreachable ;
5252 const log = res .toString (arena ) catch unreachable ;
5353 if (log .len > 0 ) {
5454 std .debug .print ("-- CONSOLE LOG\n {s}\n --\n " , .{log });
@@ -63,7 +63,7 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
6363 \\ console.debug = function () {
6464 \\ console.push("debug", ...arguments);
6565 \\ };
66- );
66+ , err_msg );
6767
6868 // loop over the scripts.
6969 const doc = parser .documentHTMLToDocument (runner .state .document .? );
@@ -79,12 +79,12 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
7979 // no need to free path, thanks to the arena.
8080 path = try fspath .join (arena , &.{ "/" , dirname , path });
8181 }
82- try runner .exec (try loader .get (path ));
82+ try runner .exec (try loader .get (path ), err_msg );
8383 }
8484
8585 // If the script as a source text, execute it.
8686 const src = try parser .nodeTextContent (s ) orelse continue ;
87- try runner .exec (src );
87+ try runner .exec (src , err_msg );
8888 }
8989
9090 // Mark tests as ready to run.
@@ -104,17 +104,17 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
104104 defer try_catch .deinit ();
105105 runner .loop .run () catch | err | {
106106 if (try try_catch .err (arena )) | msg | {
107- msg_out .* = msg ;
107+ err_msg .* = msg ;
108108 }
109109 return err ;
110110 };
111111 }
112112
113113 // Check the final test status.
114- try runner .exec ("report.status;" );
114+ try runner .exec ("report.status;" , err_msg );
115115
116116 // return the detailed result.
117- const res = try runner .eval ("report.log" );
117+ const res = try runner .eval ("report.log" , err_msg );
118118 return res .toString (arena );
119119}
120120
0 commit comments