Skip to content

Commit

Permalink
bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Mar 25, 2018
1 parent a0bf909 commit c4c0271
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 5.0.0-beta029

* BUGFIX: Fix mono version detection on netcore.

## 5.0.0-beta028

* ENHANCEMENT: Fix API Guidelines on various modules
Expand Down
2 changes: 0 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ BuildServer.install [
TeamFoundation.Installer
]

Trace.traceFAKE "MsBuild: %s" MsBuild.msBuildExe

let dotnetSdk = lazy DotNet.install DotNet.Release_2_1_4
let inline dtntWorkDir wd =
DotNet.Options.lift dotnetSdk.Value
Expand Down
17 changes: 10 additions & 7 deletions src/app/Fake.Core.Process/Process.fs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ module Process =
try
if shouldEnableProcessTracing() && (not <| proc.StartInfo.FileName.EndsWith "fsi.exe") then
Trace.tracefn "%s %s" proc.StartInfo.FileName proc.StartInfo.Arguments
startProcess proc
if not (startProcess proc) then
failwithf "Could not start process (start returned false)."
with ex -> raise <| exn(sprintf "Start of process %s failed." proc.StartInfo.FileName, ex)
if silent then
proc.BeginErrorReadLine()
Expand All @@ -440,10 +441,10 @@ module Process =
if not <| proc.WaitForExit(int timeOut.TotalMilliseconds) then
try
proc.Kill()
with exn ->
with exn ->
Trace.traceError
<| sprintf "Could not kill process %s %s after timeout." proc.StartInfo.FileName
proc.StartInfo.Arguments
<| sprintf "Could not kill process %s %s after timeout: %O" proc.StartInfo.FileName
proc.StartInfo.Arguments exn
failwithf "Process %s %s timed out." proc.StartInfo.FileName proc.StartInfo.Arguments
// See http://stackoverflow.com/a/16095658/1149924 why WaitForExit must be called twice.
proc.WaitForExit()
Expand All @@ -464,7 +465,7 @@ module Process =

let exitCode =
execRaw configProcessStartInfoF timeOut true (appendMessage true) (appendMessage false)
ProcessResult.New exitCode !messages
ProcessResult.New exitCode (!messages |> List.rev)

/// Runs the given process and returns the exit code.
/// ## Parameters
Expand Down Expand Up @@ -516,7 +517,8 @@ module Process =
let directExec configProcessStartInfoF =
use proc = getProc configProcessStartInfoF
try
startProcess proc
if not (startProcess proc) then
failwithf "Could not start process (start returned false)."
with ex -> raise <| exn(sprintf "Start of process %s failed." proc.StartInfo.FileName, ex)
proc.WaitForExit()
proc.ExitCode = 0
Expand Down Expand Up @@ -690,7 +692,8 @@ module Process =
if not (isNull e.Data) then Trace.traceError e.Data)
proc.OutputDataReceived.Add(fun e ->
if not (isNull e.Data) then Trace.log e.Data)
startProcess proc
if not (startProcess proc) then
failwithf "Could not start process (start returned false)."
proc.BeginOutputReadLine()
proc.BeginErrorReadLine()
proc.StandardInput.Dispose()
Expand Down
27 changes: 27 additions & 0 deletions src/test/Fake.Core.UnitTests/Fake.Core.Process.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

module Fake.Core.ProcessTests

open System
open Fake.Core
open Expecto
open Expecto.Flip


[<Tests>]
let tests =
testList "Fake.Core.Process.Tests" [
testCase "Test that we can read messages correctly" <| fun _ ->
let shell, command =
if Environment.isWindows then
"cmd", "/C \"echo 1&& echo 2\""
else
"sh", "-c \"echo '1'; echo '2'\""
let result =
Process.execWithResult(fun proc ->
{ proc with
FileName = shell
Arguments = command }) (TimeSpan.FromMinutes 1.)

Expect.equal "Messages are not read correctly" ["1"; "2"] result.Messages

]
2 changes: 2 additions & 0 deletions src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ProjectReference Include="..\..\app\Fake.IO.Zip\Fake.IO.Zip.fsproj" />
<ProjectReference Include="..\..\app\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" />
<ProjectReference Include="..\..\app\Fake.Tools.Git\Fake.Tools.Git.fsproj" />
<ProjectReference Include="..\..\app\Fake.Core.Process\Fake.Core.Process.fsproj" />
<ProjectReference Include="..\..\app\Fake.Core.SemVer\Fake.Core.SemVer.fsproj" />
<ProjectReference Include="..\..\app\Fake.Core.Target\Fake.Core.Target.fsproj" />
<ProjectReference Include="..\..\app\Fake.Core.ReleaseNotes\Fake.Core.ReleaseNotes.fsproj" />
Expand All @@ -18,6 +19,7 @@
<Compile Include="Fake.DotNet.Cli.fs" />
<Compile Include="Fake.Tools.Git.fs" />
<Compile Include="Fake.IO.Zip.fs" />
<Compile Include="Fake.Core.Process.fs" />
<Compile Include="Fake.Core.Target.fs" />
<Compile Include="Fake.Core.ReleaseNotes.fs" />
<Compile Include="Fake.Runtime.fs" />
Expand Down

0 comments on commit c4c0271

Please sign in to comment.