From e1961ff4f5e811bce8849c6297600f7ce9c34b93 Mon Sep 17 00:00:00 2001 From: Ayoub Kaanich Date: Wed, 3 Jan 2024 16:22:15 +0100 Subject: [PATCH] Add timeout --- Test/TestUser.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Test/TestUser.cs b/Test/TestUser.cs index f24d3cac..ded22d92 100644 --- a/Test/TestUser.cs +++ b/Test/TestUser.cs @@ -42,10 +42,11 @@ public static bool Create() private static void Bash(string cmd, params string[] args) { + var arguments = string.Join(" ", args); var info = new ProcessStartInfo { FileName = cmd, - Arguments = string.Join(" ", args), + Arguments = arguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true @@ -57,7 +58,10 @@ private static void Bash(string cmd, params string[] args) process.BeginOutputReadLine(); process.BeginErrorReadLine(); - process.WaitForExit(); + if (!process.WaitForExit(10000)) + { + throw new TimeoutException($"Command '{cmd} {arguments}' timed out"); + } Assert.AreEqual(process.ExitCode, 0); }