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

Fsi defines #2260

Merged
merged 4 commits into from
Feb 22, 2019
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
12 changes: 9 additions & 3 deletions src/app/Fake.DotNet.Fsi/Fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ type FsiParams = {
(* - LANGUAGE - *)
/// Generate overflow checks
Checked: bool option
/// Define a conditional compilation symbols
/// (Obsolete) Define a conditional compilation symbol (use FsiParams.Definitions instead)
Define: string
/// Define a list of conditional compilation symbols
Definitions: string list
/// Ignore ML compatibility warnings
MLCompatibility: bool

Expand Down Expand Up @@ -147,6 +149,8 @@ with
/// format a compiler arg that ends with "+" or "-" with string parameters "--%s%s:\"%s\""
let inline toglls s b (ls:'a list) =
stringEmptyMap (sprintf "--%s%s:%s" s (chk b)) (String.concat ";" (List.map string ls))
/// format a list of short form complier args using the same symbol
let sargmap sym ls = ls |> List.map (sargp sym)

[
argp "use" p.Use
Expand Down Expand Up @@ -193,7 +197,8 @@ with
togl "readline" p.ReadLine
togl "quotations-debug" p.QuotationsDebug
togl "shadowcopyreferences" p.ShadowCopyReferences
]
] @ (sargmap "d" p.Definitions)

|> List.filter String.isNotNullOrEmpty

static member Create() =
Expand All @@ -218,6 +223,7 @@ with
ConsoleColors = None
Checked = None
Define = null
Definitions = []
MLCompatibility = false
NoLogo = false
Help = false
Expand Down Expand Up @@ -279,7 +285,7 @@ module internal ExternalFsi =
{ info.WithEnvironmentVariables defaultEnvironmentVars with
FileName = fsiExe
Arguments = args
WorkingDirectory = ""
WorkingDirectory = parameters.WorkingDirectory
Copy link
Member

Choose a reason for hiding this comment

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

This is a bugfix as well, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, changing the WorkingDirectory parameter was always ignored.

}.WithEnvironmentVariables (parameters.Environment |> Map.toSeq)) TimeSpan.MaxValue

if r.ExitCode <> 0 then
Expand Down
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 @@
<ItemGroup>
<ProjectReference Include="..\..\app\Fake.DotNet.AssemblyInfoFile\Fake.DotNet.AssemblyInfoFile.fsproj" />
<ProjectReference Include="..\..\app\Fake.DotNet.Cli\Fake.DotNet.Cli.fsproj" />
<ProjectReference Include="..\..\app\Fake.DotNet.Fsi\Fake.DotNet.Fsi.fsproj" />
<ProjectReference Include="..\..\app\Fake.DotNet.ILMerge\Fake.DotNet.ILMerge.fsproj" />
<ProjectReference Include="..\..\app\Fake.DotNet.FxCop\Fake.DotNet.FxCop.fsproj" />
<ProjectReference Include="..\..\app\Fake.IO.Zip\Fake.IO.Zip.fsproj" />
Expand Down Expand Up @@ -39,6 +40,7 @@
<Compile Include="Fake.DotNet.MSBuild.fs" />
<Compile Include="Fake.DotNet.Testing.NUnit.fs" />
<Compile Include="Fake.DotNet.Testing.SpecFlow.fs" />
<Compile Include="Fake.DotNet.Fsi.fs" />
<Compile Include="Fake.DotNet.Xdt.fs" />
<Compile Include="Fake.Testing.ReportGenerator.fs" />
<Compile Include="Fake.Tools.Git.fs" />
Expand Down
32 changes: 32 additions & 0 deletions src/test/Fake.Core.UnitTests/Fake.DotNet.Fsi.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Fake.DotNet.FsiTests

open Fake.DotNet
open Expecto

[<Tests>]
let tests =
let isDefine (s : string) = s.StartsWith "-d:"

testList "Fake.DotNet.Fsi.Tests" [
testCase "Test that default params have no defines" <| fun _ ->
let cmdList = Fsi.FsiParams.Create() |> Fsi.FsiParams.ToArgsList
Expect.isFalse (cmdList |> List.exists isDefine) "FsiParams.Create() |> FsiParams.ToArgsList should not specify -d"

testCase "Test that Define alone adds one -d flag" <| fun _ ->
let cmdList = { Fsi.FsiParams.Create() with Define = "DEBUG" } |> Fsi.FsiParams.ToArgsList
Expect.contains cmdList "-d:DEBUG" "Define=\"DEBUG\" should create the -d:DEBUG parameter"
Expect.hasCountOf cmdList 1u isDefine "Define should create only one -d parameter"

testCase "Test that Definitions alone adds the -d flags" <| fun _ ->
let cmdList = { Fsi.FsiParams.Create() with Definitions = ["DEBUG"; "GUBED"] } |> Fsi.FsiParams.ToArgsList
Expect.contains cmdList "-d:DEBUG" "Definitions = [\"DEBUG\"; \"GUBED\"] should create the -d:DEBUG parameter"
Expect.contains cmdList "-d:GUBED" "Definitions = [\"DEBUG\"; \"GUBED\"] should create the -d:GUBED parameter"
Expect.hasCountOf cmdList 2u isDefine "Definitions should create both -d parameters"

testCase "Test that Definitions can be used together with Define" <| fun _ ->
let cmdList = { Fsi.FsiParams.Create() with Definitions = ["DEBUG"; "GUBED"]; Define="BEDUG" } |> Fsi.FsiParams.ToArgsList
Expect.contains cmdList "-d:DEBUG" "Definitions = [\"DEBUG\"; \"GUBED\"] should create the -d:DEBUG parameter"
Expect.contains cmdList "-d:GUBED" "Definitions = [\"DEBUG\"; \"GUBED\"] should create the -d:GUBED parameter"
Expect.contains cmdList "-d:BEDUG" "Define=\"BEDUG\" should create the -d:BEDUG parameter"
Expect.hasCountOf cmdList 3u isDefine "Define and Definitions should all create -d parameters"
]