From 0588ca91219e1ac614e234b7307941ec9b6df161 Mon Sep 17 00:00:00 2001 From: Saikari Date: Sun, 1 Feb 2026 15:03:58 +0300 Subject: refactor: wrap PowerShell version check in a try block for improved error handling --- tests/modules/stdin/test.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/modules/stdin/test.lua') diff --git a/tests/modules/stdin/test.lua b/tests/modules/stdin/test.lua index bcd9efca6..89e6e5a38 100644 --- a/tests/modules/stdin/test.lua +++ b/tests/modules/stdin/test.lua @@ -53,9 +53,11 @@ if os.host() == "windows" then test_shell("cmd_multi", string.format('cmd /c echo "print(\'line1\')\\nprint(\'line2\')" | %s l --stdin', xmake), "line1[\r\n]+line2") -- Test powershell (if available) local pwsh = "powershell" - if os.exec("pwsh -v") == 0 then - pwsh = "pwsh" - end + try { function () + if os.exec("pwsh -v") == 0 then + pwsh = "pwsh" + end + end } test_shell("pwsh_single", string.format('%s -c "echo \\"print(\'hello_pwsh\')\\" | %s l --stdin"', pwsh, xmake), "hello_pwsh") test_shell("pwsh_calc", string.format('%s -c "echo \\"local f = 1+1; print(f)\\" | %s l --stdin"', pwsh, xmake), "2") test_shell("pwsh_multi", string.format('%s -c "echo \\"print(\'pline1\')\\nprint(\'pline2\')\\" | %s l --stdin"', pwsh, xmake), "pline1[\r\n]+pline2") -- cgit v1.3.1