zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit eb8201afde98d9ba35d0c8488d418b1b0bef4f35 (tree)
parent af7afbd08b9c74c0d65ddda9f495e497c4c5e5a1
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 16 Jun 2024 19:30:14 -0700

std.Build.Step.Fmt: display non-conforming files

When in --check mode, and files are found to not conform, emit them
explicitly as step errors. Previously this stdout data was being
ignored.

Diffstat:
Mlib/std/Build/Step/Fmt.zig | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/std/Build/Step/Fmt.zig b/lib/std/Build/Step/Fmt.zig @@ -37,9 +37,6 @@ pub fn create(owner: *std.Build, options: Options) *Fmt { } fn make(step: *Step, prog_node: std.Progress.Node) !void { - // zig fmt is fast enough that no progress is needed. - _ = prog_node; - // TODO: if check=false, this means we are modifying source files in place, which // is an operation that could race against other operations also modifying source files // in place. In this case, this step should obtain a write lock while making those @@ -68,5 +65,15 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { argv.appendAssumeCapacity(b.pathFromRoot(p)); } - return step.evalChildProcess(argv.items); + const run_result = try step.captureChildProcess(prog_node, argv.items); + if (fmt.check) switch (run_result.term) { + .Exited => |code| if (code != 0 and run_result.stdout.len != 0) { + var it = std.mem.tokenizeScalar(u8, run_result.stdout, '\n'); + while (it.next()) |bad_file_name| { + try step.addError("{s}: non-conforming formatting", .{bad_file_name}); + } + }, + else => {}, + }; + try step.handleChildProcessTerm(run_result.term, null, argv.items); }