diff options
| author | Saikari <[email protected]> | 2026-02-01 20:42:34 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-01 20:42:34 +0300 |
| commit | c6f69e8df34f2adc620a82036dda48a82fbd15bb (patch) | |
| tree | 720f8a60593f094f1c1a77126d4080bc3230ea93 /tests/modules/stdin | |
| parent | c68524a15b90a0c400930c9ca9c4ba4e7911e569 (diff) | |
refactor: rename temporary xmake directory and update copy command for alias setup
Diffstat (limited to 'tests/modules/stdin')
| -rw-r--r-- | tests/modules/stdin/test.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/modules/stdin/test.lua b/tests/modules/stdin/test.lua index 44d0da2b7..44521d6ad 100644 --- a/tests/modules/stdin/test.lua +++ b/tests/modules/stdin/test.lua @@ -7,10 +7,10 @@ function main(t) -- APE/Cosmocc workaround: force xmake name to avoid APE loader mode issues (e.g. ape-x86_64.elf) local function setup_xmake_alias(xmake) if path.filename(xmake):find("ape-", 1, true) then - local xmake_dir = path.join(os.tmpdir(), "xmake_ape_" .. os.time()) + local xmake_dir = path.join(os.tmpdir(), "xm_alias_" .. os.time()) os.mkdir(xmake_dir) local xmake_alias = path.join(xmake_dir, os.host() == "windows" and "xmake.exe" or "xmake") - os.trycp(xmake, xmake_alias) + os.cp(xmake, xmake_alias) if os.host() ~= "windows" then os.exec("chmod +x " .. xmake_alias) end @@ -19,8 +19,17 @@ function main(t) return xmake end + local is_ape = path.filename(xmake):find("ape-", 1, true) + + -- Fix pwsh and cosmocc "err: ape error: l: not found (maybe chmod +x or ./ needed)" for Linux xmake = setup_xmake_alias(xmake) + local run_stdin = string.format('env "%s" l --stdin', xmake) + -- Fix pwsh and cosmocc "exec format error" for MacOS + if is_ape and os.host() == "macosx" then + run_stdin = string.format('sh -c \\"%s\\"', run_stdin) + end + local function test_shell(name, cmd, expect) print("testing " .. name .. ": " .. cmd) local outfile = os.tmpfile() @@ -115,10 +124,6 @@ function main(t) end if pwsh ~= "" then - local run_stdin = string.format("%s l --stdin", xmake) - if os.host() == "macosx" then - run_stdin = string.format('sh -c \\"%s\\"', run_stdin) - end test_shell( "pwsh_single", string.format('%s -c "echo \\"print(\'hello_pwsh\')\\" | %s"', pwsh, run_stdin), |
