mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 06:03:09 -05:00
tests: improve test case 3
Update test case 3 to check all exercises with an hint.
This commit is contained in:
parent
1c184c2681
commit
e7f62940eb
1 changed files with 19 additions and 8 deletions
|
@ -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 case_step = createCase(b, "case-3");
|
||||||
|
|
||||||
const cmd = b.addSystemCommand(&.{ b.zig_exe, "build", "-Dn=1" });
|
for (exercises[0 .. exercises.len - 1]) |ex| {
|
||||||
const expect = exercises[0].hint orelse "";
|
if (ex.skip) continue;
|
||||||
cmd.setName("zig build -Dn=1");
|
|
||||||
cmd.expectExitCode(2);
|
|
||||||
cmd.addCheck(.{ .expect_stderr_match = expect });
|
|
||||||
|
|
||||||
cmd.step.dependOn(case_step);
|
if (ex.hint) |hint| {
|
||||||
|
const n = ex.number();
|
||||||
|
|
||||||
step.dependOn(&cmd.step);
|
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 });
|
||||||
|
|
||||||
|
case_step.dependOn(&cmd.step);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
step.dependOn(case_step);
|
||||||
}
|
}
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
|
|
Loading…
Reference in a new issue