[Stage2/Testing] Always finish case, note all errs

master
Noam Preil 2020-05-25 16:15:39 -04:00
parent f2399db3ef
commit e030414c16
No known key found for this signature in database
GPG Key ID: FC347E7C85BE8238
1 changed files with 25 additions and 9 deletions

View File

@ -363,25 +363,30 @@ pub const TestContext = struct {
break :f false;
};
module_node.end();
var err: ?anyerror = null;
{
var i = module.failed_files.iterator();
var index: usize = 0;
while (i.next()) |pair| : (index += 1) {
if (index == case.expected_file_errors.len) {
std.debug.warn("Unexpected file error: {}\n", .{pair.value});
return error.UnexpectedError;
err = error.UnexpectedError;
}
const v1 = pair.value.*;
const v2 = case.expected_file_errors[index];
if (v1.byte_offset != v2.byte_offset) {
std.debug.warn("Expected error at {}, found it at {}\n", .{ v2.byte_offset, v1.byte_offset });
return error.ExpectedErrorElsewhere;
err = error.ExpectedErrorElsewhere;
}
if (!std.mem.eql(u8, v1.msg, v2.msg)) {
std.debug.warn("Expected '{}', found '{}'\n", .{ v2.msg, v1.msg });
return error.ExpectedOtherError;
err = error.ExpectedOtherError;
}
}
if (index != case.expected_file_errors.len) {
std.debug.warn("Expected an error ('{}'), but did not receive it\n", .{case.expected_file_errors[index]});
err = error.MissingError;
}
}
{
var i = module.failed_decls.iterator();
@ -389,19 +394,23 @@ pub const TestContext = struct {
while (i.next()) |pair| : (index += 1) {
if (index == case.expected_decl_errors.len) {
std.debug.warn("Unexpected decl error: {}\n", .{pair.value});
return error.UnexpectedError;
err = error.UnexpectedError;
}
const v1 = pair.value.*;
const v2 = case.expected_decl_errors[index];
if (v1.byte_offset != v2.byte_offset) {
std.debug.warn("Expected error at {}, found it at {}\n", .{ v2.byte_offset, v1.byte_offset });
return error.ExpectedErrorElsewhere;
err = error.ExpectedErrorElsewhere;
}
if (!std.mem.eql(u8, v1.msg, v2.msg)) {
std.debug.warn("Expected '{}', found '{}'\n", .{ v2.msg, v1.msg });
return error.ExpectedOtherError;
err = error.ExpectedOtherError;
}
}
if (index != case.expected_decl_errors.len) {
std.debug.warn("Expected an error ('{}'), but did not receive it\n", .{case.expected_decl_errors[index]});
err = error.MissingError;
}
}
{
var i = module.failed_exports.iterator();
@ -409,19 +418,26 @@ pub const TestContext = struct {
while (i.next()) |pair| : (index += 1) {
if (index == case.expected_export_errors.len) {
std.debug.warn("Unexpected export error: {}\n", .{pair.value});
return error.UnexpectedError;
err = error.UnexpectedError;
}
const v1 = pair.value.*;
const v2 = case.expected_export_errors[index];
if (v1.byte_offset != v2.byte_offset) {
std.debug.warn("Expected error at {}, found it at {}\n", .{ v2.byte_offset, v1.byte_offset });
return error.ExpectedErrorElsewhere;
err = error.ExpectedErrorElsewhere;
}
if (!std.mem.eql(u8, v1.msg, v2.msg)) {
std.debug.warn("Expected '{}', found '{}'\n", .{ v2.msg, v1.msg });
return error.ExpectedOtherError;
err = error.ExpectedOtherError;
}
}
if (index != case.expected_export_errors.len) {
std.debug.warn("Expected an error ('{}'), but did not receive it\n", .{case.expected_export_errors[index]});
err = error.MissingError;
}
}
if (err) |e| {
return e;
}
}
};