Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers for dotnet test #1311

Merged
merged 2 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 4.33.10 - 21.07.2016
* DotNet version support - https://github.com/fsharp/FAKE/pull/1310

#### 4.33.0 - 21.07.2016
* DotNet restore support - https://github.com/fsharp/FAKE/pull/1309
* BUGFIX: Update DACPAC module - https://github.com/fsharp/FAKE/pull/1307
Expand Down
62 changes: 59 additions & 3 deletions src/app/FakeLib/DotNetCLIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let isInstalled() =

processResult.OK

/// DotNet Restore parameters
/// DotNet restore parameters
type RestoreParams = {
/// ToolPath - usually just "dotnet"
ToolPath: string
Expand Down Expand Up @@ -61,7 +61,7 @@ let private DefaultRestoreParams : RestoreParams = {
/// { p with
/// NoCache = true })
let Restore (setRestoreParams: RestoreParams -> RestoreParams) =
traceStartTask "DotNetRestore" ""
traceStartTask "DotNet.Restore" ""

try
let parameters = setRestoreParams DefaultRestoreParams
Expand All @@ -78,4 +78,60 @@ let Restore (setRestoreParams: RestoreParams -> RestoreParams) =
then
failwithf "Restore failed on %s" args
finally
traceEndTask "DotNetRestore" ""
traceEndTask "DotNet.Restore" ""

/// DotNet test parameters
type TestParams = {
/// ToolPath - usually just "dotnet"
ToolPath: string

/// Working directory (optional).
WorkingDir: string

/// A timeout for the command.
TimeOut: TimeSpan

/// The build configuration.
Configuration : string
}

let private DefaultTestParams : TestParams = {
ToolPath = commandName
WorkingDir = Environment.CurrentDirectory
Configuration = "Release"
TimeOut = TimeSpan.FromMinutes 30.
}

/// Runs the dotnet "test" command.
/// ## Parameters
///
/// - `setTestParams` - Function used to overwrite the test default parameters.
///
/// ## Sample
///
/// !! "src/test/project.json"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the project.json? dotnet test work on the directory no the file

/// |> DotNet.Test
/// (fun p ->
/// { p with
/// Configuration = "Release" })
let Test (setTestParams: TestParams -> TestParams) projects =
traceStartTask "DotNet.Test" ""

try
for project in projects do
let parameters = setTestParams DefaultTestParams
let args =
new StringBuilder()
|> append "test"
|> append project
|> appendIfNotNullOrEmpty parameters.Configuration "--configuration"
|> toText

if 0 <> ExecProcess (fun info ->
info.FileName <- parameters.ToolPath
info.WorkingDirectory <- parameters.WorkingDir
info.Arguments <- args) parameters.TimeOut
then
failwithf "Test failed on %s" args
finally
traceEndTask "DotNet.Test" ""