mirror of
https://codeberg.org/ziglings/exercises.git
synced 2025-06-08 01:57:02 +09:00
Restore unit tests
Commit dbd42bb (Cleaning up zig build output) broke the unit test. Always use exit code 2, instead of 0. This is the exit code used by the build runner to notify the compiler to not report any further diagnostics. Move the Ziglings logo from the `build` function scope to the global scope, and make it public so that tests.zig can use it to find the number of lines to skip, instead of using an hard coded value. Fixes #295
This commit is contained in:
parent
e4e096c680
commit
7aa0737929
2 changed files with 23 additions and 22 deletions
|
@ -175,7 +175,7 @@ pub fn addCliTests(b: *std.Build, exercises: []const Exercise) *Step {
|
|||
const cmd = b.addSystemCommand(&.{ b.zig_exe, "build", "-Dn=1" });
|
||||
const expect = exercises[0].hint orelse "";
|
||||
cmd.setName("zig build -Dn=1");
|
||||
cmd.expectExitCode(1);
|
||||
cmd.expectExitCode(2);
|
||||
cmd.addCheck(.{ .expect_stderr_match = expect });
|
||||
|
||||
cmd.step.dependOn(case_step);
|
||||
|
@ -282,10 +282,11 @@ const CheckStep = struct {
|
|||
for (exercises) |ex| {
|
||||
if (ex.number() == 1 and self.has_logo) {
|
||||
// Skip the logo.
|
||||
const nlines = mem.count(u8, root.logo, "\n");
|
||||
var buf: [80]u8 = undefined;
|
||||
|
||||
var lineno: usize = 0;
|
||||
while (lineno < 8) : (lineno += 1) {
|
||||
while (lineno < nlines) : (lineno += 1) {
|
||||
_ = try readLine(stderr, &buf);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue