diff options
Diffstat (limited to 'src/test.zig')
| -rw-r--r-- | src/test.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test.zig b/src/test.zig index 8ad11efa9c..c0ac56aa2d 100644 --- a/src/test.zig +++ b/src/test.zig @@ -56,6 +56,12 @@ pub const TestContext = struct { }, }; + pub const File = struct { + /// Contents of the importable file. Doesn't yet support incremental updates. + src: [:0]const u8, + path: []const u8, + }; + pub const TestType = enum { Zig, ZIR, @@ -78,6 +84,8 @@ pub const TestContext = struct { extension: TestType, cbe: bool = false, + files: std.ArrayList(File), + /// Adds a subcase in which the module is updated with `src`, and the /// resulting ZIR is validated against `result`. pub fn addTransform(self: *Case, src: [:0]const u8, result: [:0]const u8) void { @@ -156,6 +164,7 @@ pub const TestContext = struct { .updates = std.ArrayList(Update).init(ctx.cases.allocator), .output_mode = .Exe, .extension = T, + .files = std.ArrayList(File).init(ctx.cases.allocator), }) catch unreachable; return &ctx.cases.items[ctx.cases.items.len - 1]; } @@ -182,6 +191,7 @@ pub const TestContext = struct { .updates = std.ArrayList(Update).init(ctx.cases.allocator), .output_mode = .Obj, .extension = T, + .files = std.ArrayList(File).init(ctx.cases.allocator), }) catch unreachable; return &ctx.cases.items[ctx.cases.items.len - 1]; } @@ -204,6 +214,7 @@ pub const TestContext = struct { .output_mode = .Obj, .extension = T, .cbe = true, + .files = std.ArrayList(File).init(ctx.cases.allocator), }) catch unreachable; return &ctx.cases.items[ctx.cases.items.len - 1]; } @@ -505,6 +516,10 @@ pub const TestContext = struct { }); defer comp.destroy(); + for (case.files.items) |file| { + try tmp.dir.writeFile(file.path, file.src); + } + for (case.updates.items) |update, update_index| { var update_node = root_node.start("update", 3); update_node.activate(); |
