diff options
| author | ruki <[email protected]> | 2026-01-30 22:36:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-30 22:36:58 +0800 |
| commit | c50a3cb891f78c187c8bd862a7e0c3ee9b65d1c4 (patch) | |
| tree | b0dd8e78c1249e0843433bac06b08f52d3883da7 /tests/modules/os/test.lua | |
| parent | 4ce1e34d1fedf281635462ee55d44d174f4ee6b5 (diff) | |
add binutils tests
Diffstat (limited to 'tests/modules/os/test.lua')
| -rw-r--r-- | tests/modules/os/test.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/modules/os/test.lua b/tests/modules/os/test.lua index 2e04e1b35..71e9d610d 100644 --- a/tests/modules/os/test.lua +++ b/tests/modules/os/test.lua @@ -169,3 +169,34 @@ function test_async(t) t:require(os.isdir(tmpdir2)) os.rm(tmpdir2, {async = true, detach = true}) end + +function test_isexec(t) + local tempdir = "temp/isexec" + os.tryrm(tempdir) + os.mkdir(tempdir) + + local programfile = os.programfile() + if programfile then + t:require(os.isexec(programfile)) + end + + local filepath = path.join(tempdir, "script") + io.writefile(filepath, "echo test\n") + + if is_host("windows") then + local batfile = path.join(tempdir, "a.bat") + io.writefile(batfile, "echo test\r\n") + t:require(os.isexec(batfile)) + + local suffix = path.join(tempdir, "prog") + io.writefile(suffix .. ".exe", "") + t:require(os.isexec(suffix)) + else + os.vrunv("chmod", {"-x", filepath}) + t:require_not(os.isexec(filepath)) + os.vrunv("chmod", {"+x", filepath}) + t:require(os.isexec(filepath)) + end + + os.tryrm(tempdir) +end |
