aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorManlio Perillo <[email protected]>2023-05-14 17:17:01 +0200
committerManlio Perillo <[email protected]>2023-05-14 17:22:03 +0200
commite7f62940eb04a67f24c2fff989b09f4d9e2628cb (patch)
treeedf84bcc2a9c90f541b6ee9bae404cc232589317 /test
parent1c184c2681d54f71f91d956243522820f4673c5b (diff)
downloadziglings-e7f62940eb04a67f24c2fff989b09f4d9e2628cb.tar.xz
ziglings-e7f62940eb04a67f24c2fff989b09f4d9e2628cb.zip
tests: improve test case 3
Update test case 3 to check all exercises with an hint.
Diffstat (limited to 'test')
-rw-r--r--test/tests.zig27
1 files changed, 19 insertions, 8 deletions
diff --git a/test/tests.zig b/test/tests.zig
index 0bde5c1..f5c3960 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -89,18 +89,29 @@ pub fn addCliTests(b: *std.Build, exercises: []const Exercise) *Step {
}
{
- // Test that `zig build -Dn=1` prints the hint.
+ // Test that `zig build -Dn=n` prints the hint.
const case_step = createCase(b, "case-3");
- const cmd = b.addSystemCommand(&.{ b.zig_exe, "build", "-Dn=1" });
- const expect = exercises[0].hint orelse "";
- cmd.setName("zig build -Dn=1");
- cmd.expectExitCode(2);
- cmd.addCheck(.{ .expect_stderr_match = expect });
+ for (exercises[0 .. exercises.len - 1]) |ex| {
+ if (ex.skip) continue;
+
+ if (ex.hint) |hint| {
+ const n = ex.number();
+
+ const cmd = b.addSystemCommand(&.{
+ b.zig_exe,
+ "build",
+ b.fmt("-Dn={}", .{n}),
+ });
+ cmd.setName(b.fmt("zig build -Dn={}", .{n}));
+ cmd.expectExitCode(2);
+ cmd.addCheck(.{ .expect_stderr_match = hint });
- cmd.step.dependOn(case_step);
+ case_step.dependOn(&cmd.step);
+ }
+ }
- step.dependOn(&cmd.step);
+ step.dependOn(case_step);
}
return step;