Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
asvili committed Dec 13, 2016
1 parent ae2af99 commit 3a10a13
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/app/FakeLib/UnitTest/Expecto/Expecto.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[<AutoOpen>]
/// Contains tasks to run [xUnit](https://github.com/haf/expecto) v2 unit tests.
/// Contains tasks to run [expecto](https://github.com/haf/expecto) v2 unit tests.
module Fake.Testing.Expecto

open System
Expand Down Expand Up @@ -29,17 +28,17 @@ type ExpectoParams =
}
override this.ToString() =
let append (s: string) (sb: StringBuilder) = sb.Append s
let appendIfTrue p s sb =
let appendIfTrue p s sb =
if p then append s sb else sb
let appendIfNotNullOrWhiteSpace p s (sb: StringBuilder) =
if String.IsNullOrWhiteSpace p |> not
let appendIfNotNullOrWhiteSpace p s (sb: StringBuilder) =
if String.IsNullOrWhiteSpace p |> not
then sprintf "%s%s " s p |> sb.Append
else sb
let appendList list s (sb: StringBuilder) =
let appendList list s (sb: StringBuilder) =
let filtered = list |> List.filter (String.IsNullOrWhiteSpace >> not)
if List.isEmpty filtered then sb
else
filtered |> String.concat " " |> sprintf "%s%s " s |> sb.Append
filtered |> separated " " |> sprintf "%s%s " s |> sb.Append
StringBuilder()
|> appendIfTrue this.Debug "--debug "
|> appendIfTrue this.Parallel "--parallel "
Expand All @@ -50,7 +49,7 @@ type ExpectoParams =
|> appendList this.Run "--run "
|> toText

static member defaultParams =
static member DefaultParams =
{
Debug = false
Parallel = true
Expand All @@ -63,20 +62,21 @@ type ExpectoParams =
}

let Expecto (setParams : ExpectoParams -> ExpectoParams) (assemblies : string seq) =
let args = setParams ExpectoParams.defaultParams
let args = setParams ExpectoParams.DefaultParams
use __ = assemblies |> separated ", " |> traceStartTaskUsing "Expecto"
let argsString = string args
let runAssembly testAssembly =
let processTimeout = TimeSpan.MaxValue // Don't set a process timeout. The timeout is per test.
let workingDir =
if isNotNullOrEmpty args.WorkingDirectory
then args.WorkingDirectory else DirectoryName testAssembly
let processResult =
let exitCode =
ExecProcess(fun info ->
info.FileName <- testAssembly
info.WorkingDirectory <- workingDir
info.Arguments <- argsString
) processTimeout
testAssembly,processResult
testAssembly, exitCode
let res =
assemblies
|> Seq.map runAssembly
Expand Down

0 comments on commit 3a10a13

Please sign in to comment.