aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Io/File.zig2
-rw-r--r--lib/std/debug.zig10
-rw-r--r--lib/std/testing.zig6
3 files changed, 8 insertions, 10 deletions
diff --git a/lib/std/Io/File.zig b/lib/std/Io/File.zig
index 7718b56f8a..ccf18a8f56 100644
--- a/lib/std/Io/File.zig
+++ b/lib/std/Io/File.zig
@@ -280,7 +280,7 @@ pub fn sync(file: File, io: Io) SyncError!void {
/// See also:
/// * `enableAnsiEscapeCodes`
/// * `supportsAnsiEscapeCodes`.
-pub fn isTty(file: File, io: Io) bool {
+pub fn isTty(file: File, io: Io) Io.Cancelable!bool {
return io.vtable.fileIsTty(io.userdata, file);
}
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 6ffa254271..7b111215f3 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -1207,9 +1207,8 @@ fn printLineFromFile(io: Io, writer: *Writer, source_location: SourceLocation) !
var buffer: [4096]u8 = undefined;
var file_reader: File.Reader = .init(file, io, &buffer);
- const r = &file_reader.interface;
var line_index: usize = 0;
- while (r.takeDelimiterExclusive('\n')) |line| {
+ while (try file_reader.interface.takeDelimiter('\n')) |line| {
line_index += 1;
if (line_index == source_location.line) {
// TODO delete hard tabs from the language
@@ -1219,9 +1218,8 @@ fn printLineFromFile(io: Io, writer: *Writer, source_location: SourceLocation) !
try writer.writeByte('\n');
return;
}
- } else |err| {
- return err;
}
+ return error.EndOfStream;
}
test printLineFromFile {
@@ -1248,7 +1246,7 @@ test printLineFromFile {
defer gpa.free(path);
try test_dir.dir.writeFile(io, .{ .sub_path = "one_line.zig", .data = "no new lines in this file, but one is printed anyway" });
- try expectError(error.EndOfFile, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
+ try expectError(error.EndOfStream, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
try expectEqualStrings("no new lines in this file, but one is printed anyway\n", aw.written());
@@ -1317,7 +1315,7 @@ test printLineFromFile {
const writer = &file_writer.interface;
try writer.splatByteAll('a', 3 * std.heap.page_size_max);
- try expectError(error.EndOfFile, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
+ try expectError(error.EndOfStream, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
try expectEqualStrings(("a" ** (3 * std.heap.page_size_max)) ++ "\n", aw.written());
diff --git a/lib/std/testing.zig b/lib/std/testing.zig
index 9eb2ad5e96..ab9f1f73c3 100644
--- a/lib/std/testing.zig
+++ b/lib/std/testing.zig
@@ -629,12 +629,12 @@ pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir {
_ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);
const cwd = Io.Dir.cwd();
- var cache_dir = cwd.makeOpenPath(".zig-cache", .{}) catch
+ var cache_dir = cwd.makeOpenPath(io, ".zig-cache", .{}) catch
@panic("unable to make tmp dir for testing: unable to make and open .zig-cache dir");
defer cache_dir.close(io);
- const parent_dir = cache_dir.makeOpenPath("tmp", .{}) catch
+ const parent_dir = cache_dir.makeOpenPath(io, "tmp", .{}) catch
@panic("unable to make tmp dir for testing: unable to make and open .zig-cache/tmp dir");
- const dir = parent_dir.makeOpenPath(&sub_path, opts) catch
+ const dir = parent_dir.makeOpenPath(io, &sub_path, .{ .open_options = opts }) catch
@panic("unable to make tmp dir for testing: unable to make and open the tmp dir");
return .{