Stage2/Testing: Fix error specification
parent
6dce317fe3
commit
e77fc7fe7e
|
@ -200,24 +200,20 @@ pub const TestContext = struct {
|
||||||
var array = std.ArrayList(ErrorMsg).init(ctx.zir_error_cases.allocator);
|
var array = std.ArrayList(ErrorMsg).init(ctx.zir_error_cases.allocator);
|
||||||
for (expected_errors) |e| {
|
for (expected_errors) |e| {
|
||||||
var cur = e;
|
var cur = e;
|
||||||
const err = cur[0..7];
|
|
||||||
if (!std.mem.eql(u8, err, "error: ")) {
|
|
||||||
std.debug.panic("Only error messages are currently supported, received {}\n", .{e});
|
|
||||||
}
|
|
||||||
cur = cur[7..];
|
|
||||||
var line_index = std.mem.indexOf(u8, cur, ":");
|
var line_index = std.mem.indexOf(u8, cur, ":");
|
||||||
if (line_index == null) {
|
if (line_index == null) {
|
||||||
std.debug.panic("Invalid test: error must be specified as 'error: line:column: msg', found '{}'", .{e});
|
std.debug.panic("Invalid test: error must be specified as 'line:column: error: msg', found '{}'", .{e});
|
||||||
}
|
}
|
||||||
const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");
|
const line = std.fmt.parseInt(u32, cur[0..line_index.?], 10) catch @panic("Unable to parse line number");
|
||||||
cur = cur[line_index.? + 1 ..];
|
cur = cur[line_index.? + 1 ..];
|
||||||
const column_index = std.mem.indexOf(u8, cur, ":");
|
const column_index = std.mem.indexOf(u8, cur, ":");
|
||||||
if (column_index == null) {
|
if (column_index == null) {
|
||||||
std.debug.panic("Invalid test: error must be specified as 'error: line:column: msg', found '{}'", .{e});
|
std.debug.panic("Invalid test: error must be specified as 'line:column: error: msg', found '{}'", .{e});
|
||||||
}
|
}
|
||||||
const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number");
|
const column = std.fmt.parseInt(u32, cur[0..column_index.?], 10) catch @panic("Unable to parse column number");
|
||||||
std.debug.assert(cur[column_index.? + 1] == ' ');
|
cur = cur[column_index.? + 2 ..];
|
||||||
const msg = cur[column_index.? + 2 ..];
|
std.debug.assert(std.mem.eql(u8, cur[0..7], "error: "));
|
||||||
|
const msg = cur[7..];
|
||||||
|
|
||||||
if (line == 0 or column == 0) {
|
if (line == 0 or column == 0) {
|
||||||
@panic("Invalid test: error line and column must be specified starting at one!");
|
@panic("Invalid test: error line and column must be specified starting at one!");
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||||
\\@start = fn(@start_fnty, {
|
\\@start = fn(@start_fnty, {
|
||||||
\\ %0 = call(%test, [])
|
\\ %0 = call(%test, [])
|
||||||
\\})
|
\\})
|
||||||
, &[_][]const u8{"error: 5:13: unrecognized identifier: %test"});
|
, &[_][]const u8{"5:13: error: unrecognized identifier: %test"});
|
||||||
|
|
||||||
// TODO: fix this test
|
// TODO: fix this test
|
||||||
// ctx.addZIRError("call with non-existent target", linux_x64,
|
// ctx.addZIRError("call with non-existent target", linux_x64,
|
||||||
|
@ -45,7 +45,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||||
\\@0 = str("_start")
|
\\@0 = str("_start")
|
||||||
\\@1 = ref(@0)
|
\\@1 = ref(@0)
|
||||||
\\@2 = export(@1, @start)
|
\\@2 = export(@1, @start)
|
||||||
, &[_][]const u8{"error: 4:9: unable to call function with naked calling convention"});
|
, &[_][]const u8{"4:9: error: unable to call function with naked calling convention"});
|
||||||
|
|
||||||
//try ctx.testCompileError(
|
//try ctx.testCompileError(
|
||||||
// \\export fn entry() void {}
|
// \\export fn entry() void {}
|
||||||
|
|
Loading…
Reference in New Issue