mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-02-10 22:24:52 +00:00
Merge pull request 'fix build errors in new Zig compiler' (#344) from prasefia/ziglings:main into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/344
This commit is contained in:
commit
d776e07af2
12
build.zig
12
build.zig
|
|
@ -5,7 +5,7 @@ const tests = @import("test/tests.zig");
|
||||||
const Build = std.Build;
|
const Build = std.Build;
|
||||||
const CompileStep = Build.CompileStep;
|
const CompileStep = Build.CompileStep;
|
||||||
const Step = Build.Step;
|
const Step = Build.Step;
|
||||||
const Child = std.process.Child;
|
const Process = std.process;
|
||||||
|
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const join = std.fs.path.join;
|
const join = std.fs.path.join;
|
||||||
|
|
@ -395,7 +395,7 @@ const ZiglingStep = struct {
|
||||||
// Allow up to 1 MB of stdout capture.
|
// Allow up to 1 MB of stdout capture.
|
||||||
const max_output_bytes = 1 * 1024 * 1024;
|
const max_output_bytes = 1 * 1024 * 1024;
|
||||||
|
|
||||||
const result = Child.run(b.allocator, io, .{
|
const result = Process.run(b.allocator, io, .{
|
||||||
.argv = &.{exe_path},
|
.argv = &.{exe_path},
|
||||||
.cwd = b.build_root.path.?,
|
.cwd = b.build_root.path.?,
|
||||||
.cwd_dir = b.build_root.handle,
|
.cwd_dir = b.build_root.handle,
|
||||||
|
|
@ -412,13 +412,13 @@ const ZiglingStep = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_output(self: *ZiglingStep, result: Child.RunResult) !void {
|
fn check_output(self: *ZiglingStep, result: Process.RunResult) !void {
|
||||||
const b = self.step.owner;
|
const b = self.step.owner;
|
||||||
const io = b.graph.io;
|
const io = b.graph.io;
|
||||||
|
|
||||||
// Make sure it exited cleanly.
|
// Make sure it exited cleanly.
|
||||||
switch (result.term) {
|
switch (result.term) {
|
||||||
.Exited => |code| {
|
.exited => |code| {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return self.step.fail("{s} exited with error code {d} (expected {})", .{
|
return self.step.fail("{s} exited with error code {d} (expected {})", .{
|
||||||
self.exercise.main_file, code, 0,
|
self.exercise.main_file, code, 0,
|
||||||
|
|
@ -475,9 +475,9 @@ const ZiglingStep = struct {
|
||||||
print("{s}PASSED:\n{s}{s}\n\n", .{ green_text, output, reset_text });
|
print("{s}PASSED:\n{s}{s}\n\n", .{ green_text, output, reset_text });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_test(self: *ZiglingStep, result: Child.RunResult) !void {
|
fn check_test(self: *ZiglingStep, result: Process.RunResult) !void {
|
||||||
switch (result.term) {
|
switch (result.term) {
|
||||||
.Exited => |code| {
|
.exited => |code| {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
// The test failed.
|
// The test failed.
|
||||||
const stderr = std.mem.trimEnd(u8, result.stderr, " \r\n");
|
const stderr = std.mem.trimEnd(u8, result.stderr, " \r\n");
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const fmt = std.fmt;
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
|
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const Child = std.process.Child;
|
const Process = std.process;
|
||||||
const Build = std.Build;
|
const Build = std.Build;
|
||||||
const Step = Build.Step;
|
const Step = Build.Step;
|
||||||
const RunStep = Build.RunStep;
|
const RunStep = Build.RunStep;
|
||||||
|
|
@ -396,8 +396,7 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8
|
||||||
|
|
||||||
const argv = &.{ "patch", "-i", patch, "-o", output, "-s", file };
|
const argv = &.{ "patch", "-i", patch, "-o", output, "-s", file };
|
||||||
|
|
||||||
var child = Child.init(argv, allocator);
|
_ = try Process.run(allocator, io, .{ .argv = argv });
|
||||||
_ = try child.spawnAndWait(io);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user