@@ -30,14 +30,20 @@ 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 , err_msg : * ? []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 , .{});
3737 defer file .close ();
3838 break :blk try file .readToEndAlloc (arena , 128 * 1024 );
3939 };
4040
41+ if (std .mem .indexOf (u8 , html , "testharness.js" ) == null ) {
42+ // This isn't a test. A lot of files are helpers/content for tests to
43+ // make use of.
44+ return null ;
45+ }
46+
4147 const dirname = fspath .dirname (f [dir .len .. ]) orelse unreachable ;
4248
4349 var runner = try @import ("../testing.zig" ).jsRunner (arena , .{
@@ -115,11 +121,11 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
115121
116122 // return the detailed result.
117123 const res = try runner .eval ("report.log" , "report" , err_msg );
118- return res .toString (arena );
124+ return try res .toString (arena );
119125}
120126
121127// browse the path to find the tests list.
122- pub fn find (allocator : std.mem. Allocator , comptime path : []const u8 , list : * std .ArrayList ([]const u8 )) ! void {
128+ pub fn find (allocator : Allocator , comptime path : []const u8 , list : * std .ArrayList ([]const u8 )) ! void {
123129 var dir = try std .fs .cwd ().openDir (path , .{ .iterate = true , .no_follow = true });
124130 defer dir .close ();
125131
@@ -130,6 +136,12 @@ pub fn find(allocator: std.mem.Allocator, comptime path: []const u8, list: *std.
130136 if (entry .kind != .file ) {
131137 continue ;
132138 }
139+
140+ if (std .mem .startsWith (u8 , entry .path , "resources/" )) {
141+ // resources for running the tests themselves, not actual tests
142+ continue ;
143+ }
144+
133145 if (! std .mem .endsWith (u8 , entry .basename , ".html" ) and ! std .mem .endsWith (u8 , entry .basename , ".htm" )) {
134146 continue ;
135147 }
0 commit comments