Stage2/Testing: Enable another test

This commit is contained in:
Noam Preil 2020-06-15 20:42:22 -04:00
parent 7d1c9a69cc
commit afec3e72f4
No known key found for this signature in database
GPG Key ID: FC347E7C85BE8238
2 changed files with 22 additions and 17 deletions

View File

@ -110,20 +110,25 @@ pub const TestContext = struct {
pub fn addError(self: *ZIRCase, src: [:0]const u8, errors: []const []const u8) void {
var array = self.updates.allocator.alloc(ErrorMsg, errors.len) catch unreachable;
for (errors) |e, i| {
if (e[0] != ':') {
std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{});
}
var cur = e[1..];
var line_index = std.mem.indexOf(u8, cur, ":");
if (line_index == null) {
std.debug.panic("Invalid test: error must be specified as ':line:column: error: msg', found '{}'", .{e});
std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{});
}
const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");
cur = cur[line_index.? + 1 ..];
const column_index = std.mem.indexOf(u8, cur, ":");
if (column_index == null) {
std.debug.panic("Invalid test: error must be specified as ':line:column: error: msg', found '{}'", .{e});
std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{});
}
const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number");
cur = cur[column_index.? + 2 ..];
std.debug.assert(std.mem.eql(u8, cur[0..7], "error: "));
if (!std.mem.eql(u8, cur[0..7], "error: ")) {
std.debug.panic("Invalid test: error must be specified as follows:\n:line:column: error: message\n=========\n", .{});
}
const msg = cur[7..];
if (line == 0 or column == 0) {
@ -312,7 +317,7 @@ pub const TestContext = struct {
break;
}
} else {
std.debug.warn("{}\nUnexpected error:\n================\n{}:{}: {}\n================\nTest failed.\n", .{ case.name, a.line + 1, a.column + 1, a.msg });
std.debug.warn("{}\nUnexpected error:\n================\n:{}:{}: error: {}\n================\nTest failed.\n", .{ case.name, a.line + 1, a.column + 1, a.msg });
std.process.exit(1);
}
}

View File

@ -18,20 +18,20 @@ pub fn addCases(ctx: *TestContext) !void {
\\@start = fn(@start_fnty, {
\\ %0 = call(%test, [])
\\})
, &[_][]const u8{":5:13: error: unrecognized identifier: %test"});
// TODO: address inconsistency in this message and the one in the next test
, &[_][]const u8{":5:13: error: unrecognized identifier: %test"});
// TODO: fix this test
// ctx.addZIRError("call with non-existent target", linux_x64,
// \\@noreturn = primitive(noreturn)
// \\
// \\@start_fnty = fntype([], @noreturn, cc=Naked)
// \\@start = fn(@start_fnty, {
// \\ %0 = call(@notafunc, [])
// \\})
// \\@0 = str("_start")
// \\@1 = ref(@0)
// \\@2 = export(@1, @start)
// , &[_][]const u8{"5:13:unrecognized identifier: @notafunc"});
ctx.addZIRError("call with non-existent target", linux_x64,
\\@noreturn = primitive(noreturn)
\\
\\@start_fnty = fntype([], @noreturn, cc=Naked)
\\@start = fn(@start_fnty, {
\\ %0 = call(@notafunc, [])
\\})
\\@0 = str("_start")
\\@1 = ref(@0)
\\@2 = export(@1, @start)
, &[_][]const u8{":5:13: error: use of undeclared identifier 'notafunc'"});
// TODO: this error should occur at the call site, not the fntype decl
ctx.addZIRError("call naked function", linux_x64,