master
1pub fn main() !void {
2 var arena_state: std.heap.ArenaAllocator = .init(std.heap.page_allocator);
3 defer arena_state.deinit();
4 const arena = arena_state.allocator();
5
6 const args = try std.process.argsAlloc(arena);
7
8 if (args.len != 3) return error.BadUsage;
9 const actual_path = args[1];
10 const expected_path = args[2];
11
12 const actual = try std.fs.cwd().readFileAlloc(actual_path, arena, .limited(1024 * 1024));
13 const expected = try std.fs.cwd().readFileAlloc(expected_path, arena, .limited(1024 * 1024));
14
15 // The actual output starts with a comment which we should strip out before comparing.
16 const comment_str = "/* This file was generated by ConfigHeader using the Zig Build System. */\n";
17 if (!std.mem.startsWith(u8, actual, comment_str)) {
18 return error.MissingOrMalformedComment;
19 }
20 const actual_without_comment = actual[comment_str.len..];
21
22 if (!std.mem.eql(u8, actual_without_comment, expected)) {
23 return error.DoesNotMatch;
24 }
25}
26const std = @import("std");