st/os: address @andrewrk concerns

This commit is contained in:
hellerve 2018-03-29 10:23:44 +02:00
parent f5b43ada46
commit 7e951e5043
2 changed files with 10 additions and 3 deletions

View File

@ -1134,7 +1134,7 @@ pub const Dir = struct {
SymLink,
File,
UnixDomainSocket,
Wht, // TODO wtf is this
Whiteout,
Unknown,
};
};
@ -1223,7 +1223,7 @@ pub const Dir = struct {
posix.DT_LNK => Entry.Kind.SymLink,
posix.DT_REG => Entry.Kind.File,
posix.DT_SOCK => Entry.Kind.UnixDomainSocket,
posix.DT_WHT => Entry.Kind.Wht,
posix.DT_WHT => Entry.Kind.Whiteout,
else => Entry.Kind.Unknown,
};
return Entry {
@ -1759,11 +1759,12 @@ test "std.os" {
_ = @import("linux/index.zig");
_ = @import("path.zig");
_ = @import("windows/index.zig");
_ = @import("test.zig");
}
// TODO make this a build variable that you can set
const unexpected_error_tracing = true;
const unexpected_error_tracing = false;
/// Call this when you made a syscall or something that sets errno
/// and you get an unexpected error.

View File

@ -1,5 +1,6 @@
const std = @import("../index.zig");
const os = std.os;
const debug = std.debug;
const io = std.io;
const a = std.debug.global_allocator;
@ -9,4 +10,9 @@ test "makePath, put some files in it, deleteTree" {
try io.writeFile(a, "os_test_tmp/b/c/file.txt", "nonsense");
try io.writeFile(a, "os_test_tmp/b/file2.txt", "blah");
try os.deleteTree(a, "os_test_tmp");
if (os.Dir.open(a, "os_test_tmp")) |dir| {
debug.assert(false); // this should not happen!
} else |err| {
debug.assert(err == error.PathNotFound);
}
}