@@ -96,11 +96,15 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
9696 \\console.log = function () {
9797 \\ console.push(...arguments);
9898 \\};
99+ \\console.debug = function () {
100+ \\ console.push("debug", ...arguments);
101+ \\};
99102 ;
100103 res = try evalJS (js_env , alloc , init , "init" );
101104 if (! res .success ) {
102105 return res ;
103106 }
107+ res .deinit (alloc );
104108
105109 // loop hover the scripts.
106110 const doc = parser .documentHTMLToDocument (html_doc );
@@ -121,6 +125,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
121125 if (! res .success ) {
122126 return res ;
123127 }
128+ res .deinit (alloc );
124129 }
125130
126131 // If the script as a source text, execute it.
@@ -131,6 +136,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
131136 if (! res .success ) {
132137 return res ;
133138 }
139+ res .deinit (alloc );
134140 }
135141
136142 // Mark tests as ready to run.
@@ -143,20 +149,26 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
143149 loadevt ,
144150 );
145151
152+ // wait for all async executions
153+ res = try js_env .waitTryCatch (alloc );
154+ if (! res .success ) {
155+ return res ;
156+ }
157+ res .deinit (alloc );
158+
146159 // Check the final test status.
147160 res = try evalJS (js_env , alloc , "report.status;" , "teststatus" );
148161 if (! res .success ) {
149162 return res ;
150163 }
164+ res .deinit (alloc );
151165
152166 // return the detailed result.
153167 return try evalJS (js_env , alloc , "report.log" , "teststatus" );
154168}
155169
156170fn evalJS (env : jsruntime.Env , alloc : std.mem.Allocator , script : []const u8 , name : ? []const u8 ) ! jsruntime.JSResult {
157- var res = jsruntime.JSResult {};
158- try env .run (alloc , script , name , & res , null );
159- return res ;
171+ return try env .execTryCatch (alloc , script , name );
160172}
161173
162174// browse the path to find the tests list.
0 commit comments