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 {...@@ -200,24 +200,20 @@ pub const TestContext = struct {
200 var array = std.ArrayList(ErrorMsg).init(ctx.zir_error_cases.allocator);200 var array = std.ArrayList(ErrorMsg).init(ctx.zir_error_cases.allocator);
201 for (expected_errors) |e| {201 for (expected_errors) |e| {
202 var cur = e;202 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..];
208 var line_index = std.mem.indexOf(u8, cur, ":");203 var line_index = std.mem.indexOf(u8, cur, ":");
209 if (line_index == null) {204 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});
211 }206 }
212 const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");207 const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");
213 cur = cur[line_index.? + 1 ..];208 cur = cur[line_index.? + 1 ..];
214 const column_index = std.mem.indexOf(u8, cur, ":");209 const column_index = std.mem.indexOf(u8, cur, ":");
215 if (column_index == null) {210 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});
217 }212 }
218 const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number");213 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] == ' ');214 cur = cur[column_index.? + 2 ..];
220 const msg = cur[column_index.? + 2 ..];215 std.debug.assert(std.mem.eql(u8, cur[0..7], "error: "));
216 const msg = cur[7..];
221217
222 if (line == 0 or column == 0) {218 if (line == 0 or column == 0) {
223 @panic("Invalid test: error line and column must be specified starting at one!");219 @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 {...@@ -18,7 +18,7 @@ pub fn addCases(ctx: *TestContext) !void {
18 \\@start = fn(@start_fnty, {18 \\@start = fn(@start_fnty, {
19 \\ %0 = call(%test, [])19 \\ %0 = call(%test, [])
20 \\})20 \\})
21 , &[_][]const u8{"error: 5:13: unrecognized identifier: %test"});21 , &[_][]const u8{"5:13: error: unrecognized identifier: %test"});
2222
23 // TODO: fix this test23 // TODO: fix this test
24 // ctx.addZIRError("call with non-existent target", linux_x64,24 // ctx.addZIRError("call with non-existent target", linux_x64,
...@@ -45,7 +45,7 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -45,7 +45,7 @@ pub fn addCases(ctx: *TestContext) !void {
45 \\@0 = str("_start")45 \\@0 = str("_start")
46 \\@1 = ref(@0)46 \\@1 = ref(@0)
47 \\@2 = export(@1, @start)47 \\@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
50 //try ctx.testCompileError(50 //try ctx.testCompileError(
51 // \\export fn entry() void {}51 // \\export fn entry() void {}