diff options
| author | Saikari <[email protected]> | 2026-02-01 15:03:58 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-01 15:03:58 +0300 |
| commit | 0588ca91219e1ac614e234b7307941ec9b6df161 (patch) | |
| tree | c07414fa48693e0d1c9f9a460dd74a5b44b162ba /tests/modules/stdin/test.lua | |
| parent | 50b428269a657fd0adce1de35b01abe42c13708b (diff) | |
refactor: wrap PowerShell version check in a try block for improved error handling
Diffstat (limited to 'tests/modules/stdin/test.lua')
| -rw-r--r-- | tests/modules/stdin/test.lua | 8 |
1 files changed, 5 insertions, 3 deletions
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") |
