mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 07:48:58 +00:00
wpt: use std.ChildProcess.run
This commit is contained in:
@@ -268,24 +268,17 @@ 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;
|
});
|
||||||
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();
|
|
||||||
|
|
||||||
var result: Result = undefined;
|
var result: Result = undefined;
|
||||||
switch (term) {
|
switch (run.term) {
|
||||||
.Exited => |v| {
|
.Exited => |v| {
|
||||||
if (v == 0) {
|
if (v == 0) {
|
||||||
result = .pass;
|
result = .pass;
|
||||||
@@ -313,7 +306,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 +317,12 @@ fn runSafe(
|
|||||||
continue;
|
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);
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user