authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-04 16:12:09-04:00
committergravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-15 20:33:17-04:00
loge77fc7fe7e3d6e5e4dc89bbc8fa95e65d4134b9f
treec12eb145645249cf3f4e04655dc15c782c78cc40
parent6dce317fe39443278ee744e66118c6e9b6023615
signaturelock-open Commit is signed but in an unrecognized format.

Stage2/Testing: Fix error specification


2 files changed, 7 insertions(+), 11 deletions(-)

src-self-hosted/test.zig+5-9
......@@ -200,24 +200,20 @@ pub const TestContext = struct {
200200 var array = std.ArrayList(ErrorMsg).init(ctx.zir_error_cases.allocator);
201201 for (expected_errors) |e| {
202202 var cur = e;
203 const err = cur[0..7];
204 if (!std.mem.eql(u8, err, "error: ")) {
205 std.debug.panic("Only error messages are currently supported, received {}\n", .{e});
206 }
207 cur = cur[7..];
208203 var line_index = std.mem.indexOf(u8, cur, ":");
209204 if (line_index == null) {
210 std.debug.panic("Invalid test: error must be specified as 'error: line:column: msg', found '{}'", .{e});
205 std.debug.panic("Invalid test: error must be specified as 'line:column: error: msg', found '{}'", .{e});
211206 }
212207 const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");
213208 cur = cur[line_index.? + 1 ..];
214209 const column_index = std.mem.indexOf(u8, cur, ":");
215210 if (column_index == null) {
216 std.debug.panic("Invalid test: error must be specified as 'error: line:column: msg', found '{}'", .{e});
211 std.debug.panic("Invalid test: error must be specified as 'line:column: error: msg', found '{}'", .{e});
217212 }
218213 const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number");
219 std.debug.assert(cur[column_index.? + 1] == ' ');
220 const msg = cur[column_index.? + 2 ..];
214 cur = cur[column_index.? + 2 ..];
215 std.debug.assert(std.mem.eql(u8, cur[0..7], "error: "));
216 const msg = cur[7..];
221217
222218 if (line == 0 or column == 0) {
223219 @panic("Invalid test: error line and column must be specified starting at one!");
test/stage2/compile_errors.zig+2-2
......@@ -18,7 +18,7 @@ pub fn addCases(ctx: *TestContext) !void {
1818 \\@start = fn(@start_fnty, {
1919 \\ %0 = call(%test, [])
2020 \\})
21 , &[_][]const u8{"error: 5:13: unrecognized identifier: %test"});
21 , &[_][]const u8{"5:13: error: unrecognized identifier: %test"});
2222
2323 // TODO: fix this test
2424 // ctx.addZIRError("call with non-existent target", linux_x64,
......@@ -45,7 +45,7 @@ pub fn addCases(ctx: *TestContext) !void {
4545 \\@0 = str("_start")
4646 \\@1 = ref(@0)
4747 \\@2 = export(@1, @start)
48 , &[_][]const u8{"error: 4:9: unable to call function with naked calling convention"});
48 , &[_][]const u8{"4:9: error: unable to call function with naked calling convention"});
4949
5050 //try ctx.testCompileError(
5151 // \\export fn entry() void {}