authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-25 08:11:00+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-25 08:57:20+00:00
log7ef345f342534f93a7e61d9ecd096523f048871d
tree6a780b3130783fd9d3f8fe2c6dd6b367e1069841
parentf47b8de2ad706616b648c52f5036102cb804e65d
signature Commit is signed but in an unrecognized format.

incr-check: deal with Windows stupidity

The real problem here is that Git for Windows has horrendous defaults which convert LF to CRLF. However, rather than changing this configuration on the CI runners, it's worth supporting inexplicable CRLF in these files so that anyone else cloning Zig on Windows doesn't get unexpected test failures.

1 files changed, 15 insertions(+), 8 deletions(-)

tools/incr-check.zig+15-8
......@@ -660,21 +660,28 @@ const Case = struct {
660660 if (root_source_file == null)
661661 root_source_file = val;
662662
663 const start_index = it.index.?;
664 const src = while (true) : (line_n += 1) {
663 // Because Windows is so excellent, we need to convert CRLF to LF, so
664 // can't just slice into the input here. How delightful!
665 var src: std.ArrayListUnmanaged(u8) = .empty;
666
667 while (true) {
665668 const old = it;
666 const next_line = it.next() orelse fatal("line {d}: unexpected EOF", .{line_n});
669 const next_line_raw = it.next() orelse fatal("line {d}: unexpected EOF", .{line_n});
670 const next_line = std.mem.trimRight(u8, next_line_raw, "\r");
667671 if (std.mem.startsWith(u8, next_line, "#")) {
668 const end_index = old.index.?;
669 const src = bytes[start_index..end_index];
670672 it = old;
671 break src;
673 break;
672674 }
673 };
675 line_n += 1;
676
677 try src.ensureUnusedCapacity(arena, next_line.len + 1);
678 src.appendSliceAssumeCapacity(next_line);
679 src.appendAssumeCapacity('\n');
680 }
674681
675682 try changes.append(arena, .{
676683 .name = val,
677 .bytes = src,
684 .bytes = src.items,
678685 });
679686 } else if (std.mem.eql(u8, key, "rm_file")) {
680687 if (updates.items.len == 0) fatal("line {d}: rm_file directive before update", .{line_n});