mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Merge pull request #135 from lightpanda-io/wpt-imp
wpt: better summary output
This commit is contained in:
@@ -249,17 +249,15 @@ fn runSafe(
|
|||||||
const alloc = arena.allocator();
|
const alloc = arena.allocator();
|
||||||
|
|
||||||
const Result = enum {
|
const Result = enum {
|
||||||
pass,
|
success,
|
||||||
fail,
|
|
||||||
crash,
|
crash,
|
||||||
};
|
};
|
||||||
|
|
||||||
var argv = try std.ArrayList([]const u8).initCapacity(alloc, 3);
|
var argv = try std.ArrayList([]const u8).initCapacity(alloc, 3);
|
||||||
defer argv.deinit();
|
defer argv.deinit();
|
||||||
argv.appendAssumeCapacity(execname);
|
argv.appendAssumeCapacity(execname);
|
||||||
if (out == .json) {
|
// always require json output to count test cases results
|
||||||
argv.appendAssumeCapacity("--json");
|
argv.appendAssumeCapacity("--json");
|
||||||
}
|
|
||||||
|
|
||||||
var output = std.ArrayList(Test).init(alloc);
|
var output = std.ArrayList(Test).init(alloc);
|
||||||
|
|
||||||
@@ -268,43 +266,47 @@ fn runSafe(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// append the test case to argv and pop it before next loop.
|
||||||
argv.appendAssumeCapacity(tc);
|
argv.appendAssumeCapacity(tc);
|
||||||
defer _ = argv.pop();
|
defer _ = argv.pop();
|
||||||
|
|
||||||
// TODO use std.ChildProcess.run after next zig upgrade.
|
const run = try std.ChildProcess.run(.{
|
||||||
var child = std.ChildProcess.init(argv.items, alloc);
|
.allocator = alloc,
|
||||||
child.stdin_behavior = .Ignore;
|
.argv = argv.items,
|
||||||
child.stdout_behavior = .Pipe;
|
.max_output_bytes = 1024 * 1024,
|
||||||
child.stderr_behavior = .Pipe;
|
});
|
||||||
|
|
||||||
var stdout = std.ArrayList(u8).init(alloc);
|
const result: Result = switch (run.term) {
|
||||||
var stderr = std.ArrayList(u8).init(alloc);
|
.Exited => .success,
|
||||||
|
else => .crash,
|
||||||
|
};
|
||||||
|
|
||||||
try child.spawn();
|
// read the JSON result from stdout
|
||||||
try child.collectOutput(&stdout, &stderr, 1024 * 1024);
|
var tests: []Test = undefined;
|
||||||
const term = try child.wait();
|
if (result != .crash) {
|
||||||
|
const parsed = try std.json.parseFromSlice([]Test, alloc, run.stdout, .{});
|
||||||
var result: Result = undefined;
|
tests = parsed.value;
|
||||||
switch (term) {
|
|
||||||
.Exited => |v| {
|
|
||||||
if (v == 0) {
|
|
||||||
result = .pass;
|
|
||||||
} else {
|
|
||||||
result = .fail;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.Signal => result = .crash,
|
|
||||||
.Stopped => result = .crash,
|
|
||||||
.Unknown => result = .crash,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out == .summary) {
|
if (out == .summary) {
|
||||||
switch (result) {
|
defer std.debug.print("\t{s}\n", .{tc});
|
||||||
.pass => std.debug.print("Pass", .{}),
|
if (result == .crash) {
|
||||||
.fail => std.debug.print("Fail", .{}),
|
std.debug.print("Crash\t", .{});
|
||||||
.crash => std.debug.print("Crash", .{}),
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +315,7 @@ fn runSafe(
|
|||||||
var cases = [_]Case{.{
|
var cases = [_]Case{.{
|
||||||
.pass = false,
|
.pass = false,
|
||||||
.name = "crash",
|
.name = "crash",
|
||||||
.message = stderr.items,
|
.message = run.stderr,
|
||||||
}};
|
}};
|
||||||
try output.append(Test{
|
try output.append(Test{
|
||||||
.pass = false,
|
.pass = false,
|
||||||
@@ -324,12 +326,11 @@ fn runSafe(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const jp = try std.json.parseFromSlice([]Test, alloc, stdout.items, .{});
|
try output.appendSlice(tests);
|
||||||
try output.appendSlice(jp.value);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std.debug.print("{s}\n", .{stderr.items});
|
std.debug.print("{s}\n", .{run.stderr});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out == .json) {
|
if (out == .json) {
|
||||||
|
|||||||
5
tests/wpt/dom/nodes/creators.js
Normal file
5
tests/wpt/dom/nodes/creators.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var creators = {
|
||||||
|
"element": "createElement",
|
||||||
|
"text": "createTextNode",
|
||||||
|
"comment": "createComment"
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user