diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-05-10 14:39:03 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-05-18 17:10:04 +0100 |
| commit | a0792e743ff41cf17343fad02bde54240df89419 (patch) | |
| tree | 5facade8d41874ac9f7979df22f260258fa0c5fa /tools | |
| parent | ed7335ce570a2cf0099487067136a8d517902ea8 (diff) | |
| download | zig-a0792e743ff41cf17343fad02bde54240df89419.tar.gz zig-a0792e743ff41cf17343fad02bde54240df89419.zip | |
incr-check: normalize path separators in file names in errors
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/incr-check.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/incr-check.zig b/tools/incr-check.zig index d5cdeb7bfd..6e69b93b96 100644 --- a/tools/incr-check.zig +++ b/tools/incr-check.zig @@ -364,7 +364,7 @@ const Eval = struct { error_bundle.renderToStdErr(color.renderOptions()); eval.fatal("update '{s}': more errors than expected", .{update.name}); } - eval.checkOneError(update, error_bundle, expected.errors[expected_idx], false, err_idx); + try eval.checkOneError(update, error_bundle, expected.errors[expected_idx], false, err_idx); expected_idx += 1; for (error_bundle.getNotes(err_idx)) |note_idx| { @@ -373,7 +373,7 @@ const Eval = struct { error_bundle.renderToStdErr(color.renderOptions()); eval.fatal("update '{s}': more error notes than expected", .{update.name}); } - eval.checkOneError(update, error_bundle, expected.errors[expected_idx], true, note_idx); + try eval.checkOneError(update, error_bundle, expected.errors[expected_idx], true, note_idx); expected_idx += 1; } } @@ -392,13 +392,21 @@ const Eval = struct { expected: Case.ExpectedError, is_note: bool, err_idx: std.zig.ErrorBundle.MessageIndex, - ) void { + ) Allocator.Error!void { const err = eb.getErrorMessage(err_idx); if (err.src_loc == .none) @panic("TODO error message with no source location"); if (err.count != 1) @panic("TODO error message with count>1"); const msg = eb.nullTerminatedString(err.msg); const src = eb.getSourceLocation(err.src_loc); - const filename = eb.nullTerminatedString(src.src_path); + const raw_filename = eb.nullTerminatedString(src.src_path); + + // We need to replace backslashes for consistency between platforms. + const filename = name: { + if (std.mem.indexOfScalar(u8, raw_filename, '\\') == null) break :name raw_filename; + const copied = try eval.arena.dupe(u8, raw_filename); + std.mem.replaceScalar(u8, copied, '\\', '/'); + break :name copied; + }; if (expected.is_note != is_note or !std.mem.eql(u8, expected.filename, filename) or |
