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
signature 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 {...@@ -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..];
128133
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 }
test/stage2/compile_errors.zig+13-13
...@@ -18,20 +18,20 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -18,20 +18,20 @@ 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{":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 test24 ctx.addZIRError("call with non-existent target", linux_x64,
24 // ctx.addZIRError("call with non-existent target", linux_x64,25 \\@noreturn = primitive(noreturn)
25 // \\@noreturn = primitive(noreturn)26 \\
26 // \\27 \\@start_fnty = fntype([], @noreturn, cc=Naked)
27 // \\@start_fnty = fntype([], @noreturn, cc=Naked)28 \\@start = fn(@start_fnty, {
28 // \\@start = fn(@start_fnty, {29 \\ %0 = call(@notafunc, [])
29 // \\ %0 = call(@notafunc, [])30 \\})
30 // \\})31 \\@0 = str("_start")
31 // \\@0 = str("_start")32 \\@1 = ref(@0)
32 // \\@1 = ref(@0)33 \\@2 = export(@1, @start)
33 // \\@2 = export(@1, @start)34 , &[_][]const u8{":5:13: error: use of undeclared identifier 'notafunc'"});
34 // , &[_][]const u8{"5:13:unrecognized identifier: @notafunc"});
3535
36 // TODO: this error should occur at the call site, not the fntype decl36 // TODO: this error should occur at the call site, not the fntype decl
37 ctx.addZIRError("call naked function", linux_x64,37 ctx.addZIRError("call naked function", linux_x64,