diff options
| author | ruki <[email protected]> | 2025-11-09 08:28:01 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-09 08:28:01 +0800 |
| commit | a1b0ec856e2c22aac84022feb05b6687912e3d6e (patch) | |
| tree | a4679af3be46069a480be76bdc322eeeefcc4049 /tests/modules/os/test.lua | |
| parent | 0b91f564b00bf22d611a70c17088ba3a155b8a84 (diff) | |
| parent | 91ef5fa9376814db12d35a020008a0d692883945 (diff) | |
Merge pull request #6989 from xmake-io/async
Add async support in os APIs
Diffstat (limited to 'tests/modules/os/test.lua')
| -rw-r--r-- | tests/modules/os/test.lua | 22 |
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 |
