diff --git a/WoofWare.Expect.Test/TestDot.fs b/WoofWare.Expect.Test/TestDot.fs index 19b927e..65678f8 100644 --- a/WoofWare.Expect.Test/TestDot.fs +++ b/WoofWare.Expect.Test/TestDot.fs @@ -61,6 +61,7 @@ module TestDot = let mutable started = false let mutable waited = false + let mutable exitCodeObserved = false let mutable disposed = false let expected = @@ -84,7 +85,7 @@ module TestDot = member _.Create exe args = exe |> shouldEqual "graph-easy" - args.StartsWith ("--as=boxarg --from=dot ", StringComparison.Ordinal) + args.StartsWith ("--as=boxart --from=dot ", StringComparison.Ordinal) |> shouldEqual true { new IDisposable with @@ -93,6 +94,10 @@ module TestDot = member _.WaitForExit p = waited <- true member _.ReadStandardOutput _ = expected + + member _.ExitCode _ = + exitCodeObserved <- true + 0 } Dot.render' pr (toFs fs) "graph-easy" contents @@ -101,4 +106,5 @@ module TestDot = started |> shouldEqual true waited |> shouldEqual true + exitCodeObserved |> shouldEqual true disposed |> shouldEqual true diff --git a/WoofWare.Expect/Dot.fs b/WoofWare.Expect/Dot.fs index cf46ee0..7a80f51 100644 --- a/WoofWare.Expect/Dot.fs +++ b/WoofWare.Expect/Dot.fs @@ -17,6 +17,8 @@ module Dot = abstract WaitForExit : 'Process -> unit /// Equivalent to Process.StandardOutput.ReadToEnd abstract ReadStandardOutput : 'Process -> string + /// Equivalent to Process.ExitCode + abstract ExitCode : 'Process -> int /// The real Process interface, in a form that can be passed to `render'`. let process' = @@ -32,6 +34,7 @@ module Dot = member _.Start p = p.Start () member _.WaitForExit p = p.WaitForExit () member _.ReadStandardOutput p = p.StandardOutput.ReadToEnd () + member _.ExitCode p = p.ExitCode } /// A mock for System.IO @@ -66,11 +69,17 @@ module Dot = try fs.WriteFile tempFile dotFileContents - use p = pr.Create graphEasyExecutable ("--as=boxarg --from=dot " + tempFile) + use p = pr.Create graphEasyExecutable ("--as=boxart --from=dot " + tempFile) pr.Start p |> ignore pr.WaitForExit p - "\n" + pr.ReadStandardOutput p + let stdout = pr.ReadStandardOutput p + let exitCode = pr.ExitCode p + + if exitCode <> 0 then + failwithf "failed to run; exit code: %i. stdout:\n%s" exitCode stdout + + "\n" + stdout finally try fs.DeleteFile tempFile diff --git a/WoofWare.Expect/SurfaceBaseline.txt b/WoofWare.Expect/SurfaceBaseline.txt index 83e3327..089baf1 100644 --- a/WoofWare.Expect/SurfaceBaseline.txt +++ b/WoofWare.Expect/SurfaceBaseline.txt @@ -55,8 +55,9 @@ WoofWare.Expect.Dot+IFileSystem - interface with 3 member(s) WoofWare.Expect.Dot+IFileSystem.DeleteFile [method]: string -> unit WoofWare.Expect.Dot+IFileSystem.GetTempFileName [method]: unit -> string WoofWare.Expect.Dot+IFileSystem.WriteFile [method]: string -> string -> unit -WoofWare.Expect.Dot+IProcess`1 - interface with 4 member(s) +WoofWare.Expect.Dot+IProcess`1 - interface with 5 member(s) WoofWare.Expect.Dot+IProcess`1.Create [method]: string -> string -> #(IDisposable) +WoofWare.Expect.Dot+IProcess`1.ExitCode [method]: #(IDisposable) -> int WoofWare.Expect.Dot+IProcess`1.ReadStandardOutput [method]: #(IDisposable) -> string WoofWare.Expect.Dot+IProcess`1.Start [method]: #(IDisposable) -> bool WoofWare.Expect.Dot+IProcess`1.WaitForExit [method]: #(IDisposable) -> unit