From 9f80386338af7d164ff1f47d480ee1ae775cb0ef Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Wed, 1 Jun 2022 18:44:14 -0700 Subject: [PATCH] Add async `fs_scandir` test case --- tests/test-fs.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test-fs.lua b/tests/test-fs.lua index e199b8e5..1eb55af2 100644 --- a/tests/test-fs.lua +++ b/tests/test-fs.lua @@ -125,6 +125,21 @@ return require('lib/tap')(function (test) end end) + test("fs.scandir async", function (print, p, expect, uv) + assert(uv.fs_scandir('.', function(err, req) + assert(not err) + local function iter() + return uv.fs_scandir_next(req) + end + for name, ftype in iter do + p{name=name, ftype=ftype} + assert(name) + -- ftype is not available in all filesystems; for example it's + -- provided for HFS+ (OSX), NTFS (Windows) but not for ext4 (Linux). + end + end)) + end) + -- this test does nothing on its own, but when run with a leak checker, -- it will check that the memory allocated by Libuv for req is cleaned up -- even if its not iterated fully (or at all)