diff options
| author | ruki <[email protected]> | 2025-11-08 00:48:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-08 00:48:23 +0800 |
| commit | a9567b1b432e8f2d352963f66bde3cf07b863c5a (patch) | |
| tree | d0100cfea439a72de0e0c1494e4c5d2551e0e43d /tests/modules/os/async_copy.lua | |
| parent | 45f03066b9738062aaa512de7c1c9f0e7c096ec4 (diff) | |
add tests
Diffstat (limited to 'tests/modules/os/async_copy.lua')
| -rw-r--r-- | tests/modules/os/async_copy.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/modules/os/async_copy.lua b/tests/modules/os/async_copy.lua new file mode 100644 index 000000000..751a940ae --- /dev/null +++ b/tests/modules/os/async_copy.lua @@ -0,0 +1,34 @@ +local function _prepare_source(dir) + os.mkdir(dir) + io.writefile(path.join(dir, "foo.txt"), "foo") + io.writefile(path.join(dir, "bar.txt"), "bar") +end + +function main() + local root = os.tmpfile() .. ".os_async_copy" + local srcdir = path.join(root, "src") + local dstdir = path.join(root, "dst") + + _prepare_source(srcdir) + print("source prepared: %s", srcdir) + + local files = os.files(path.join(srcdir, "*.txt"), {async = true}) + assert(files and #files == 2) + print("async enumerate: %d files", #files) + + os.cp(srcdir, dstdir, {async = true}) + assert(os.isdir(dstdir)) + print("async copy done: %s", dstdir) + + files = os.files(path.join(dstdir, "*.txt"), {async = true}) + assert(files and #files == 2) + + os.rm(dstdir, {async = true}) + assert(not os.isdir(dstdir)) + print("dst removed async") + + os.rm(srcdir, {async = true}) + os.tryrm(root) + print("async copy test finished") +end + |
