Skip to content

Commit 80348ef

Browse files
committed
fix wpt tests with platform requirement
1 parent a3c1474 commit 80348ef

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/main_wpt.zig

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ pub fn main() !void {
7070
defer _ = test_arena.reset(.{ .retain_capacity = {} });
7171

7272
var err_out: ?[]const u8 = null;
73-
const result = run(test_arena.allocator(), test_file, &loader, &err_out) catch |err| blk: {
73+
const result = run(
74+
test_arena.allocator(),
75+
&platform,
76+
test_file,
77+
&loader,
78+
&err_out,
79+
) catch |err| blk: {
7480
if (err_out == null) {
7581
err_out = @errorName(err);
7682
}
@@ -89,7 +95,13 @@ pub fn main() !void {
8995
try writer.finalize();
9096
}
9197

92-
fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?[]const u8) !?[]const u8 {
98+
fn run(
99+
arena: Allocator,
100+
platform: *const Platform,
101+
test_file: []const u8,
102+
loader: *FileLoader,
103+
err_out: *?[]const u8,
104+
) !?[]const u8 {
93105
// document
94106
const html = blk: {
95107
const full_path = try std.fs.path.join(arena, &.{ WPT_DIR, test_file });
@@ -110,6 +122,7 @@ fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?
110122
var runner = try @import("testing.zig").jsRunner(arena, .{
111123
.url = "http://127.0.0.1",
112124
.html = html,
125+
.platform = platform,
113126
});
114127
defer runner.deinit();
115128

src/testing.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
const std = @import("std");
2020
const Allocator = std.mem.Allocator;
2121

22+
const Platform = @import("runtime/js.zig").Platform;
23+
2224
pub const allocator = std.testing.allocator;
2325
pub const expectError = std.testing.expectError;
2426
pub const expect = std.testing.expect;
@@ -383,6 +385,7 @@ pub const JsRunner = struct {
383385
var app = try App.init(alloc, .{
384386
.run_mode = .serve,
385387
.tls_verify_host = false,
388+
.platform = opts.platform,
386389
});
387390
errdefer app.deinit();
388391

@@ -474,6 +477,7 @@ pub const JsRunner = struct {
474477
};
475478

476479
const RunnerOpts = struct {
480+
platform: ?*const Platform = null,
477481
url: []const u8 = "https://lightpanda.io/opensource-browser/",
478482
html: []const u8 =
479483
\\ <div id="content">

0 commit comments

Comments
 (0)