| ... | ... | @@ -462,6 +462,19 @@ pub const TestContext = struct { |
| 462 | 462 | try module.update(); |
| 463 | 463 | module_node.end(); |
| 464 | 464 | |
| 465 | if (update.case != .Error) { |
| 466 | var all_errors = try module.getAllErrorsAlloc(); |
| 467 | defer all_errors.deinit(allocator); |
| 468 | if (all_errors.list.len != 0) { |
| 469 | std.debug.warn("\nErrors occurred updating the module:\n================\n", .{}); |
| 470 | for (all_errors.list) |err| { |
| 471 | std.debug.warn(":{}:{}: error: {}\n================\n", .{ err.line + 1, err.column + 1, err.msg }); |
| 472 | } |
| 473 | std.debug.warn("Test failed.\n", .{}); |
| 474 | std.process.exit(1); |
| 475 | } |
| 476 | } |
| 477 | |
| 465 | 478 | switch (update.case) { |
| 466 | 479 | .Transformation => |expected_output| { |
| 467 | 480 | var label: []const u8 = "ZIR"; |
| ... | ... | @@ -472,13 +485,13 @@ pub const TestContext = struct { |
| 472 | 485 | defer allocator.free(out); |
| 473 | 486 | |
| 474 | 487 | if (expected_output.len != out.len) { |
| 475 | | std.debug.warn("{}\nTransformed {} length differs:\n================\nExpected:\n================\n{}\n================\nFound:\n================\n{}\n================\nTest failed.\n", .{ case.name, label, expected_output, out }); |
| 488 | std.debug.warn("\nTransformed {} length differs:\n================\nExpected:\n================\n{}\n================\nFound:\n================\n{}\n================\nTest failed.\n", .{ label, expected_output, out }); |
| 476 | 489 | std.process.exit(1); |
| 477 | 490 | } |
| 478 | 491 | for (expected_output) |e, i| { |
| 479 | 492 | if (out[i] != e) { |
| 480 | 493 | if (expected_output.len != out.len) { |
| 481 | | std.debug.warn("{}\nTransformed {} differs:\n================\nExpected:\n================\n{}\n================\nFound:\n================\n{}\n================\nTest failed.\n", .{ case.name, label, expected_output, out }); |
| 494 | std.debug.warn("\nTransformed {} differs:\n================\nExpected:\n================\n{}\n================\nFound:\n================\n{}\n================\nTest failed.\n", .{ label, expected_output, out }); |
| 482 | 495 | std.process.exit(1); |
| 483 | 496 | } |
| 484 | 497 | } |