From 1cf0fc71ea038553882bb638593213778a61b583 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 15 Dec 2023 11:10:38 +0100 Subject: [PATCH 1/3] wpt: unskip test --- .../{Node-removeChild.html.skip => Node-removeChild.html} | 0 tests/wpt/dom/nodes/creators.js | 5 +++++ 2 files changed, 5 insertions(+) rename tests/wpt/dom/nodes/{Node-removeChild.html.skip => Node-removeChild.html} (100%) create mode 100644 tests/wpt/dom/nodes/creators.js diff --git a/tests/wpt/dom/nodes/Node-removeChild.html.skip b/tests/wpt/dom/nodes/Node-removeChild.html similarity index 100% rename from tests/wpt/dom/nodes/Node-removeChild.html.skip rename to tests/wpt/dom/nodes/Node-removeChild.html diff --git a/tests/wpt/dom/nodes/creators.js b/tests/wpt/dom/nodes/creators.js new file mode 100644 index 00000000..8b7415d1 --- /dev/null +++ b/tests/wpt/dom/nodes/creators.js @@ -0,0 +1,5 @@ +var creators = { + "element": "createElement", + "text": "createTextNode", + "comment": "createComment" +}; From 1e739af4e4c15a5e1dd0c8b5dd910649d9b821a5 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 15 Dec 2023 11:28:28 +0100 Subject: [PATCH 2/3] wpt: use std.ChildProcess.run --- src/main_wpt.zig | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main_wpt.zig b/src/main_wpt.zig index f6d56244..7755f158 100644 --- a/src/main_wpt.zig +++ b/src/main_wpt.zig @@ -268,24 +268,17 @@ fn runSafe( continue; } + // append the test case to argv and pop it before next loop. argv.appendAssumeCapacity(tc); defer _ = argv.pop(); - // TODO use std.ChildProcess.run after next zig upgrade. - var child = std.ChildProcess.init(argv.items, alloc); - child.stdin_behavior = .Ignore; - child.stdout_behavior = .Pipe; - child.stderr_behavior = .Pipe; - - var stdout = std.ArrayList(u8).init(alloc); - var stderr = std.ArrayList(u8).init(alloc); - - try child.spawn(); - try child.collectOutput(&stdout, &stderr, 1024 * 1024); - const term = try child.wait(); + const run = try std.ChildProcess.run(.{ + .allocator = alloc, + .argv = argv.items, + }); var result: Result = undefined; - switch (term) { + switch (run.term) { .Exited => |v| { if (v == 0) { result = .pass; @@ -313,7 +306,7 @@ fn runSafe( var cases = [_]Case{.{ .pass = false, .name = "crash", - .message = stderr.items, + .message = run.stderr, }}; try output.append(Test{ .pass = false, @@ -324,12 +317,12 @@ fn runSafe( continue; } - const jp = try std.json.parseFromSlice([]Test, alloc, stdout.items, .{}); + const jp = try std.json.parseFromSlice([]Test, alloc, run.stdout, .{}); try output.appendSlice(jp.value); continue; } - std.debug.print("{s}\n", .{stderr.items}); + std.debug.print("{s}\n", .{run.stderr}); } if (out == .json) { From e04bbc2ace81dd0adc1f647e1491e044ddc7e132 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Fri, 15 Dec 2023 11:58:54 +0100 Subject: [PATCH 3/3] wpt: summary includes pass cases number --- src/main_wpt.zig | 56 +++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/main_wpt.zig b/src/main_wpt.zig index 7755f158..9cc30200 100644 --- a/src/main_wpt.zig +++ b/src/main_wpt.zig @@ -249,17 +249,15 @@ fn runSafe( const alloc = arena.allocator(); const Result = enum { - pass, - fail, + success, crash, }; var argv = try std.ArrayList([]const u8).initCapacity(alloc, 3); defer argv.deinit(); argv.appendAssumeCapacity(execname); - if (out == .json) { - argv.appendAssumeCapacity("--json"); - } + // always require json output to count test cases results + argv.appendAssumeCapacity("--json"); var output = std.ArrayList(Test).init(alloc); @@ -275,29 +273,40 @@ fn runSafe( const run = try std.ChildProcess.run(.{ .allocator = alloc, .argv = argv.items, + .max_output_bytes = 1024 * 1024, }); - var result: Result = undefined; - switch (run.term) { - .Exited => |v| { - if (v == 0) { - result = .pass; - } else { - result = .fail; - } - }, - .Signal => result = .crash, - .Stopped => result = .crash, - .Unknown => result = .crash, + const result: Result = switch (run.term) { + .Exited => .success, + else => .crash, + }; + + // read the JSON result from stdout + var tests: []Test = undefined; + if (result != .crash) { + const parsed = try std.json.parseFromSlice([]Test, alloc, run.stdout, .{}); + tests = parsed.value; } if (out == .summary) { - switch (result) { - .pass => std.debug.print("Pass", .{}), - .fail => std.debug.print("Fail", .{}), - .crash => std.debug.print("Crash", .{}), + defer std.debug.print("\t{s}\n", .{tc}); + if (result == .crash) { + std.debug.print("Crash\t", .{}); + continue; } - std.debug.print("\t{s}\n", .{tc}); + + // count results + var pass: u32 = 0; + var all: u32 = 0; + for (tests) |ttc| { + for (ttc.cases) |c| { + all += 1; + if (c.pass) pass += 1; + } + } + const status = if (pass == all) "Pass" else "Fail"; + std.debug.print("{s} {d}/{d}", .{ status, pass, all }); + continue; } @@ -317,8 +326,7 @@ fn runSafe( continue; } - const jp = try std.json.parseFromSlice([]Test, alloc, run.stdout, .{}); - try output.appendSlice(jp.value); + try output.appendSlice(tests); continue; }