From 66e4cb7a7059fcee61ff66970b716d7762334f61 Mon Sep 17 00:00:00 2001 From: Erica Marigold <hi@devcomp.xyz> Date: Thu, 5 Oct 2023 19:00:01 +0530 Subject: [PATCH] chore(tests): fix failing tests on windows (as recommended by @SnorlaxAssist) --- tests/process/spawn.luau | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/process/spawn.luau b/tests/process/spawn.luau index 8f3dd77..1eda09d 100644 --- a/tests/process/spawn.luau +++ b/tests/process/spawn.luau @@ -162,13 +162,18 @@ assert( ) -- Passing stdin strings should work -local stdinChild = process.spawn((((not IS_WINDOWS) and "xargs") or "powershell"), { - "echo", + +local stdinChild = process.spawn(not IS_WINDOWS and "xargs" or "powershell", { + "echo", }, { - stdin = (IS_WINDOWS and (echoMessage .. "\n\n")) or echoMessage, + stdin = echoMessage .. (IS_WINDOWS and "\n\n" or ""), }) +local stdinChildOut = stdinChild.stdout +if IS_WINDOWS then + stdinChildOut = stdinChildOut:sub(#stdinChildOut - #echoMessage - 1, #stdinChildOut) +end assert( - stdinChild.stdout == (((IS_WINDOWS and `{string.char(239)}{string.char(191)}`) or "") .. echoMessage .. "\n"), -- Windows "echo" adds these "escape codes" to strings + stdinChildOut == echoMessage .. trailingAddition, "Stdin passing did not return proper output" )