| ... | ... | @@ -28,6 +28,7 @@ test "self-hosted" { |
| 28 | 28 | |
| 29 | 29 | const ErrorMsg = union(enum) { |
| 30 | 30 | src: struct { |
| 31 | src_path: []const u8, |
| 31 | 32 | msg: []const u8, |
| 32 | 33 | line: u32, |
| 33 | 34 | column: u32, |
| ... | ... | @@ -47,6 +48,7 @@ const ErrorMsg = union(enum) { |
| 47 | 48 | switch (other) { |
| 48 | 49 | .src => |src| return .{ |
| 49 | 50 | .src = .{ |
| 51 | .src_path = src.src_path, |
| 50 | 52 | .msg = src.msg, |
| 51 | 53 | .line = @intCast(u32, src.line), |
| 52 | 54 | .column = @intCast(u32, src.column), |
| ... | ... | @@ -70,7 +72,8 @@ const ErrorMsg = union(enum) { |
| 70 | 72 | ) !void { |
| 71 | 73 | switch (self) { |
| 72 | 74 | .src => |src| { |
| 73 | | return writer.print(":{d}:{d}: {s}: {s}", .{ |
| 75 | return writer.print("{s}:{d}:{d}: {s}: {s}", .{ |
| 76 | src.src_path, |
| 74 | 77 | src.line + 1, |
| 75 | 78 | src.column + 1, |
| 76 | 79 | @tagName(src.kind), |
| ... | ... | @@ -188,9 +191,9 @@ pub const TestContext = struct { |
| 188 | 191 | }; |
| 189 | 192 | continue; |
| 190 | 193 | } |
| 191 | | // example: ":1:2: error: bad thing happened" |
| 194 | // example: "file.zig:1:2: error: bad thing happened" |
| 192 | 195 | var it = std.mem.split(err_msg_line, ":"); |
| 193 | | _ = it.next() orelse @panic("missing colon"); |
| 196 | const src_path = it.next() orelse @panic("missing colon"); |
| 194 | 197 | const line_text = it.next() orelse @panic("missing line"); |
| 195 | 198 | const col_text = it.next() orelse @panic("missing column"); |
| 196 | 199 | const kind_text = it.next() orelse @panic("missing 'error'/'note'"); |
| ... | ... | @@ -211,6 +214,7 @@ pub const TestContext = struct { |
| 211 | 214 | |
| 212 | 215 | array[i] = .{ |
| 213 | 216 | .src = .{ |
| 217 | .src_path = src_path, |
| 214 | 218 | .msg = msg, |
| 215 | 219 | .line = line - 1, |
| 216 | 220 | .column = column - 1, |
| ... | ... | @@ -692,8 +696,8 @@ pub const TestContext = struct { |
| 692 | 696 | for (all_errors.list) |err_msg| { |
| 693 | 697 | switch (err_msg) { |
| 694 | 698 | .src => |src| { |
| 695 | | std.debug.print(":{d}:{d}: error: {s}\n{s}\n", .{ |
| 696 | | src.line + 1, src.column + 1, src.msg, hr, |
| 699 | std.debug.print("{s}:{d}:{d}: error: {s}\n{s}\n", .{ |
| 700 | src.src_path, src.line + 1, src.column + 1, src.msg, hr, |
| 697 | 701 | }); |
| 698 | 702 | }, |
| 699 | 703 | .plain => |plain| { |
| ... | ... | @@ -747,7 +751,11 @@ pub const TestContext = struct { |
| 747 | 751 | |
| 748 | 752 | if (ex_tag != .src) continue; |
| 749 | 753 | |
| 750 | | if (actual_msg.line == case_msg.src.line and |
| 754 | const src_path_ok = case_msg.src.src_path.len == 0 or |
| 755 | std.mem.eql(u8, case_msg.src.src_path, actual_msg.src_path); |
| 756 | |
| 757 | if (src_path_ok and |
| 758 | actual_msg.line == case_msg.src.line and |
| 751 | 759 | actual_msg.column == case_msg.src.column and |
| 752 | 760 | std.mem.eql(u8, case_msg.src.msg, actual_msg.msg) and |
| 753 | 761 | case_msg.src.kind == .@"error") |
| ... | ... | @@ -959,7 +967,6 @@ pub const TestContext = struct { |
| 959 | 967 | } |
| 960 | 968 | } |
| 961 | 969 | } |
| 962 | | |
| 963 | 970 | }; |
| 964 | 971 | |
| 965 | 972 | fn dumpArgs(argv: []const []const u8) void { |