authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-15 20:42:22-04:00
committergravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-06-15 20:42:22-04:00
logafec3e72f438fae41e493e3fd18ca62e5ef1c89b
tree8c940a8043ca7495e492a1a08250437bbb2a49e8
parent7d1c9a69ccaf148c7264df2d197549a851478998
signaturelock-open Commit is signed but in an unrecognized format.

Stage2/Testing: Enable another test


2 files changed, 22 insertions(+), 17 deletions(-)

src-self-hosted/test.zig+9-4
......@@ -110,20 +110,25 @@ pub const TestContext = struct {
110110 pub fn addError(self: *ZIRCase, src: [:0]const u8, errors: []const []const u8) void {
111111 var array = self.updates.allocator.alloc(ErrorMsg, errors.len) catch unreachable;
112112 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 }
113116 var cur = e[1..];
114117 var line_index = std.mem.indexOf(u8, cur, ":");
115118 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", .{});
117120 }
118121 const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");
119122 cur = cur[line_index.? + 1 ..];
120123 const column_index = std.mem.indexOf(u8, cur, ":");
121124 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", .{});
123126 }
124127 const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number");
125128 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 }
127132 const msg = cur[7..];
128133
129134 if (line == 0 or column == 0) {
......@@ -312,7 +317,7 @@ pub const TestContext = struct {
312317 break;
313318 }
314319 } 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 });
316321 std.process.exit(1);
317322 }
318323 }
test/stage2/compile_errors.zig+13-13
......@@ -18,20 +18,20 @@ pub fn addCases(ctx: *TestContext) !void {
1818 \\@start = fn(@start_fnty, {
1919 \\ %0 = call(%test, [])
2020 \\})
21 , &[_][]const u8{":5:13: error: unrecognized identifier: %test"});
21 // TODO: address inconsistency in this message and the one in the next test
22 , &[_][]const u8{":5:13: error: unrecognized identifier: %test"});
2223
23 // TODO: fix this test
24 // ctx.addZIRError("call with non-existent target", linux_x64,
25 // \\@noreturn = primitive(noreturn)
26 // \\
27 // \\@start_fnty = fntype([], @noreturn, cc=Naked)
28 // \\@start = fn(@start_fnty, {
29 // \\ %0 = call(@notafunc, [])
30 // \\})
31 // \\@0 = str("_start")
32 // \\@1 = ref(@0)
33 // \\@2 = export(@1, @start)
34 // , &[_][]const u8{"5:13:unrecognized identifier: @notafunc"});
24 ctx.addZIRError("call with non-existent target", linux_x64,
25 \\@noreturn = primitive(noreturn)
26 \\
27 \\@start_fnty = fntype([], @noreturn, cc=Naked)
28 \\@start = fn(@start_fnty, {
29 \\ %0 = call(@notafunc, [])
30 \\})
31 \\@0 = str("_start")
32 \\@1 = ref(@0)
33 \\@2 = export(@1, @start)
34 , &[_][]const u8{":5:13: error: use of undeclared identifier 'notafunc'"});
3535
3636 // TODO: this error should occur at the call site, not the fntype decl
3737 ctx.addZIRError("call naked function", linux_x64,