mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Don't [try] to run non-tests
Currently, we treat every .html file in tests/wpt as-if it's a test. That
isn't always the case. wpt has a manifest tool to generate a manifest (in
JSON) of the tests, we should probably use that (but it's quite large).
This PR filters out two groups. First, everything in resources/ appears to
be things to _run_ the tests, not actual tests.
Second, any file without a "testharness.js" doesn't appear to be a test
either. Note that WPT's own manifest generator looks at this:
43a0615361/tools/manifest/sourcefile.py (L676)
(which is used later in the file to determine the type of file).
This commit is contained in:
@@ -148,6 +148,10 @@ pub fn main() !void {
|
|||||||
}
|
}
|
||||||
failures += 1;
|
failures += 1;
|
||||||
continue;
|
continue;
|
||||||
|
} orelse {
|
||||||
|
// This test should _not_ have been run.
|
||||||
|
run -= 1;
|
||||||
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
const suite = try Suite.init(alloc, tc, true, res);
|
const suite = try Suite.init(alloc, tc, true, res);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const polyfill = @import("../browser/polyfill/polyfill.zig");
|
|||||||
// runWPT parses the given HTML file, starts a js env and run the first script
|
// runWPT parses the given HTML file, starts a js env and run the first script
|
||||||
// tags containing javascript sources.
|
// tags containing javascript sources.
|
||||||
// It loads first the js libs files.
|
// It loads first the js libs files.
|
||||||
pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *FileLoader, err_msg: *?[]const u8) ![]const u8 {
|
pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *FileLoader, err_msg: *?[]const u8) !?[]const u8 {
|
||||||
// document
|
// document
|
||||||
const html = blk: {
|
const html = blk: {
|
||||||
const file = try std.fs.cwd().openFile(f, .{});
|
const file = try std.fs.cwd().openFile(f, .{});
|
||||||
@@ -38,6 +38,12 @@ pub fn run(arena: Allocator, comptime dir: []const u8, f: []const u8, loader: *F
|
|||||||
break :blk try file.readToEndAlloc(arena, 128 * 1024);
|
break :blk try file.readToEndAlloc(arena, 128 * 1024);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (std.mem.indexOf(u8, html, "testharness.js") == null) {
|
||||||
|
// This isn't a test. A lot of files are helpers/content for tests to
|
||||||
|
// make use of.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const dirname = fspath.dirname(f[dir.len..]) orelse unreachable;
|
const dirname = fspath.dirname(f[dir.len..]) orelse unreachable;
|
||||||
|
|
||||||
var runner = try @import("../testing.zig").jsRunner(arena, .{
|
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
|
|||||||
|
|
||||||
// return the detailed result.
|
// return the detailed result.
|
||||||
const res = try runner.eval("report.log", "report", err_msg);
|
const res = try runner.eval("report.log", "report", err_msg);
|
||||||
return res.toString(arena);
|
return try res.toString(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
// browse the path to find the tests list.
|
// browse the path to find the tests list.
|
||||||
pub fn find(allocator: std.mem.Allocator, comptime path: []const u8, list: *std.ArrayList([]const u8)) !void {
|
pub fn find(allocator: Allocator, comptime path: []const u8, list: *std.ArrayList([]const u8)) !void {
|
||||||
var dir = try std.fs.cwd().openDir(path, .{ .iterate = true, .no_follow = true });
|
var dir = try std.fs.cwd().openDir(path, .{ .iterate = true, .no_follow = true });
|
||||||
defer dir.close();
|
defer dir.close();
|
||||||
|
|
||||||
@@ -130,6 +136,12 @@ pub fn find(allocator: std.mem.Allocator, comptime path: []const u8, list: *std.
|
|||||||
if (entry.kind != .file) {
|
if (entry.kind != .file) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std.mem.startsWith(u8, entry.path, "resources/")) {
|
||||||
|
// resources for running the tests themselves, not actual tests
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!std.mem.endsWith(u8, entry.basename, ".html") and !std.mem.endsWith(u8, entry.basename, ".htm")) {
|
if (!std.mem.endsWith(u8, entry.basename, ".html") and !std.mem.endsWith(u8, entry.basename, ".htm")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user