From c0b044c6c578fe281b689bcd93cffb9def24e967 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Thu, 9 Nov 2017 01:27:03 -0800 Subject: [PATCH] Use WaitForExit(timeout) rather than loop on HasExited property for some tests (#3906) * bump * Remove reliance on HasExited, instead use WaitForExit(timeout) * Huge timeout in fcs tests * Remove bump space * Replace scary computed constants with hipster TimeSpans * fix comment * Of course TotalMilliseconds is float and Milliseconds is int --- use Milliseconds * Use the Timespan APIs correctly --- tests/fsharpqa/Source/CodeGen/Structure/DoNotInlineX.fs | 8 +++++--- tests/service/FscTests.fs | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/fsharpqa/Source/CodeGen/Structure/DoNotInlineX.fs b/tests/fsharpqa/Source/CodeGen/Structure/DoNotInlineX.fs index 058daf815..6c4a6447e 100644 --- a/tests/fsharpqa/Source/CodeGen/Structure/DoNotInlineX.fs +++ b/tests/fsharpqa/Source/CodeGen/Structure/DoNotInlineX.fs @@ -4,6 +4,8 @@ open System open System.Diagnostics open System.IO +let longtime = int(System.TimeSpan.FromSeconds(30.0).TotalMilliseconds) // longtime is 30 seconds + let programFiles = let pf86 = Environment.GetEnvironmentVariable("ProgramFiles(x86)") if String.IsNullOrEmpty(pf86) then Environment.GetEnvironmentVariable("ProgramFiles") else pf86 @@ -26,7 +28,7 @@ let start (p1 : string) = Process.Start(p1) let CompileFile file args = let p = Process.Start(fsc, file + " " + args) - while not (p.HasExited) do () + p.WaitForExit() [] let main (args : string[]) = @@ -40,13 +42,13 @@ let main (args : string[]) = printfn "Compiled DerivedType with %A" derivedFlag let r1 = start "DerivedType.exe" - while not r1.HasExited do () + r1.WaitForExit(longtime) printfn "Ran DerivedType.exe with result: %A" r1.ExitCode CompileFile "BaseType.fs" "-a" printfn "Compiled BaseType without %A" baseFlag let r2 = start "DerivedType.exe" - while not r2.HasExited do () + r2.WaitForExit(longtime) printfn "Ran DerivedType.exe with result: %A" r2.ExitCode if r1.ExitCode = expectedResult1 && r2.ExitCode = expectedResult2 then 0 else 1 diff --git a/tests/service/FscTests.fs b/tests/service/FscTests.fs index 97f1ee759..ca3d3999e 100644 --- a/tests/service/FscTests.fs +++ b/tests/service/FscTests.fs @@ -76,6 +76,8 @@ type PEVerifier () = #endif static let execute (fileName : string, arguments : string) = + // Peverify may run quite a while some assemblies are pretty big. Make the timeout 3 minutes just in case. + let longtime = int (TimeSpan.FromMinutes(3.0).TotalMilliseconds) printfn "executing '%s' with arguments %s" fileName arguments let psi = new ProcessStartInfo(fileName, arguments) psi.UseShellExecute <- false @@ -87,7 +89,7 @@ type PEVerifier () = use proc = Process.Start(psi) let stdOut = proc.StandardOutput.ReadToEnd() let stdErr = proc.StandardError.ReadToEnd() - while not proc.HasExited do () + proc.WaitForExit(longtime) proc.ExitCode, stdOut, stdErr member __.Verify(assemblyPath : string) = -- GitLab