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

Allow users of nunit3 set environment variables in the runner #2543

Merged
Merged
Changes from 2 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
10 changes: 9 additions & 1 deletion src/app/Fake.DotNet.Testing.NUnit/NUnit3.fs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ type NUnit3Params =

/// A test parameter specified in the form name=value. Multiple parameters may be specified, separated by semicolons
Params : string

/// list or environment variables that will be set in the nunit-console.exe process
Environment : Map<string, string>
}
/// Sets the current environment variables.
member x.WithEnvironment map =
{ x with Environment = map }

/// The [NUnit3Params](fake-testing-nunit3-nunit3params.html) default parameters.
///
Expand Down Expand Up @@ -245,6 +251,7 @@ type NUnit3Params =
/// - `TraceLevel` - `Default` (By default NUnit3 sets this to off internally)
/// - `SkipNonTestAssemblies` - `false`
/// - `Params` - `""`
/// - `EnvironmentVariables` - `[]`
/// ## Defaults
let NUnit3Defaults =
{
Expand Down Expand Up @@ -273,6 +280,7 @@ let NUnit3Defaults =
TraceLevel= NUnit3TraceLevel.Default
SkipNonTestAssemblies = false
Params = ""
Environment = Map.empty
}

/// Tries to detect the working directory as specified in the parameters or via TeamCity settings
Expand Down Expand Up @@ -330,7 +338,7 @@ let internal createProcess createTempFile (setParams : NUnit3Params -> NUnit3Par
let argLine = Args.toWindowsCommandLine [ (sprintf "@%s" path) ]
CreateProcess.fromRawCommandLine tool argLine
|> CreateProcess.withFramework
|> CreateProcess.withWorkingDirectory (getWorkingDir parameters)
|> CreateProcess.withEnvironment (parameters.Environment |> Map.toList)
Copy link
Member

Choose a reason for hiding this comment

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

We sill want to set the working directory, correct?

//|> CreateProcess.withTimeout processTimeout
|> CreateProcess.addOnSetup (fun () ->
File.WriteAllText(path, generatedArgs)
Expand Down