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