From 8321aa42c7ee2dc6ac4ca7b936ad6cd8270a279e Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 10 Oct 2023 17:05:31 +0200 Subject: [PATCH] wpt: create a command instead of a test --- build.zig | 24 +++++++++++++++++------- src/run_wpt.zig | 10 ++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/build.zig b/build.zig index 21da0049..0a50bfff 100644 --- a/build.zig +++ b/build.zig @@ -73,18 +73,28 @@ pub fn build(b: *std.build.Builder) !void { const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_tests.step); - // wpt tests + // wpt // ----- - // compile - const wpt = b.addTest(.{ .root_source_file = .{ .path = "src/run_wpt.zig" } }); + // compile and install + const wpt = b.addExecutable(.{ + .name = "browsercore-wpt", + .root_source_file = .{ .path = "src/run_wpt.zig" }, + .target = target, + .optimize = mode, + }); try common(wpt, options); - wpt.single_threaded = true; - const run_wpt = b.addRunArtifact(wpt); + b.installArtifact(wpt); + // run + const wpt_cmd = b.addRunArtifact(wpt); + wpt_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + wpt_cmd.addArgs(args); + } // step - const wpt_step = b.step("wpt", "Run Web Platform Tests"); - wpt_step.dependOn(&run_wpt.step); + const wpt_step = b.step("wpt", "WPT tests"); + wpt_step.dependOn(&wpt_cmd.step); } fn common( diff --git a/src/run_wpt.zig b/src/run_wpt.zig index 7bf60ab1..dacc5568 100644 --- a/src/run_wpt.zig +++ b/src/run_wpt.zig @@ -63,10 +63,12 @@ const FileLoader = struct { // the HTML page. // Once browsercore will have the html loader, it would be useful to refacto // this test to use it. -test "WPT tests suite" { +pub fn main() !void { std.debug.print("Running WPT test suite\n", .{}); - const alloc = std.testing.allocator; + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const alloc = gpa.allocator(); // initialize VM JS lib. const vm = jsruntime.VM.init(); @@ -92,7 +94,7 @@ test "WPT tests suite" { run += 1; // create an arena and deinit it for each test case. - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); + var arena = std.heap.ArenaAllocator.init(alloc); defer arena.deinit(); // TODO I don't use testing.expect here b/c I want to execute all the @@ -120,8 +122,8 @@ test "WPT tests suite" { if (failures > 0) { std.debug.print("{d}/{d} tests failures\n", .{ failures, run }); + std.os.exit(1); } - try std.testing.expect(failures == 0); } // runWPT parses the given HTML file, starts a js env and run the first script