diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-10-04 18:00:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-04 18:00:21 -0400 |
| commit | 302a69f127ae8542f49d9cd07c7cc49f3bbd6181 (patch) | |
| tree | 063f062e7701e4679a0e97ad1a25021294663640 /src/test.zig | |
| parent | 0e2d858d69ee1595bb58d936f83f0e0248d54d68 (diff) | |
| parent | 6d3858dc8a5e5d510a6c9cc972357dda551628b3 (diff) | |
| download | zig-302a69f127ae8542f49d9cd07c7cc49f3bbd6181.tar.gz zig-302a69f127ae8542f49d9cd07c7cc49f3bbd6181.zip | |
Merge pull request #6295 from Vexu/stage2
Stage2: basic imports
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(); |
