authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-26 18:58:16+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-28 18:35:01+02:00
logf41dd3617e3f630c3d5ec7745784076ccc0c3025
tree7d9c2ba2810b3fa90df815c60190b75e2331fea7
parentd305a6fb550d68f4ee57bbb86f482969b819653b

test: pass Strategy per directory of tests


4 files changed, 8 insertions(+), 16 deletions(-)

src/test.zig+8-11
......@@ -80,7 +80,7 @@ test {
8080 var dir = try std.fs.cwd().openDir(dir_path, .{ .iterate = true });
8181 defer dir.close();
8282
83 ctx.addTestCasesFromDir(dir);
83 ctx.addTestCasesFromDir(dir, .incremental);
8484 }
8585
8686 try @import("test_cases").addCases(&ctx);
......@@ -834,10 +834,6 @@ pub const TestContext = struct {
834834 /// Execute all tests as incremental updates to a single compilation. Explicitly
835835 /// incremental tests ("foo.0.zig", "foo.1.zig", etc.) still execute in order
836836 incremental,
837
838 fn parse(str: []const u8) ?Strategy {
839 return std.meta.stringToEnum(Strategy, str);
840 }
841837 };
842838
843839 /// Adds a compile-error test for each file in the provided directory, using the
......@@ -866,9 +862,9 @@ pub const TestContext = struct {
866862 };
867863 }
868864
869 pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir) void {
865 pub fn addTestCasesFromDir(ctx: *TestContext, dir: std.fs.Dir, strategy: Strategy) void {
870866 var current_file: []const u8 = "none";
871 addTestCasesFromDirInner(ctx, dir, &current_file) catch |err| {
867 addTestCasesFromDirInner(ctx, dir, strategy, &current_file) catch |err| {
872868 std.debug.panic("test harness failed to process file '{s}': {s}\n", .{
873869 current_file, @errorName(err),
874870 });
......@@ -938,6 +934,7 @@ pub const TestContext = struct {
938934 fn addTestCasesFromDirInner(
939935 ctx: *TestContext,
940936 dir: std.fs.Dir,
937 strategy: Strategy,
941938 /// This is kept up to date with the currently being processed file so
942939 /// that if any errors occur the caller knows it happened during this file.
943940 current_file: *[]const u8,
......@@ -988,8 +985,8 @@ pub const TestContext = struct {
988985 // in a new sequence ("*.0.zig") or an independent test file ("*.zig")
989986 if (new_parts.test_index != null and new_parts.test_index.? != 0) return error.InvalidIncrementalTestIndex;
990987
991 // if (strategy == .independent)
992 // opt_case = null; // Generate a new independent test case for this update
988 if (strategy == .independent)
989 opt_case = null; // Generate a new independent test case for this update
993990 }
994991 }
995992 prev_filename = filename;
......@@ -999,13 +996,12 @@ pub const TestContext = struct {
999996
1000997 // Parse the manifest
1001998 var manifest = try TestManifest.parse(ctx.arena, src);
1002 const strategy = manifest.getConfigForKey("strategy", Strategy, Strategy.parse).next().?;
1003 const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?;
1004999
10051000 switch (manifest.@"type") {
10061001 .@"error" => {
10071002 const case = opt_case orelse case: {
10081003 const case = try ctx.cases.addOne();
1004 const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?;
10091005 case.* = .{
10101006 .name = "none",
10111007 .target = .{},
......@@ -1032,6 +1028,7 @@ pub const TestContext = struct {
10321028 .run => {
10331029 const case = opt_case orelse case: {
10341030 const case = try ctx.cases.addOne();
1031 const backend = manifest.getConfigForKey("backend", Backend, Backend.parse).next().?;
10351032 case.* = .{
10361033 .name = "none",
10371034 .target = .{},
test/incremental/add.0.zig-1
......@@ -8,5 +8,4 @@ fn add(a: u32, b: u32) void {
88
99// run
1010// backend=stage2
11// strategy=incremental
1211//
test/incremental/add.1.zig-2
......@@ -9,6 +9,4 @@ fn add(a: u32, b: u32) u32 {
99const x = add(3, 4);
1010
1111// run
12// backend=stage2
13// strategy=incremental
1412//
test/incremental/add.2.zig-2
......@@ -9,6 +9,4 @@ inline fn add(a: usize, b: usize, c: usize) usize {
99}
1010
1111// run
12// backend=stage2
13// strategy=incremental
1412//