Skip to content

Commit 834693c

Browse files
committed
incr-check: normalize path separators in file names in errors
1 parent 1053505 commit 834693c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tools/incr-check.zig

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ const Eval = struct {
364364
error_bundle.renderToStdErr(color.renderOptions());
365365
eval.fatal("update '{s}': more errors than expected", .{update.name});
366366
}
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);
368368
expected_idx += 1;
369369

370370
for (error_bundle.getNotes(err_idx)) |note_idx| {
@@ -373,7 +373,7 @@ const Eval = struct {
373373
error_bundle.renderToStdErr(color.renderOptions());
374374
eval.fatal("update '{s}': more error notes than expected", .{update.name});
375375
}
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);
377377
expected_idx += 1;
378378
}
379379
}
@@ -392,13 +392,21 @@ const Eval = struct {
392392
expected: Case.ExpectedError,
393393
is_note: bool,
394394
err_idx: std.zig.ErrorBundle.MessageIndex,
395-
) void {
395+
) Allocator.Error!void {
396396
const err = eb.getErrorMessage(err_idx);
397397
if (err.src_loc == .none) @panic("TODO error message with no source location");
398398
if (err.count != 1) @panic("TODO error message with count>1");
399399
const msg = eb.nullTerminatedString(err.msg);
400400
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

403411
if (expected.is_note != is_note or
404412
!std.mem.eql(u8, expected.filename, filename) or

0 commit comments

Comments
 (0)