Skip to content

Commit

Permalink
Update spawn.luau
Browse files Browse the repository at this point in the history
Fixed args being different for linux and macOs for sleep test
  • Loading branch information
SnorlaxAssist authored Sep 20, 2023
1 parent cb9f1cb commit 6bce250
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/process/spawn.luau
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ assert(homeDir1 == homeDir2, "Home dirs did not match when performing tilde subs
than a single sleep but also less than 1.5 sleeps
]]

-- We need to account for the time it takes to spawn a process for Windows
-- We need to account for the time it takes to spawn a process, because of Windows
local commandExecutionTolarance = 0 do
if isWindows then
local commandExecutionStart = os.clock()
process.spawn("sleep", {"0"}, if isWindows then { shell = true } else nil)
commandExecutionTolarance = os.clock() - commandExecutionStart
end
local commandExecutionStart = os.clock()
process.spawn("sleep", {"0"}, if isWindows then { shell = true } else nil)
commandExecutionTolarance = os.clock() - commandExecutionStart
end

local SLEEP_DURATION = 1 / 4
Expand All @@ -129,11 +127,14 @@ local sleepCounter = 0
for i = 1, SLEEP_SAMPLES, 1 do
task.spawn(function()
-- Windows does not have a sleep command, so we use shell instead.
process.spawn("sleep", {
-- Sleep command on Windows in Seconds has some weird behavior with decimals.
if isWindows then "-Milliseconds" else nil::any,
local args = {
tostring(SLEEP_DURATION * (isWindows and 1000 or 1))
}, if isWindows then { shell = true } else nil)
};
if isWindows then
-- Sleep command on Windows in Seconds has some weird behavior with decimals.
table.insert(args, 1, "-Milliseconds");
end
process.spawn("sleep", args, if isWindows then { shell = true } else nil)
sleepCounter += 1
end)
end
Expand Down

0 comments on commit 6bce250

Please sign in to comment.