| ... | @@ -110,20 +110,25 @@ pub const TestContext = struct { | ... | @@ -110,20 +110,25 @@ pub const TestContext = struct { |
| 110 | pub fn addError(self: *ZIRCase, src: [:0]const u8, errors: []const []const u8) void { | 110 | pub fn addError(self: *ZIRCase, src: [:0]const u8, errors: []const []const u8) void { |
| 111 | var array = self.updates.allocator.alloc(ErrorMsg, errors.len) catch unreachable; | 111 | var array = self.updates.allocator.alloc(ErrorMsg, errors.len) catch unreachable; |
| 112 | for (errors) |e, i| { | 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 | var cur = e[1..]; | 116 | var cur = e[1..]; |
| 114 | var line_index = std.mem.indexOf(u8, cur, ":"); | 117 | var line_index = std.mem.indexOf(u8, cur, ":"); |
| 115 | if (line_index == null) { | 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 | const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number"); | 121 | const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number"); |
| 119 | cur = cur[line_index.? + 1 ..]; | 122 | cur = cur[line_index.? + 1 ..]; |
| 120 | const column_index = std.mem.indexOf(u8, cur, ":"); | 123 | const column_index = std.mem.indexOf(u8, cur, ":"); |
| 121 | if (column_index == null) { | 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 | const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number"); | 127 | const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number"); |
| 125 | cur = cur[column_index.? + 2 ..]; | 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 | const msg = cur[7..]; | 132 | const msg = cur[7..]; |
| 128 | | 133 | |
| 129 | if (line == 0 or column == 0) { | 134 | if (line == 0 or column == 0) { |
| ... | @@ -312,7 +317,7 @@ pub const TestContext = struct { | ... | @@ -312,7 +317,7 @@ pub const TestContext = struct { |
| 312 | break; | 317 | break; |
| 313 | } | 318 | } |
| 314 | } else { | 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 | std.process.exit(1); | 321 | std.process.exit(1); |
| 317 | } | 322 | } |
| 318 | } | 323 | } |