From e8da60b8c43a51de8a54220b7c698545a669b9f2 Mon Sep 17 00:00:00 2001 From: Mark Lambert Date: Thu, 21 Feb 2019 11:22:26 +0000 Subject: [PATCH 1/4] Fixes #2259 - add a Defines list to FsiParams to specify multiple conditional compile symbols --- src/app/Fake.DotNet.Fsi/Fsi.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/Fake.DotNet.Fsi/Fsi.fs b/src/app/Fake.DotNet.Fsi/Fsi.fs index c4121829890..cd529da70b9 100644 --- a/src/app/Fake.DotNet.Fsi/Fsi.fs +++ b/src/app/Fake.DotNet.Fsi/Fsi.fs @@ -75,8 +75,10 @@ type FsiParams = { (* - LANGUAGE - *) /// Generate overflow checks Checked: bool option - /// Define a conditional compilation symbols + /// Define a conditional compilation symbol Define: string + /// Define a list of conditional compilation symbols + Definitions: string list /// Ignore ML compatibility warnings MLCompatibility: bool @@ -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 @@ -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() = @@ -218,6 +223,7 @@ with ConsoleColors = None Checked = None Define = null + Definitions = [] MLCompatibility = false NoLogo = false Help = false From 43a40eed687782abf516812a1734dcb18f0e6241 Mon Sep 17 00:00:00 2001 From: Mark Lambert Date: Thu, 21 Feb 2019 12:29:59 +0000 Subject: [PATCH 2/4] WorkingDirectory was not being passed to Pcoess.execWithResult --- src/app/Fake.DotNet.Fsi/Fsi.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Fake.DotNet.Fsi/Fsi.fs b/src/app/Fake.DotNet.Fsi/Fsi.fs index cd529da70b9..e7526bc93ac 100644 --- a/src/app/Fake.DotNet.Fsi/Fsi.fs +++ b/src/app/Fake.DotNet.Fsi/Fsi.fs @@ -285,7 +285,7 @@ module internal ExternalFsi = { info.WithEnvironmentVariables defaultEnvironmentVars with FileName = fsiExe Arguments = args - WorkingDirectory = "" + WorkingDirectory = parameters.WorkingDirectory }.WithEnvironmentVariables (parameters.Environment |> Map.toSeq)) TimeSpan.MaxValue if r.ExitCode <> 0 then From b3a3486e7d65857da846c3fe7e91f0b8e5a2982b Mon Sep 17 00:00:00 2001 From: Mark Lambert Date: Thu, 21 Feb 2019 14:20:51 +0000 Subject: [PATCH 3/4] Add tests for FsiParams Define / Definitions --- .../Fake.Core.UnitTests.fsproj | 2 ++ .../Fake.Core.UnitTests/Fake.DotNet.Fsi.fs | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/test/Fake.Core.UnitTests/Fake.DotNet.Fsi.fs diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj index b9385613ca2..a0968bd7440 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj +++ b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj @@ -8,6 +8,7 @@ + @@ -39,6 +40,7 @@ + diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.Fsi.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.Fsi.fs new file mode 100644 index 00000000000..92a151b594a --- /dev/null +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.Fsi.fs @@ -0,0 +1,32 @@ +module Fake.DotNet.FsiTests + +open Fake.DotNet +open Expecto + +[] +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" + ] From 3f2f75d74e3ec0f88f9d36981d0e2347d8998535 Mon Sep 17 00:00:00 2001 From: Mark Lambert Date: Fri, 22 Feb 2019 09:48:17 +0000 Subject: [PATCH 4/4] Update comment to suggest using Definitions instead of Define. --- src/app/Fake.DotNet.Fsi/Fsi.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Fake.DotNet.Fsi/Fsi.fs b/src/app/Fake.DotNet.Fsi/Fsi.fs index e7526bc93ac..9dcf8689fd8 100644 --- a/src/app/Fake.DotNet.Fsi/Fsi.fs +++ b/src/app/Fake.DotNet.Fsi/Fsi.fs @@ -75,7 +75,7 @@ type FsiParams = { (* - LANGUAGE - *) /// Generate overflow checks Checked: bool option - /// Define a conditional compilation symbol + /// (Obsolete) Define a conditional compilation symbol (use FsiParams.Definitions instead) Define: string /// Define a list of conditional compilation symbols Definitions: string list