Skip to content

Commit

Permalink
fix bug reported on gitter
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Jan 13, 2020
1 parent 3b0a8aa commit 4344fb1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/Fake.Core.Process/CreateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ module CreateProcess =
|> EnvMap.ofSeq
|> Some
Streams =
{ StandardInput = if p.RedirectStandardError then CreatePipe StreamRef.Empty else Inherit
StandardOutput = if p.RedirectStandardError then CreatePipe StreamRef.Empty else Inherit
{ StandardInput = if p.RedirectStandardInput then CreatePipe StreamRef.Empty else Inherit
StandardOutput = if p.RedirectStandardOutput then CreatePipe StreamRef.Empty else Inherit
StandardError = if p.RedirectStandardError then CreatePipe StreamRef.Empty else Inherit
}
Hook = emptyHook
Expand Down
41 changes: 41 additions & 0 deletions src/test/Fake.Core.UnitTests/Fake.Core.Process.fs
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,45 @@ let tests =
|> CreateProcess.fromRawCommandLine "./folder/mytool.exe"
|> getRawCommandLine
Expect.equal actual original "Expected to retrieve exact match"

yield testCase "Test CreateProcess.ofStartInfo with different streams - reported on gitter" <| fun _ ->
let isRedirected s =
match s with
| StreamSpecification.Inherit -> false
| _ -> true

let si = System.Diagnostics.ProcessStartInfo()
let actual =
si
|> CreateProcess.ofStartInfo
Expect.isFalse (isRedirected actual.Streams.StandardInput) "Expect Std Input to be NOT redirected"
Expect.isFalse (isRedirected actual.Streams.StandardOutput) "Expect Std Output to be NOT redirected"
Expect.isFalse (isRedirected actual.Streams.StandardError) "Expect Std Error to be NOT redirected"

let si = System.Diagnostics.ProcessStartInfo()
si.RedirectStandardInput <- true
let actual =
si
|> CreateProcess.ofStartInfo
Expect.isTrue (isRedirected actual.Streams.StandardInput) "Expect Std Input to be redirected"
Expect.isFalse (isRedirected actual.Streams.StandardOutput) "Expect Std Output to be NOT redirected"
Expect.isFalse (isRedirected actual.Streams.StandardError) "Expect Std Error to be NOT redirected"

let si = System.Diagnostics.ProcessStartInfo()
si.RedirectStandardOutput <- true
let actual =
si
|> CreateProcess.ofStartInfo
Expect.isFalse (isRedirected actual.Streams.StandardInput) "Expect Std Input to be NOT redirected"
Expect.isTrue (isRedirected actual.Streams.StandardOutput) "Expect Std Output to be redirected"
Expect.isFalse (isRedirected actual.Streams.StandardError) "Expect Std Error to be NOT redirected"

let si = System.Diagnostics.ProcessStartInfo()
si.RedirectStandardError <- true
let actual =
si
|> CreateProcess.ofStartInfo
Expect.isFalse (isRedirected actual.Streams.StandardInput) "Expect Std Input to be NOT redirected"
Expect.isFalse (isRedirected actual.Streams.StandardOutput) "Expect Std Output to be NOT redirected"
Expect.isTrue (isRedirected actual.Streams.StandardError) "Expect Std Error to be redirected"
]
3 changes: 2 additions & 1 deletion src/test/Fake.ExpectoSupport/ExpectoHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ module ExpectoHelpers =
let! result = Task.WhenAny(t, delay) |> Async.AwaitTask
if result = delay then
Expecto.Tests.failtestf "Test '%s' timed out" labelPath
return result.GetAwaiter().GetResult()
}

match test with
| Expecto.Sync test -> async { test() } |> timeoutAsync |> Expecto.Async
| Expecto.SyncWithCancel test ->
Expecto.SyncWithCancel (fun ct ->
Async.StartImmediate(async { test ct } |> timeoutAsync)
Async.StartImmediate(async { test (CancellationToken.None) } |> timeoutAsync)
)
| Expecto.Async test -> timeoutAsync test |> Expecto.Async
| Expecto.AsyncFsCheck (testConfig, stressConfig, test) ->
Expand Down

0 comments on commit 4344fb1

Please sign in to comment.