mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
👌 Add delay
global function
This commit is contained in:
@ -49,3 +49,11 @@ func grepContains(file: String, query: String) async -> Bool {
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
.contains("YES")
|
||||
}
|
||||
|
||||
/**
|
||||
Attempts to introduce sleep for a particular duration. Use with caution.
|
||||
Only intended for testing purposes.
|
||||
*/
|
||||
func delay(seconds: Double) async {
|
||||
try! await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))
|
||||
}
|
||||
|
@ -92,8 +92,7 @@ class SystemShell: Shellable {
|
||||
// (in order to debug or identify async issues)
|
||||
if ProcessInfo.processInfo.environment["SLOW_SHELL_MODE"] != nil {
|
||||
print("[SLOW SHELL] \(command)")
|
||||
let delayInSeconds = 3
|
||||
try! await Task.sleep(nanoseconds: UInt64(delayInSeconds * 1_000_000_000))
|
||||
await delay(seconds: 3.0)
|
||||
}
|
||||
|
||||
task.standardOutput = outputPipe
|
||||
|
@ -37,8 +37,7 @@ public class TestableShell: Shellable {
|
||||
// Seriously slow down the shell's return rate in order to debug or identify async issues
|
||||
if ProcessInfo.processInfo.environment["SLOW_SHELL_MODE"] != nil {
|
||||
print("[SLOW SHELL] \(command)")
|
||||
let delayInSeconds = 3
|
||||
try! await Task.sleep(nanoseconds: UInt64(delayInSeconds * 1_000_000_000))
|
||||
await delay(seconds: 3.0)
|
||||
}
|
||||
|
||||
// This assertion will only fire during test builds
|
||||
@ -100,8 +99,7 @@ struct BatchFakeShellOutput {
|
||||
|
||||
for item in items {
|
||||
if !ignoreDelay {
|
||||
let delay = UInt64(item.delay * 1_000_000_000)
|
||||
try! await Task.sleep(nanoseconds: delay)
|
||||
await delay(seconds: item.delay)
|
||||
}
|
||||
|
||||
if item.stream == .stdErr {
|
||||
|
Reference in New Issue
Block a user