windows: fix setting dirent types on uv_fs_scandir_next

Also make the tests more strict.

PR-URL: https://github.com/libuv/libuv/pull/201
Reviewed-By: Tim Caswell <tim@creationix.com>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
Saúl Ibarra Corretgé 2015-02-11 22:07:11 +01:00
parent 454688dc61
commit 3ddfb4a9cc
2 changed files with 21 additions and 4 deletions

View File

@ -294,6 +294,7 @@ typedef struct uv__dirent_s {
char d_name[1];
} uv__dirent_t;
#define HAVE_DIRENT_TYPES
#define UV__DT_DIR UV_DIRENT_DIR
#define UV__DT_FILE UV_DIRENT_FILE
#define UV__DT_LINK UV_DIRENT_LINK

View File

@ -436,7 +436,11 @@ static void scandir_cb(uv_fs_t* req) {
while (UV_EOF != uv_fs_scandir_next(req, &dent)) {
ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
#ifdef HAVE_DIRENT_TYPES
ASSERT(dent.type == UV_DIRENT_FILE);
#else
ASSERT(dent.type == UV_DIRENT_UNKNOWN);
#endif
}
scandir_cb_count++;
ASSERT(req->path);
@ -875,7 +879,11 @@ TEST_IMPL(fs_async_dir) {
ASSERT(scandir_req.ptr);
while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) {
ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
#ifdef HAVE_DIRENT_TYPES
ASSERT(dent.type == UV_DIRENT_FILE);
#else
ASSERT(dent.type == UV_DIRENT_UNKNOWN);
#endif
}
uv_fs_req_cleanup(&scandir_req);
ASSERT(!scandir_req.ptr);
@ -1695,7 +1703,11 @@ TEST_IMPL(fs_symlink_dir) {
ASSERT(scandir_req.ptr);
while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) {
ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
#ifdef HAVE_DIRENT_TYPES
ASSERT(dent.type == UV_DIRENT_FILE);
#else
ASSERT(dent.type == UV_DIRENT_UNKNOWN);
#endif
}
uv_fs_req_cleanup(&scandir_req);
ASSERT(!scandir_req.ptr);
@ -1715,7 +1727,11 @@ TEST_IMPL(fs_symlink_dir) {
ASSERT(scandir_req.ptr);
while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) {
ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
#ifdef HAVE_DIRENT_TYPES
ASSERT(dent.type == UV_DIRENT_FILE);
#else
ASSERT(dent.type == UV_DIRENT_UNKNOWN);
#endif
}
uv_fs_req_cleanup(&scandir_req);
ASSERT(!scandir_req.ptr);