|
@@ -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);
|