From 8c3939b842dda616844c2518914f83591a4a8d77 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 18 Jul 2024 16:51:36 +0200 Subject: [PATCH] wpt: remove useless Suite.stack --- src/main_wpt.zig | 6 +++--- src/wpt/testcase.zig | 23 +++++------------------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/main_wpt.zig b/src/main_wpt.zig index c19598b2..c8790254 100644 --- a/src/main_wpt.zig +++ b/src/main_wpt.zig @@ -142,7 +142,7 @@ pub fn main() !void { defer arena.deinit(); const res = wpt.run(&arena, wpt_dir, tc, &loader) catch |err| { - const suite = try Suite.init(alloc, tc, false, @errorName(err), null); + const suite = try Suite.init(alloc, tc, false, @errorName(err)); try results.append(suite); if (out == .text) { @@ -153,7 +153,7 @@ pub fn main() !void { }; defer res.deinit(arena.allocator()); - const suite = try Suite.init(alloc, tc, res.ok, res.msg orelse "", null); + const suite = try Suite.init(alloc, tc, res.ok, res.msg orelse ""); try results.append(suite); if (out == .json) { @@ -196,7 +196,7 @@ pub fn main() !void { try cases.append(Case{ .pass = suite.pass, .name = suite.name, - .message = suite.stack orelse suite.message, + .message = suite.message, }); } diff --git a/src/wpt/testcase.zig b/src/wpt/testcase.zig index 6c006e4a..1f3e0915 100644 --- a/src/wpt/testcase.zig +++ b/src/wpt/testcase.zig @@ -67,28 +67,22 @@ pub const Suite = struct { pass: bool, name: []const u8, message: ?[]const u8, - stack: ?[]const u8, cases: ?[]Case, // caller owns the wpt.Suite. // owner must call deinit(). - pub fn init(alloc: std.mem.Allocator, name: []const u8, pass: bool, res: []const u8, stack: ?[]const u8) !Suite { + pub fn init(alloc: std.mem.Allocator, name: []const u8, pass: bool, res: []const u8) !Suite { var suite = Suite{ .alloc = alloc, .pass = false, .name = try alloc.dupe(u8, name), .message = null, - .stack = null, .cases = null, }; // handle JS error. if (!pass) { suite.message = try alloc.dupe(u8, res); - if (stack) |st| { - suite.stack = try alloc.dupe(u8, st); - } - return suite; } @@ -155,10 +149,6 @@ pub const Suite = struct { pub fn deinit(self: Suite) void { self.alloc.free(self.name); - if (self.stack) |stack| { - self.alloc.free(stack); - } - if (self.message) |res| { self.alloc.free(res); } @@ -175,9 +165,6 @@ pub const Suite = struct { if (self.message) |v| { return v; } - if (self.stack) |v| { - return v; - } return ""; } }; @@ -199,7 +186,7 @@ test "success test case" { , }; - const suite = Suite.init(alloc, "foo", res.pass, res.result, null) catch unreachable; // TODO + const suite = Suite.init(alloc, "foo", res.pass, res.result) catch unreachable; // TODO defer suite.deinit(); try testing.expect(suite.pass == true); @@ -226,7 +213,7 @@ test "failed test case" { , }; - const suite = Suite.init(alloc, "foo", res.pass, res.result, null) catch unreachable; // TODO + const suite = Suite.init(alloc, "foo", res.pass, res.result) catch unreachable; // TODO defer suite.deinit(); try testing.expect(suite.pass == false); @@ -251,7 +238,7 @@ test "invalid result" { , }; - const suite = Suite.init(alloc, "foo", res.pass, res.result, null) catch unreachable; // TODO + const suite = Suite.init(alloc, "foo", res.pass, res.result) catch unreachable; // TODO defer suite.deinit(); try testing.expect(suite.pass == false); @@ -266,7 +253,7 @@ test "invalid result" { , }; - const suite2 = Suite.init(alloc, "foo", res2.pass, res2.result, null) catch unreachable; // TODO + const suite2 = Suite.init(alloc, "foo", res2.pass, res2.result) catch unreachable; // TODO defer suite2.deinit(); try testing.expect(suite2.pass == false);