Fix a couple bugs in memory access (tests only)

This commit is contained in:
Mitchell Hashimoto
2022-09-23 12:51:50 -07:00
parent 72105fc6cd
commit a1d238e385
2 changed files with 4 additions and 4 deletions

View File

@ -353,7 +353,7 @@ test "Command: pre exec" {
}
test "Command: redirect stdout to file" {
const td = try TempDir.init();
var td = try TempDir.init();
defer td.deinit();
var stdout = try td.dir.createFile("stdout.txt", .{ .read = true });
defer stdout.close();
@ -378,7 +378,7 @@ test "Command: redirect stdout to file" {
}
test "Command: custom env vars" {
const td = try TempDir.init();
var td = try TempDir.init();
defer td.deinit();
var stdout = try td.dir.createFile("stdout.txt", .{ .read = true });
defer stdout.close();

View File

@ -52,13 +52,13 @@ pub fn init() !TempDir {
/// Name returns the name of the directory. This is just the basename
/// and is not the full absolute path.
pub fn name(self: TempDir) []const u8 {
pub fn name(self: *TempDir) []const u8 {
return std.mem.sliceTo(&self.name_buf, 0);
}
/// Finish with the temporary directory. This deletes all contents in the
/// directory. This is safe to call multiple times.
pub fn deinit(self: TempDir) void {
pub fn deinit(self: *TempDir) void {
self.parent.deleteTree(self.name()) catch |err|
log.err("error deleting temp dir err={}", .{err});
}