summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-04 22:31:52 +0800
committerruki <[email protected]>2025-11-07 15:01:57 +0800
commit642dd2b624ff57874def40faba72b1bd4dddfab1 (patch)
treed2d78b12cba117339802cd2e6d2de9fd44a44c43 /tests/modules
parent5511722baa97e852b83227c2fde12039108fbbc1 (diff)
improve os tests
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/os/test.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua
index 92890a234..1207cb615 100644
--- a/tests/modules/os/test.lua
+++ b/tests/modules/os/test.lua
@@ -149,3 +149,25 @@ function test_args(t)
t:are_equal(os.args({'-DTEST="hello world"', '-DTEST2="hello world2"'}), '"-DTEST=\\\"hello world\\\"" "-DTEST2=\\\"hello world2\\\""')
end
+function test_async(t)
+ local tmpdir = os.tmpfile() .. ".dir"
+ local tmpdir2 = os.tmpfile() .. ".dir"
+ io.writefile(path.join(tmpdir, "foo.txt"), "foo")
+ io.writefile(path.join(tmpdir, "bar.txt"), "bar")
+ local files = os.files(path.join(tmpdir, "*.txt"), {async = true})
+ t:require(files and #files == 2)
+
+ os.cp(tmpdir, tmpdir2, {async = true, detach = true})
+ t:require(not os.isdir(tmpdir2))
+
+ os.cp(tmpdir, tmpdir2, {async = true})
+ t:require(os.isdir(tmpdir2))
+
+ t:require(os.isdir(tmpdir))
+ os.rm(tmpdir, {async = true})
+ t:require(not os.isdir(tmpdir))
+
+ t:require(os.isdir(tmpdir2))
+ os.rm(tmpdir2, {async = true, detach = true})
+ t:require(os.isdir(tmpdir2))
+end