summaryrefslogtreecommitdiff
path: root/tests/modules/stdin/test.lua
diff options
context:
space:
mode:
authorSaikari <[email protected]>2026-02-02 05:02:58 +0300
committerSaikari <[email protected]>2026-02-02 05:02:58 +0300
commitc6aa73fa21bba45a591aa185b4d4a3648417b35f (patch)
treee75ce220e8b798cf4171de309363eafef5d5a3f9 /tests/modules/stdin/test.lua
parent7629549db84dc57a7c5e71b93ec9baf628be5e7e (diff)
refactor: enhance path resolution for xmake and improve MacOS stdin command handling
Diffstat (limited to 'tests/modules/stdin/test.lua')
-rw-r--r--tests/modules/stdin/test.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/modules/stdin/test.lua b/tests/modules/stdin/test.lua
index 9911048d5..8aac5a38e 100644
--- a/tests/modules/stdin/test.lua
+++ b/tests/modules/stdin/test.lua
@@ -1,8 +1,18 @@
function main(t)
+ local function resolve_path(p)
+ if path.is_absolute(p) then return p end
+ local root = path.join(os.scriptdir(), "../../..")
+ local p_root = path.join(root, p)
+ if os.isfile(p_root) then return path.absolute(p_root) end
+ if os.isfile(p) then return path.absolute(p) end
+ return p
+ end
+
local xmake = path.unix(os.programfile())
if os.host() == "windows" then
xmake = xmake:gsub("/", "\\")
end
+ xmake = resolve_path(xmake)
-- Fix /usr/bin/ape loader mode on Linux
local function fix_ape_programfile(xmake)
@@ -18,9 +28,7 @@ function main(t)
end
if #args >= 2 and path.unix(args[1]) == xmake then
xmake = path.unix(args[2])
- if not path.is_absolute(xmake) then
- xmake = path.absolute(xmake)
- end
+ xmake = resolve_path(xmake)
end
end
end
@@ -31,13 +39,12 @@ function main(t)
-- Fix pwsh and cosmocc "err: ape error: l: not found (maybe chmod +x or ./ needed)" for Linux
xmake = fix_ape_programfile(xmake)
- local is_ape = path.filename(xmake):find("ape-", 1, true)
- print("Using xmake programfile is_ape = ", is_ape)
+ local is_ape = path.filename(xmake):find("ape-", 1, true) ~= nil
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() ~= "windows" then
- run_stdin = string.format("sh -c ' \\\"%s\\\" l --stdin '", xmake)
+ run_stdin = string.format("sh -c ' \"%s\" l --stdin '", xmake)
end
local function test_shell(name, cmd, expect)