diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-11-22 12:35:33 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-11-22 12:35:33 -0700 |
| commit | 519ba9bb654a4d5caf7440160f018b7a3ae1e95a (patch) | |
| tree | 2308d007f7e1bf1a8aed846ad4faef8e729e0598 /lib/std/testing.zig | |
| parent | e4977f3e89fcc164a4d02cd38eb066cfe1a1124f (diff) | |
| download | zig-519ba9bb654a4d5caf7440160f018b7a3ae1e95a.tar.gz zig-519ba9bb654a4d5caf7440160f018b7a3ae1e95a.zip | |
Revert "Merge pull request #12060 from Vexu/IterableDir"
This reverts commit da94227f783ec3c92859c4713b80a668f1183f96, reversing
changes made to 8f943b3d33432a26b7e242c1181e4220ed400501.
I was against this change originally, but decided to approve it to keep
an open mind. After a year of trying it in practice, I firmly believe
that the previous way of doing it was better.
Diffstat (limited to 'lib/std/testing.zig')
| -rw-r--r-- | lib/std/testing.zig | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 09507a2392..a26b6ff321 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -543,22 +543,6 @@ pub const TmpDir = struct { } }; -pub const TmpIterableDir = struct { - iterable_dir: std.fs.IterableDir, - parent_dir: std.fs.Dir, - sub_path: [sub_path_len]u8, - - const random_bytes_count = 12; - const sub_path_len = std.fs.base64_encoder.calcSize(random_bytes_count); - - pub fn cleanup(self: *TmpIterableDir) void { - self.iterable_dir.close(); - self.parent_dir.deleteTree(&self.sub_path) catch {}; - self.parent_dir.close(); - self.* = undefined; - } -}; - pub fn tmpDir(opts: std.fs.Dir.OpenDirOptions) TmpDir { var random_bytes: [TmpDir.random_bytes_count]u8 = undefined; std.crypto.random.bytes(&random_bytes); @@ -581,28 +565,6 @@ pub fn tmpDir(opts: std.fs.Dir.OpenDirOptions) TmpDir { }; } -pub fn tmpIterableDir(opts: std.fs.Dir.OpenDirOptions) TmpIterableDir { - var random_bytes: [TmpIterableDir.random_bytes_count]u8 = undefined; - std.crypto.random.bytes(&random_bytes); - var sub_path: [TmpIterableDir.sub_path_len]u8 = undefined; - _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes); - - const cwd = std.fs.cwd(); - var cache_dir = cwd.makeOpenPath("zig-cache", .{}) catch - @panic("unable to make tmp dir for testing: unable to make and open zig-cache dir"); - defer cache_dir.close(); - const parent_dir = cache_dir.makeOpenPath("tmp", .{}) catch - @panic("unable to make tmp dir for testing: unable to make and open zig-cache/tmp dir"); - const dir = parent_dir.makeOpenPathIterable(&sub_path, opts) catch - @panic("unable to make tmp dir for testing: unable to make and open the tmp dir"); - - return .{ - .iterable_dir = dir, - .parent_dir = parent_dir, - .sub_path = sub_path, - }; -} - test "expectEqual nested array" { const a = [2][2]f32{ [_]f32{ 1.0, 0.0 }, |
