diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2025-07-22 10:52:04 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2025-07-22 10:52:04 +0200 |
| commit | 1f6ce9a2684149c99606ba2ccbfa7092d72cdeae (patch) | |
| tree | 2edab32995d90203155546ef575bbd9db45c377b /test/tests.zig | |
| parent | b9a372bde810939c35d90fd7fc98bc262e7632d8 (diff) | |
| parent | 4044b93dd210cb3eb8c1993f2be0e286c4383f2f (diff) | |
Merge pull request 'Fix zig 0.15.0-dev.1149+4e6a04929 build errors' (#283) from zawupf/ziglings-exercises:zig-0.15 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/283
Diffstat (limited to 'test/tests.zig')
| -rw-r--r-- | test/tests.zig | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/test/tests.zig b/test/tests.zig index 5f64f8e..b191610 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -161,7 +161,7 @@ const CheckNamedStep = struct { ); defer stderr_file.close(); - const stderr = stderr_file.reader(); + var stderr = stderr_file.readerStreaming(&.{}); { // Skip the logo. const nlines = mem.count(u8, root.logo, "\n"); @@ -169,10 +169,10 @@ const CheckNamedStep = struct { var lineno: usize = 0; while (lineno < nlines) : (lineno += 1) { - _ = try readLine(stderr, &buf); + _ = try readLine(&stderr, &buf); } } - try check_output(step, ex, stderr); + try check_output(step, ex, &stderr); } }; @@ -213,7 +213,7 @@ const CheckStep = struct { ); defer stderr_file.close(); - const stderr = stderr_file.reader(); + var stderr = stderr_file.readerStreaming(&.{}); for (exercises) |ex| { if (ex.number() == 1) { // Skip the logo. @@ -222,15 +222,15 @@ const CheckStep = struct { var lineno: usize = 0; while (lineno < nlines) : (lineno += 1) { - _ = try readLine(stderr, &buf); + _ = try readLine(&stderr, &buf); } } - try check_output(step, ex, stderr); + try check_output(step, ex, &stderr); } } }; -fn check_output(step: *Step, exercise: Exercise, reader: Reader) !void { +fn check_output(step: *Step, exercise: Exercise, reader: *Reader) !void { const b = step.owner; var buf: [1024]u8 = undefined; @@ -297,12 +297,9 @@ fn check( } } -fn readLine(reader: fs.File.Reader, buf: []u8) !?[]const u8 { - if (try reader.readUntilDelimiterOrEof(buf, '\n')) |line| { - return mem.trimRight(u8, line, " \r\n"); - } - - return null; +fn readLine(reader: *fs.File.Reader, buf: []u8) !?[]const u8 { + try reader.interface.readSliceAll(buf); + return mem.trimRight(u8, buf, " \r\n"); } /// Fails with a custom error message. @@ -405,7 +402,8 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8 /// difference that returns an error when the temp path cannot be created. pub fn makeTempPath(b: *Build) ![]const u8 { const rand_int = std.crypto.random.int(u64); - const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ Build.hex64(rand_int); + const rand_hex64 = std.fmt.hex(rand_int); + const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ rand_hex64; const path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM"); try b.cache_root.handle.makePath(tmp_dir_sub_path); |
