| ... | ... | @@ -110,20 +110,25 @@ pub const TestContext = struct { |
| 110 | 110 | pub fn addError(self: *ZIRCase, src: [:0]const u8, errors: []const []const u8) void { |
| 111 | 111 | var array = self.updates.allocator.alloc(ErrorMsg, errors.len) catch unreachable; |
| 112 | 112 | for (errors) |e, i| { |
| 113 | if (e[0] != ':') { |
| 114 | std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{}); |
| 115 | } |
| 113 | 116 | var cur = e[1..]; |
| 114 | 117 | var line_index = std.mem.indexOf(u8, cur, ":"); |
| 115 | 118 | if (line_index == null) { |
| 116 | | std.debug.panic("Invalid test: error must be specified as ':line:column: error: msg', found '{}'", .{e}); |
| 119 | std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{}); |
| 117 | 120 | } |
| 118 | 121 | const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number"); |
| 119 | 122 | cur = cur[line_index.? + 1 ..]; |
| 120 | 123 | const column_index = std.mem.indexOf(u8, cur, ":"); |
| 121 | 124 | if (column_index == null) { |
| 122 | | std.debug.panic("Invalid test: error must be specified as ':line:column: error: msg', found '{}'", .{e}); |
| 125 | std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{}); |
| 123 | 126 | } |
| 124 | 127 | const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number"); |
| 125 | 128 | cur = cur[column_index.? + 2 ..]; |
| 126 | | std.debug.assert(std.mem.eql(u8, cur[0..7], "error: ")); |
| 129 | if (!std.mem.eql(u8, cur[0..7], "error: ")) { |
| 130 | std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{}); |
| 131 | } |
| 127 | 132 | const msg = cur[7..]; |
| 128 | 133 | |
| 129 | 134 | if (line == 0 or column == 0) { |
| ... | ... | @@ -312,7 +317,7 @@ pub const TestContext = struct { |
| 312 | 317 | break; |
| 313 | 318 | } |
| 314 | 319 | } else { |
| 315 | | std.debug.warn("{}\nUnexpected error:\n================\n{}:{}: {}\n================\nTest failed.\n", .{ case.name, a.line + 1, a.column + 1, a.msg }); |
| 320 | std.debug.warn("{}\nUnexpected error:\n================\n:{}:{}: error: {}\n================\nTest failed.\n", .{ case.name, a.line + 1, a.column + 1, a.msg }); |
| 316 | 321 | std.process.exit(1); |
| 317 | 322 | } |
| 318 | 323 | } |