mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
25 lines
990 B
Zig
25 lines
990 B
Zig
pub fn main(init: std.process.Init) !void {
|
|
const arena = init.arena.allocator();
|
|
const io = init.io;
|
|
const args = try init.minimal.args.toSlice(arena);
|
|
|
|
if (args.len != 3) return error.BadUsage;
|
|
const actual_path = args[1];
|
|
const expected_path = args[2];
|
|
|
|
const actual = try std.Io.Dir.cwd().readFileAlloc(io, actual_path, arena, .limited(1024 * 1024));
|
|
const expected = try std.Io.Dir.cwd().readFileAlloc(io, expected_path, arena, .limited(1024 * 1024));
|
|
|
|
// The actual output starts with a comment which we should strip out before comparing.
|
|
const comment_str = "/* This file was generated by ConfigHeader using the Zig Build System. */\n";
|
|
if (!std.mem.startsWith(u8, actual, comment_str)) {
|
|
return error.MissingOrMalformedComment;
|
|
}
|
|
const actual_without_comment = actual[comment_str.len..];
|
|
|
|
if (!std.mem.eql(u8, actual_without_comment, expected)) {
|
|
return error.DoesNotMatch;
|
|
}
|
|
}
|
|
const std = @import("std");
|