mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
Add deleteDir test with exception for not-empty directory on Windows
Re-adds the test that was added and then reverted in https://github.com/ziglang/zig/pull/6397, but with the test for https://github.com/ziglang/zig/issues/5537 skipped for now since that issue is no longer fixed.
This commit is contained in:
parent
254ee89def
commit
bd449b184a
@ -274,6 +274,32 @@ test "file operations on directories" {
|
|||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "deleteDir" {
|
||||||
|
var tmp_dir = tmpDir(.{});
|
||||||
|
defer tmp_dir.cleanup();
|
||||||
|
|
||||||
|
// deleting a non-existent directory
|
||||||
|
testing.expectError(error.FileNotFound, tmp_dir.dir.deleteDir("test_dir"));
|
||||||
|
|
||||||
|
var dir = try tmp_dir.dir.makeOpenPath("test_dir", .{});
|
||||||
|
var file = try dir.createFile("test_file", .{});
|
||||||
|
file.close();
|
||||||
|
dir.close();
|
||||||
|
|
||||||
|
// deleting a non-empty directory
|
||||||
|
// TODO: Re-enable this check on Windows, see https://github.com/ziglang/zig/issues/5537
|
||||||
|
if (builtin.os.tag != .windows) {
|
||||||
|
testing.expectError(error.DirNotEmpty, tmp_dir.dir.deleteDir("test_dir"));
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = try tmp_dir.dir.openDir("test_dir", .{});
|
||||||
|
try dir.deleteFile("test_file");
|
||||||
|
dir.close();
|
||||||
|
|
||||||
|
// deleting an empty directory
|
||||||
|
try tmp_dir.dir.deleteDir("test_dir");
|
||||||
|
}
|
||||||
|
|
||||||
test "Dir.rename files" {
|
test "Dir.rename files" {
|
||||||
var tmp_dir = tmpDir(.{});
|
var tmp_dir = tmpDir(.{});
|
||||||
defer tmp_dir.cleanup();
|
defer tmp_dir.cleanup();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user