Skip to content

Commit faf9344

Browse files
Merge pull request #555 from lightpanda-io/wpt_filter_non_tests
Don't [try] to run non-tests
2 parents 9727a9d + 8aa3608 commit faf9344

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/main_wpt.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ pub fn main() !void {
148148
}
149149
failures += 1;
150150
continue;
151+
} orelse {
152+
// This test should _not_ have been run.
153+
run -= 1;
154+
continue;
151155
};
152156

153157
const suite = try Suite.init(alloc, tc, true, res);

src/wpt/run.zig

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)