authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-10 14:39:03+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-18 17:10:04+01:00
loga0792e743ff41cf17343fad02bde54240df89419
tree5facade8d41874ac9f7979df22f260258fa0c5fa
parented7335ce570a2cf0099487067136a8d517902ea8
signaturelock-open Commit is signed but in an unrecognized format.

incr-check: normalize path separators in file names in errors


1 files changed, 12 insertions(+), 4 deletions(-)

tools/incr-check.zig+12-4
...@@ -364,7 +364,7 @@ const Eval = struct {...@@ -364,7 +364,7 @@ const Eval = struct {
364 error_bundle.renderToStdErr(color.renderOptions());364 error_bundle.renderToStdErr(color.renderOptions());
365 eval.fatal("update '{s}': more errors than expected", .{update.name});365 eval.fatal("update '{s}': more errors than expected", .{update.name});
366 }366 }
367 eval.checkOneError(update, error_bundle, expected.errors[expected_idx], false, err_idx);367 try eval.checkOneError(update, error_bundle, expected.errors[expected_idx], false, err_idx);
368 expected_idx += 1;368 expected_idx += 1;
369369
370 for (error_bundle.getNotes(err_idx)) |note_idx| {370 for (error_bundle.getNotes(err_idx)) |note_idx| {
...@@ -373,7 +373,7 @@ const Eval = struct {...@@ -373,7 +373,7 @@ const Eval = struct {
373 error_bundle.renderToStdErr(color.renderOptions());373 error_bundle.renderToStdErr(color.renderOptions());
374 eval.fatal("update '{s}': more error notes than expected", .{update.name});374 eval.fatal("update '{s}': more error notes than expected", .{update.name});
375 }375 }
376 eval.checkOneError(update, error_bundle, expected.errors[expected_idx], true, note_idx);376 try eval.checkOneError(update, error_bundle, expected.errors[expected_idx], true, note_idx);
377 expected_idx += 1;377 expected_idx += 1;
378 }378 }
379 }379 }
...@@ -392,13 +392,21 @@ const Eval = struct {...@@ -392,13 +392,21 @@ const Eval = struct {
392 expected: Case.ExpectedError,392 expected: Case.ExpectedError,
393 is_note: bool,393 is_note: bool,
394 err_idx: std.zig.ErrorBundle.MessageIndex,394 err_idx: std.zig.ErrorBundle.MessageIndex,
395 ) void {395 ) Allocator.Error!void {
396 const err = eb.getErrorMessage(err_idx);396 const err = eb.getErrorMessage(err_idx);
397 if (err.src_loc == .none) @panic("TODO error message with no source location");397 if (err.src_loc == .none) @panic("TODO error message with no source location");
398 if (err.count != 1) @panic("TODO error message with count>1");398 if (err.count != 1) @panic("TODO error message with count>1");
399 const msg = eb.nullTerminatedString(err.msg);399 const msg = eb.nullTerminatedString(err.msg);
400 const src = eb.getSourceLocation(err.src_loc);400 const src = eb.getSourceLocation(err.src_loc);
401 const filename = eb.nullTerminatedString(src.src_path);401 const raw_filename = eb.nullTerminatedString(src.src_path);
402
403 // We need to replace backslashes for consistency between platforms.
404 const filename = name: {
405 if (std.mem.indexOfScalar(u8, raw_filename, '\\') == null) break :name raw_filename;
406 const copied = try eval.arena.dupe(u8, raw_filename);
407 std.mem.replaceScalar(u8, copied, '\\', '/');
408 break :name copied;
409 };
402410
403 if (expected.is_note != is_note or411 if (expected.is_note != is_note or
404 !std.mem.eql(u8, expected.filename, filename) or412 !std.mem.eql(u8, expected.filename, filename) or