From 1056c09cb31f7e873573d4e0a5a24d06af8297df Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 1 Feb 2026 18:15:24 +0300 Subject: refactor: enhance APE/Cosmocc workaround by creating a temporary xmake alias for compatibility --- tests/modules/stdin/test.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/modules/stdin/test.lua b/tests/modules/stdin/test.lua index d942b7858..162b58d53 100644 --- a/tests/modules/stdin/test.lua +++ b/tests/modules/stdin/test.lua @@ -4,6 +4,20 @@ function main(t) xmake = xmake:gsub("/", "\\") end + -- 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()) + os.mkdir(xmake_dir) + local xmake_alias = path.join(xmake_dir, os.host() == "windows" and "xmake.exe" or "xmake") + os.trycp(xmake, xmake_alias) + return xmake_alias + end + return xmake + end + + xmake = setup_xmake_alias(xmake) + local function test_shell(name, cmd, expect) print("testing " .. name .. ": " .. cmd) local outfile = os.tmpfile() @@ -114,20 +128,12 @@ function main(t) ) test_shell( "pwsh_main", - string.format( - '%s -c "echo \\"function main() print(\'in_pwsh_main\') end\\" | %s"', - pwsh, - run_stdin - ), + string.format('%s -c "echo \\"function main() print(\'in_pwsh_main\') end\\" | %s"', pwsh, run_stdin), "in_pwsh_main" ) test_shell( "pwsh_multi", - string.format( - '%s -c "echo \\"print(\'pline1\')\\" \\"print(\'pline2\')\\" | %s"', - pwsh, - run_stdin - ), + string.format('%s -c "echo \\"print(\'pline1\')\\" \\"print(\'pline2\')\\" | %s"', pwsh, run_stdin), "pline1[\r\n]+pline2" ) end -- cgit v1.3.1