1 Commits

Author SHA1 Message Date
Patrick Stevens
ad05a9c106 Fix typo resulting in failed renders (#24) 2025-07-25 11:35:14 +00:00
3 changed files with 20 additions and 4 deletions

View File

@@ -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

View File

@@ -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<bool>
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

View File

@@ -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