From b6f0a86add0ab8d63f89a6cb7a27e94f3c8d5faf Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 11:11:22 +0100 Subject: [PATCH 01/26] Add ability to get fake var with a type --- src/app/Fake.Core.Context/Context.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index cc4bf602d33..11192d7e273 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -112,7 +112,7 @@ let forceFakeContext () = invalidOp "no Fake Execution context was found. You can initialize one via Fake.Core.Context.setExecutionContext" | RuntimeContext.Fake e -> e -let getFakeVar name = +let getFakeVar<'a> name = forceFakeContext() |> getFakeContext name |> Option.map (fun o -> o :?> 'a) @@ -145,4 +145,4 @@ let fakeVarAllowNoContext name = (fun (v : 'a) -> if isFakeContext() then setFakeVar name v |> ignore - else varWithoutContext <- Some v) \ No newline at end of file + else varWithoutContext <- Some v) From 5fcfbac25147ea091483b11c2780df1949cea755 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 11:11:45 +0100 Subject: [PATCH 02/26] Add function to get fakevar or fail if not present --- src/app/Fake.Core.Context/Context.fs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 11192d7e273..674d0c844c5 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -116,6 +116,11 @@ let getFakeVar<'a> name = forceFakeContext() |> getFakeContext name |> Option.map (fun o -> o :?> 'a) + +let getFakeVarOrFail<'a> name = + match getFakeVar<'a> name with + | Some v -> v + | _ -> failwithf "Unable to find FakeVar %s" name let removeFakeVar name = forceFakeContext() From a6467abae324689d7f79351351bd5d3d99427058 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 11:12:32 +0100 Subject: [PATCH 03/26] Add get fakevar or default function --- src/app/Fake.Core.Context/Context.fs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 674d0c844c5..2959084f0de 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -121,6 +121,11 @@ let getFakeVarOrFail<'a> name = match getFakeVar<'a> name with | Some v -> v | _ -> failwithf "Unable to find FakeVar %s" name + +let getFakeVarOrDefault<'a> name defaultValue = + match getFakeVar<'a> name with + | Some v -> v + | _ -> defaultValue let removeFakeVar name = forceFakeContext() From 0e0453e3412a158dbeac8b13a93ca21b185c3184 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 11:25:26 +0100 Subject: [PATCH 04/26] Added tests on FakeVar logic --- src/app/Fake.Core.Context/Context.fs | 2 +- .../Fake.Core.UnitTests/Fake.Core.Context.fs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 2959084f0de..29e87524ebc 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -120,7 +120,7 @@ let getFakeVar<'a> name = let getFakeVarOrFail<'a> name = match getFakeVar<'a> name with | Some v -> v - | _ -> failwithf "Unable to find FakeVar %s" name + | _ -> failwithf "Unable to find FakeVar '%s'" name let getFakeVarOrDefault<'a> name defaultValue = match getFakeVar<'a> name with diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs index c427c76c316..282e0b1bedc 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs @@ -4,6 +4,7 @@ open System open Fake.Core open Expecto open Expecto.Flip +open FParsec.ErrorMessage [] let tests = @@ -19,5 +20,31 @@ let tests = Fake.Core.Context.forceFakeContext() |> ignore Tests.failtest "Expected exception" with :? System.InvalidOperationException as e -> () + + testCase "Ability to set and get fake variables" <| fun _ -> + Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore + let value = Fake.Core.Context.getFakeVar "Test" + Expect.isSome "FakeVar 'Test' is none" value + Expect.equal "TestValue" value.Value "FakeVar 'Test' is incorrect" + testCase "Ability to set and get fake variables with default - when found" <| fun _ -> + Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore + let value = Fake.Core.Context.getFakeVarOrDefault "Test" "DefaultValue" + Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" + + testCase "Ability to set and get fake variables with default - when not found" <| fun _ -> + let value = Fake.Core.Context.getFakeVarOrDefault "Test" "DefaultValue" + Expect.equal "DefaultValue" value "FakeVar 'Test' is not the default" + + testCase "Ability to set and get fake variables with failure - when found" <| fun _ -> + Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore + let value = Fake.Core.Context.getFakeVarOrFail "Test" + Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" + + testCase "Ability to set and get fake variables with default - when not found" <| fun _ -> + try + Fake.Core.Context.getFakeVarOrFail "Test" |> ignore + Tests.failtest "Expected exception" + with e -> + Expect.equal "Unable to find FakeVar 'Test'" e.Message "Incorrect failure message for FakeVar failure case" ] From d44b388fe1016c07dd119813f622e8501cf79628 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 11:27:05 +0100 Subject: [PATCH 05/26] Update to use the type passing on fakevar --- src/app/Fake.Core.Process/Process.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 7c98226c95b..8690c940f23 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -263,12 +263,12 @@ module Process = //let startedProcesses = HashSet() let private startedProcessesVar = "Fake.Core.Process.startedProcesses" let private getStartedProcesses, _, private setStartedProcesses = - Fake.Core.Context.fakeVar startedProcessesVar + Fake.Core.Context.fakeVar startedProcessesVar let private doWithProcessList f = if Fake.Core.Context.isFakeContext () then match getStartedProcesses () with - | Some (h:ProcessList) -> Some(f h) + | Some h -> Some(f h) | None -> let h = new ProcessList() setStartedProcesses (h) From 1298eb0bba3008d82de59025456945217461cc9c Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 11:56:18 +0100 Subject: [PATCH 06/26] Build and test fix --- src/test/Fake.Core.UnitTests/Fake.Core.Context.fs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs index 282e0b1bedc..e690817331d 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs @@ -4,7 +4,6 @@ open System open Fake.Core open Expecto open Expecto.Flip -open FParsec.ErrorMessage [] let tests = @@ -41,7 +40,7 @@ let tests = let value = Fake.Core.Context.getFakeVarOrFail "Test" Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" - testCase "Ability to set and get fake variables with default - when not found" <| fun _ -> + testCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> try Fake.Core.Context.getFakeVarOrFail "Test" |> ignore Tests.failtest "Expected exception" From cac5c4874c135b0e0d85366e55fa5767630a8341 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 12:44:27 +0100 Subject: [PATCH 07/26] Remove Expecto flip opens This makes it harder for newbies to understand since the core readme on expecto states "All expect-functions have the signature actual -> expected -> string -> unit, leaving out expected when obvious from the function." When flip is needed (for pipelines) it's explicitly mentioned --- .../Fake.Core.UnitTests/Fake.Core.Context.fs | 13 ++-- .../Fake.Core.UnitTests/Fake.Core.Process.fs | 10 ++- .../Fake.Core.ReleaseNotes.fs | 14 ++-- .../Fake.Core.UnitTests/Fake.Core.Target.fs | 64 +++++++++---------- src/test/Fake.Core.UnitTests/Fake.Core.Xml.fs | 4 +- .../Fake.Core.UnitTests/Fake.IO.Globbing.fs | 22 +++---- src/test/Fake.Core.UnitTests/Fake.IO.Zip.fs | 3 +- src/test/Fake.Core.UnitTests/Fake.Runtime.fs | 25 ++++---- 8 files changed, 70 insertions(+), 85 deletions(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs index e690817331d..e6c628765a0 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs @@ -3,7 +3,6 @@ module Fake.Core.ContextTests open System open Fake.Core open Expecto -open Expecto.Flip [] let tests = @@ -20,27 +19,27 @@ let tests = Tests.failtest "Expected exception" with :? System.InvalidOperationException as e -> () - testCase "Ability to set and get fake variables" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables" <| fun _ -> Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore let value = Fake.Core.Context.getFakeVar "Test" - Expect.isSome "FakeVar 'Test' is none" value + Expect.isSome value "FakeVar 'Test' is none" Expect.equal "TestValue" value.Value "FakeVar 'Test' is incorrect" - testCase "Ability to set and get fake variables with default - when found" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore let value = Fake.Core.Context.getFakeVarOrDefault "Test" "DefaultValue" Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" - testCase "Ability to set and get fake variables with default - when not found" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when not found" <| fun _ -> let value = Fake.Core.Context.getFakeVarOrDefault "Test" "DefaultValue" Expect.equal "DefaultValue" value "FakeVar 'Test' is not the default" - testCase "Ability to set and get fake variables with failure - when found" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when found" <| fun _ -> Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore let value = Fake.Core.Context.getFakeVarOrFail "Test" Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" - testCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> try Fake.Core.Context.getFakeVarOrFail "Test" |> ignore Tests.failtest "Expected exception" diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs index b4349afcf90..5e5b0d73fca 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs @@ -4,8 +4,6 @@ module Fake.Core.ProcessTests open System open Fake.Core open Expecto -open Expecto.Flip - [] let tests = @@ -17,10 +15,10 @@ let tests = FileName = "FileDoesntExist.exe" Arguments = "arg1 arg2" }) |> ignore - Expect.isTrue "Expected an exception" false + Expect.isTrue false "Expected an exception" with e -> let s = e.Message.Contains "FileDoesntExist.exe" - Expect.isTrue ("Expected file-path as part of the message '" + e.Message + "'") s + Expect.isTrue s ("Expected file-path as part of the message '" + e.Message + "'") testCase "Test that we can read messages correctly" <| fun _ -> let shell, command = @@ -34,6 +32,6 @@ let tests = FileName = shell Arguments = command }) (TimeSpan.FromMinutes 1.) - Expect.equal "Messages are not read correctly" ["1"; "2"] result.Messages + Expect.equal ["1"; "2"] result.Messages "Messages are not read correctly" - ] \ No newline at end of file + ] diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs b/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs index b676a18c55b..bd2b18eafdb 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.ReleaseNotes.fs @@ -1,9 +1,7 @@ - module Fake.Core.ReleaseNotesTests open Fake.Core open Expecto -open Expecto.Flip [] @@ -20,7 +18,7 @@ let tests = // For historic reasons notes get appended a "." { AssemblyVersion = "1.1.0"; NugetVersion = "1.1.0"; SemVer = SemVer.parse "1.1.0"; Date = None; Notes = ["First change."] } - Expect.equal "Simple parse failure" expected releaseNotes + Expect.equal expected releaseNotes "Simple parse failure" testCase "Test that we can parse simple release notes (reversed)" <| fun _ -> let releaseNotesLines = [ @@ -33,7 +31,7 @@ let tests = // For historic reasons notes get appended a "." { AssemblyVersion = "1.1.0"; NugetVersion = "1.1.0"; SemVer = SemVer.parse "1.1.0"; Date = None; Notes = ["First change."] } - Expect.equal "Simple parse failure" expected releaseNotes + Expect.equal expected releaseNotes "Simple parse failure" testCase "Test that we can parse complex release notes" <| fun _ -> let releaseNotesLines = [ @@ -50,7 +48,7 @@ let tests = let (expected:ReleaseNotes.ReleaseNotes) = { AssemblyVersion = "1.1.0"; NugetVersion = "1.1.0"; SemVer = SemVer.parse "1.1.0"; Date = Some (System.DateTime(2017,04,12)); Notes = ["- Some change 3"; "- Some change 4"] } - Expect.equal "Simple parse failure" expected releaseNotes + Expect.equal expected releaseNotes "Simple parse failure" testCase "Test that we can parse complex release notes (reversed)" <| fun _ -> let releaseNotesLines = [ @@ -68,7 +66,7 @@ let tests = let (expected:ReleaseNotes.ReleaseNotes) = { AssemblyVersion = "1.1.0"; NugetVersion = "1.1.0"; SemVer = SemVer.parse "1.1.0"; Date = Some (System.DateTime(2017,04,12)); Notes = ["- Some change 3"; "- Some change 4"] } - Expect.equal "Simple parse failure" expected releaseNotes + Expect.equal expected releaseNotes "Simple parse failure" testCase "Test that we can parse complex release notes with header" <| fun _ -> let releaseNotesLines = [ @@ -87,5 +85,5 @@ let tests = let (expected:ReleaseNotes.ReleaseNotes) = { AssemblyVersion = "1.1.0"; NugetVersion = "1.1.0"; SemVer = SemVer.parse "1.1.0"; Date = Some (System.DateTime(2017,04,12)); Notes = ["- Some change 3"; "- Some change 4"] } - Expect.equal "Simple parse failure" expected releaseNotes - ] \ No newline at end of file + Expect.equal expected releaseNotes "Simple parse failure" + ] diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Target.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Target.fs index 14aba96befc..a687da25745 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Target.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Target.fs @@ -2,7 +2,6 @@ module Fake.Core.TargetTests open Fake.Core open Expecto -open Expecto.Flip let run targetName = try Target.runAndGetContext 1 targetName [] @@ -58,7 +57,7 @@ let tests = // as expected () | _ -> - Expect.isTrue (sprintf "inconsistent order: %A" order) false + Expect.isTrue false (sprintf "inconsistent order: %A" order) Fake.ContextHelper.fakeContextTestCase "issue #1395 example" <| fun _ -> Target.create "T1" DoNothing @@ -450,8 +449,8 @@ let tests = "Dependency" ==> "SimpleTest" |> ignore let context = run "SimpleTest" - Expect.equal "Expected both tasks to succeed" false context.HasError - Expect.equal "Expected context to contain both targets" 2 context.PreviousTargets.Length + Expect.equal false context.HasError "Expected both tasks to succeed" + Expect.equal 2 context.PreviousTargets.Length "Expected context to contain both targets" Fake.ContextHelper.fakeContextTestCase "Test we output targets after failing targets" <| fun _ -> Target.create "SimpleTest" ignore @@ -459,8 +458,8 @@ let tests = "Dependency" ==> "SimpleTest" |> ignore let context = run "SimpleTest" - Expect.equal "Expected failure" true context.HasError - Expect.equal "Expected context to contain both targets" 2 context.PreviousTargets.Length // second one as "skipped" + Expect.equal true context.HasError "Expected failure" + Expect.equal 2 context.PreviousTargets.Length "Expected context to contain both targets" // second one as "skipped" ] @ ( [ @@ -477,9 +476,9 @@ let tests = context.PreviousTargets |> List.map (fun tr -> tr.Target.Name) let expectedOrder = ["a";"b";"c"] - Expect.equal "Expected context to contain 3 targets" 3 context.PreviousTargets.Length - Expect.equal "Expected context to contain 3 targets in right order" expectedOrder actualOrder - Expect.equal "Expected final target to not run" 0 finalTargetResult + Expect.equal 3 context.PreviousTargets.Length "Expected context to contain 3 targets" + Expect.equal expectedOrder actualOrder "Expected context to contain 3 targets in right order" + Expect.equal 0 finalTargetResult "Expected final target to not run" testCaseMultipleRuns "Final targets run after all targets" <| fun myRun _ -> Target.create "a" DoNothing @@ -496,9 +495,9 @@ let tests = context.PreviousTargets |> List.map (fun tr -> tr.Target.Name) let expectedOrder = ["a";"b";"c";"Final";"Final2"] - Expect.equal "Expected context to contain 5 targets" 5 context.PreviousTargets.Length - Expect.equal "Expected context to contain 5 targets in right order" expectedOrder actualOrder - Expect.equal "Expected final targets to run" 2 finalTargetResult + Expect.equal 5 context.PreviousTargets.Length "Expected context to contain 5 targets" + Expect.equal expectedOrder actualOrder "Expected context to contain 5 targets in right order" + Expect.equal 2 finalTargetResult "Expected final targets to run" testCaseMultipleRuns "BuildFailure targets do not run if nothing fails" <| fun myRun _ -> Target.create "a" ignore @@ -513,9 +512,9 @@ let tests = context.PreviousTargets |> List.map (fun tr -> tr.Target.Name) let expectedOrder = ["a";"b";"c"] - Expect.equal "Expected context to contain 3 targets" 3 context.PreviousTargets.Length - Expect.equal "Expected context to contain 3 targets in right order" expectedOrder actualOrder - Expect.equal "Expected buildFailure target to not run" 0 failureTargetResult + Expect.equal 3 context.PreviousTargets.Length "Expected context to contain 3 targets" + Expect.equal expectedOrder actualOrder "Expected context to contain 3 targets in right order" + Expect.equal 0 failureTargetResult "Expected buildFailure target to not run" testCaseMultipleRuns "BuildFailure targets do not run if not activated" <| fun myRun _ -> Target.create "a" ignore @@ -530,9 +529,9 @@ let tests = context.PreviousTargets |> List.map (fun tr -> tr.Target.Name) let expectedOrder = ["a";"b";"c"] - Expect.equal "Expected context to contain 3 targets" 3 context.PreviousTargets.Length - Expect.equal "Expected context to contain 3 targets in right order" expectedOrder actualOrder - Expect.equal "Expected buildFailure target to not run" 0 failureTargetResult + Expect.equal 3 context.PreviousTargets.Length "Expected context to contain 3 targets" + Expect.equal expectedOrder actualOrder "Expected context to contain 3 targets in right order" + Expect.equal 0 failureTargetResult "Expected buildFailure target to not run" testCaseMultipleRuns "BuildFailure targets run after failing targets" <| fun myRun _ -> Target.create "a" DoNothing @@ -555,14 +554,13 @@ let tests = let cResult = context.PreviousTargets |> List.find (fun tr -> tr.Target.Name="c") - Expect.equal "Expected failure" true context.HasError - Expect.equal "Expected second target to skip after failure" true context.HasError - Expect.equal "Expected context to contain 5 targets" 5 context.PreviousTargets.Length - Expect.equal "Expected context to contain 5 targets in right order" expectedOrder actualOrder - Expect.isSome "Expected target b to error" bResult.Error - Expect.isTrue "Expected target c to skip" cResult.WasSkipped - Expect.equal "Expected buildFailure targets to run" 2 failureTargetResult - + Expect.equal true context.HasError "Expected failure" + Expect.equal true context.HasError "Expected second target to skip after failure" + Expect.equal 5 context.PreviousTargets.Length "Expected context to contain 5 targets" + Expect.equal expectedOrder actualOrder "Expected context to contain 5 targets in right order" + Expect.isSome bResult.Error "Expected target b to error" + Expect.isTrue cResult.WasSkipped "Expected target c to skip" + Expect.equal 2 failureTargetResult "Expected buildFailure targets to run" testCaseMultipleRuns "Final targets run after failing targets" <| fun myRun _ -> Target.create "a" DoNothing @@ -585,11 +583,11 @@ let tests = let cResult = context.PreviousTargets |> List.find (fun tr -> tr.Target.Name="c") - Expect.equal "Expected failure" true context.HasError - Expect.equal "Expected second target to skip after failure" true context.HasError - Expect.equal "Expected context to contain 5 targets" 5 context.PreviousTargets.Length - Expect.equal "Expected context to contain 5 targets in right order" expectedOrder actualOrder - Expect.isSome "Expected target b to error" bResult.Error - Expect.isTrue "Expected target c to skip" cResult.WasSkipped - Expect.equal "Expected final targets to run" 2 finalTargetResult + Expect.equal true context.HasError "Expected failure" + Expect.equal true context.HasError "Expected second target to skip after failure" + Expect.equal 5 context.PreviousTargets.Length "Expected context to contain 5 targets" + Expect.equal expectedOrder actualOrder "Expected context to contain 5 targets in right order" + Expect.isSome bResult.Error "Expected target b to error" + Expect.isTrue cResult.WasSkipped "Expected target c to skip" + Expect.equal 2 finalTargetResult "Expected final targets to run" ] |> List.concat)) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Xml.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Xml.fs index 7aba4568d67..6e8903215c4 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Xml.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Xml.fs @@ -2,9 +2,7 @@ module Fake.Core.XmlTests open System.IO open Fake.Core -open Fake.DotNet open Expecto -open Expecto.Flip let normalize (s:string) = s.Replace("\r", "") @@ -34,7 +32,7 @@ let tests = let bundleIdentifier = "whateva" Xml.pokeInnerText tmpFile "plist/dict/key[text()='CFBundleIdentifier']/following-sibling::string" bundleIdentifier let actual = File.ReadAllText tmpFile |> normalize - Expect.equal "expected same xml" expected actual + Expect.equal expected actual "expected same xml" finally File.Delete(tmpFile) ] diff --git a/src/test/Fake.Core.UnitTests/Fake.IO.Globbing.fs b/src/test/Fake.Core.UnitTests/Fake.IO.Globbing.fs index 7542f2bf030..6e14de208c9 100644 --- a/src/test/Fake.Core.UnitTests/Fake.IO.Globbing.fs +++ b/src/test/Fake.Core.UnitTests/Fake.IO.Globbing.fs @@ -1,16 +1,12 @@ module Fake.Core.GlobbingTests open System.IO -open Fake.Core open Fake.IO open Fake.IO.Globbing open Fake.IO.FileSystemOperators open Fake.IO.Globbing.Operators open Expecto -open Expecto.Flip -open System.ComponentModel -open System.ComponentModel -open System.IO + let getFileIncludeWithKnownBaseDir includes : LazyGlobbingPattern= { Fake.IO.Globbing.LazyGlobbingPattern.BaseDirectory = @"C:\Project" Fake.IO.Globbing.LazyGlobbingPattern.Includes = includes @@ -27,20 +23,20 @@ let tests = Fake.IO.Globbing.ResolvedGlobbingPattern.Results = [ "folder/file1.exe" "folder/file2.exe" ] } - Expect.equal "Glob should match relative paths" true (globExe.IsMatch "folder/test.exe") - Expect.equal "Glob should match full paths" true (globExe.IsMatch (Path.GetFullPath "folder/test.exe")) + Expect.equal true (globExe.IsMatch "folder/test.exe") "Glob should match relative paths" + Expect.equal true (globExe.IsMatch (Path.GetFullPath "folder/test.exe")) "Glob should match full paths" testCase "It should resolve multiple directories" <| fun _ -> let fileIncludes = getFileIncludeWithKnownBaseDir [@"test1\bin\*.dll"; @"test2\bin\*.dll"] let dirIncludes = GlobbingPattern.getBaseDirectoryIncludes(fileIncludes) - Expect.equal "Should have 2 dirs" dirIncludes.Length 2 - Expect.contains "Should contain first folder" (Glob.normalizePath(@"C:\Project\test1\bin")) dirIncludes - Expect.contains "Should contain second folder" (Glob.normalizePath(@"C:\Project\test2\bin")) dirIncludes + Expect.equal dirIncludes.Length 2 "Should have 2 dirs" + Expect.contains dirIncludes (Glob.normalizePath(@"C:\Project\test1\bin")) "Should contain first folder" + Expect.contains dirIncludes (Glob.normalizePath(@"C:\Project\test2\bin")) "Should contain second folder" testCase "should only take the most root path when multiple directories share a root" <| fun _ -> let fileIncludes = getFileIncludeWithKnownBaseDir [@"tests\**\test1\bin\*.dll"; @"tests\test2\bin\*.dll"] let dirIncludes = GlobbingPattern.getBaseDirectoryIncludes(fileIncludes) - Expect.equal "Should have only 1 directory" dirIncludes.Length 1 - Expect.contains "Should contain tests folder" (Glob.normalizePath(@"C:\Project\tests")) dirIncludes + Expect.equal dirIncludes.Length 1 "Should have only 1 directory" + Expect.contains dirIncludes (Glob.normalizePath(@"C:\Project\tests")) "Should contain tests folder" testCase "glob should handle substring directories properly" <| fun _ -> let testDir = Path.GetTempFileName() @@ -60,7 +56,7 @@ let tests = |> Seq.map (fun f -> Path.GetFileName f) |> Seq.sort |> Seq.toList - |> Expect.equal "Expected equal lists." ["match1.txt"; "match2.txt"; "match3.txt"] + |> Flip.Expect.equal "Expected equal lists." ["match1.txt"; "match2.txt"; "match3.txt"] finally Directory.Delete(testDir, true) ] diff --git a/src/test/Fake.Core.UnitTests/Fake.IO.Zip.fs b/src/test/Fake.Core.UnitTests/Fake.IO.Zip.fs index 03995a15e0d..b74aff015c8 100644 --- a/src/test/Fake.Core.UnitTests/Fake.IO.Zip.fs +++ b/src/test/Fake.Core.UnitTests/Fake.IO.Zip.fs @@ -1,6 +1,5 @@ module Fake.IO.ZipTests -open Fake.Core open Fake.IO open Fake.IO.FileSystemOperators open Expecto @@ -46,4 +45,4 @@ let tests = @"subfolder/1/file2.dll", @"1""file2.dll" @"subfolder/2/file2.dll", @"2""file2.dll" ] Expect.equal actual expected "FilesAsSpecs failed." - ] \ No newline at end of file + ] diff --git a/src/test/Fake.Core.UnitTests/Fake.Runtime.fs b/src/test/Fake.Core.UnitTests/Fake.Runtime.fs index b3e4c5b2ff4..4841f8166d5 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Runtime.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Runtime.fs @@ -4,7 +4,6 @@ open System.IO open Fake.Runtime open Fake.IO.FileSystemOperators open Expecto -open Expecto.Flip open Fake.IO [] @@ -12,16 +11,16 @@ let tests = testList "Fake.Runtime.Tests" [ testCase "Test that cache helpers work" <| fun _ -> Path.fixPathForCache "build.fsx" "build.fsx" - |> Expect.equal "should detect script itself" "scriptpath:///build.fsx" + |> Flip.Expect.equal "should detect script itself" "scriptpath:///build.fsx" Path.readPathFromCache "build.fsx" "scriptpath:///build.fsx" - |> Expect.equal "should detect script itself" (Path.GetFullPath "build.fsx") + |> Flip.Expect.equal "should detect script itself" (Path.GetFullPath "build.fsx") testCase "Test that cache helpers work for nuget cache" <| fun _ -> let nugetLib = Paket.Constants.UserNuGetPackagesFolder "MyLib" "lib" "mylib.dll" Path.fixPathForCache "build.fsx" nugetLib - |> Expect.equal "should detect script itself" "nugetcache:///MyLib/lib/mylib.dll" + |> Flip.Expect.equal "should detect script itself" "nugetcache:///MyLib/lib/mylib.dll" Path.readPathFromCache "build.fsx" "nugetcache:///MyLib/lib/mylib.dll" - |> Expect.equal "should detect script itself" nugetLib + |> Flip.Expect.equal "should detect script itself" nugetLib testCase "Test that we can properly find type names when the file name contains '.'" <| fun _ -> // Add test if everything works with __SOURCE_FILE__ @@ -31,13 +30,13 @@ let tests = "build.test1.test2.fsx" Expect.equal - "Expected to have correct full type name" ".$Build.test1.test2$fsx" name + "Expected to have correct full type name" testCase "Test that we can tokenize __SOURCE_FILE__" <| fun _ -> // Add test if everything works with __SOURCE_FILE__ - Expect.equal "." "" "" + Expect.equal "" "" "." // Add test if everything works with #ifdefed #r "paket: line" testCase "Test that we find the correct references" <| fun _ -> @@ -52,7 +51,7 @@ nuget Fake.Core.SemVer prerelease //" |> Fake.Runtime.FSharpParser.findInterestingItems let expected = [Fake.Runtime.FSharpParser.InterestingItem.Reference (sprintf "paket:\nnuget Fake.Core.SemVer prerelease //") ] - Expect.equal "Expected to find reference." expected interesting + Expect.equal expected interesting "Expected to find reference." // Add test if everything works with #ifdefed #r "paket: line" testCase "Test that we find the correct references without defines" <| fun _ -> @@ -66,7 +65,7 @@ nuget Fake.Core.SemVer prerelease //" Fake.Runtime.FSharpParser.getTokenized "testfile.fsx" ["DOTNETCORE"; "FAKE"] (scriptText.Split([|'\r';'\n'|])) |> Fake.Runtime.FSharpParser.findInterestingItems let expected = [] - Expect.equal "Expected to find reference." expected interesting + Expect.equal expected interesting "Expected to find reference." // TODO: Add test if everything works with #ifdefed #r "paket: line" @@ -97,7 +96,7 @@ nuget Fake.Core.SemVer prerelease //" tmpDir "paket-files" "test" "octokit.fsx" ] let actual = scripts |> List.map (fun s -> s.Location) - Expect.equal "Expected to find script." expected actual + Expect.equal expected actual "Expected to find script." finally Directory.Delete(tmpDir, true) @@ -133,7 +132,7 @@ printfn "other.fsx" otherScriptPath ] let actual = scripts |> List.map (fun s -> s.Location) - Expect.equal "Expected to find script." expected actual + Expect.equal expected actual "Expected to find script." finally Directory.Delete(tmpDir, true) @@ -150,10 +149,10 @@ printfn "other.fsx" Fake.Runtime.FSharpParser.getTokenized "test.fsx" ["DOTNETCORE"; "FAKE"] (testScript.Split([|'\r';'\n'|])) try let scripts = HashGeneration.getAllScripts [] tokens testScriptPath - Expect.isTrue "Expected an exception" false + Expect.isTrue false "Expected an exception" with e -> (e.Message.Contains "test.fsx(2,1): error FS2302: Directory '" && e.Message.Contains "' doesn't exist") - |> Expect.isTrue (sprintf "Expected a good error message, but got: %s" e.Message) + |> Flip.Expect.isTrue (sprintf "Expected a good error message, but got: %s" e.Message) finally Directory.Delete(tmpDir, true) ] From 7f33f85f084a25d92123208da21a2915c6071dad Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 14:43:49 +0100 Subject: [PATCH 08/26] Migrate FakeVar usage into separate module --- Fake.sln | 41 +++++++++++----- src/app/Fake.Core.Context/Context.fs | 17 +++---- .../Fake.Core.Process.fsproj | 3 +- src/app/Fake.Core.Process/Process.fs | 6 +-- .../Fake.Core.Target/Fake.Core.Target.fsproj | 1 + src/app/Fake.Core.Target/Target.fs | 6 +-- .../Fake.Core.Trace/Fake.Core.Trace.fsproj | 3 +- src/app/Fake.Core.Trace/TraceListener.fs | 4 +- src/app/Fake.Core.Variables/AssemblyInfo.fs | 17 +++++++ .../Fake.Core.Variables.fsproj | 18 +++++++ src/app/Fake.Core.Variables/Variables.fs | 49 +++++++++++++++++++ src/app/Fake.Core.Variables/paket.references | 4 ++ .../Fake.Core.UnitTests/Fake.Core.Context.fs | 29 ----------- .../Fake.Core.UnitTests.fsproj | 1 + .../Fake.Core.Variables.fs | 35 +++++++++++++ 15 files changed, 171 insertions(+), 63 deletions(-) create mode 100644 src/app/Fake.Core.Variables/AssemblyInfo.fs create mode 100644 src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj create mode 100644 src/app/Fake.Core.Variables/Variables.fs create mode 100644 src/app/Fake.Core.Variables/paket.references create mode 100644 src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs diff --git a/Fake.sln b/Fake.sln index d2c6c236474..7ac9ca460dc 100644 --- a/Fake.sln +++ b/Fake.sln @@ -1,4 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2026 MinimumVisualStudioVersion = 15.0.26124.0 @@ -6,6 +7,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{7BFFAE76-DEE EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Context", "src/app/Fake.Core.Context/Fake.Core.Context.fsproj", "{D3D92ED7-C2B9-46D5-B611-A2CF0C30C8DB}" EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Variables", "src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj", "{1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}" +EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Environment", "src/app/Fake.Core.Environment/Fake.Core.Environment.fsproj", "{A2C4A85F-24C4-4FFA-B165-4807B1127C4E}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Process", "src/app/Fake.Core.Process/Fake.Core.Process.fsproj", "{DB09FF66-8750-40B8-9E25-70FADD9CF0BD}" @@ -126,10 +129,10 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Tools.Pickles", "src/a EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{03CB61B6-EBB8-4C4A-B6A3-0D84D1F78A92}" ProjectSection(SolutionItems) = preProject + .gitlab-ci.yml = .gitlab-ci.yml build.fsx = build.fsx - paket.lock = paket.lock paket.dependencies = paket.dependencies - .gitlab-ci.yml = .gitlab-ci.yml + paket.lock = paket.lock RELEASE_NOTES.md = RELEASE_NOTES.md EndProjectSection EndProject @@ -139,9 +142,9 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Windows.Registry", "sr EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.Fsc", "src/app/Fake.DotNet.Fsc/Fake.DotNet.Fsc.fsproj", "{32A82EF2-BB35-40A2-9418-904ECFC1EF47}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fake.BuildServer.GitLab", "src/app/Fake.BuildServer.GitLab/Fake.BuildServer.GitLab.fsproj", "{F778A9E5-FC1A-4934-A6B9-98C84BE9A667}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.BuildServer.GitLab", "src/app/Fake.BuildServer.GitLab/Fake.BuildServer.GitLab.fsproj", "{F778A9E5-FC1A-4934-A6B9-98C84BE9A667}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "fake-cli", "src/app/fake-cli/fake-cli.fsproj", "{9E26B2AE-856A-42B6-9670-8766919F7D25}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "fake-cli", "src/app/fake-cli/fake-cli.fsproj", "{9E26B2AE-856A-42B6-9670-8766919F7D25}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -165,6 +168,18 @@ Global {D3D92ED7-C2B9-46D5-B611-A2CF0C30C8DB}.Release|x64.Build.0 = Release|Any CPU {D3D92ED7-C2B9-46D5-B611-A2CF0C30C8DB}.Release|x86.ActiveCfg = Release|Any CPU {D3D92ED7-C2B9-46D5-B611-A2CF0C30C8DB}.Release|x86.Build.0 = Release|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Debug|x64.ActiveCfg = Debug|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Debug|x64.Build.0 = Debug|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Debug|x86.ActiveCfg = Debug|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Debug|x86.Build.0 = Debug|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Release|Any CPU.Build.0 = Release|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Release|x64.ActiveCfg = Release|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Release|x64.Build.0 = Release|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Release|x86.ActiveCfg = Release|Any CPU + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}.Release|x86.Build.0 = Release|Any CPU {A2C4A85F-24C4-4FFA-B165-4807B1127C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2C4A85F-24C4-4FFA-B165-4807B1127C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2C4A85F-24C4-4FFA-B165-4807B1127C4E}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -863,16 +878,16 @@ Global {32A82EF2-BB35-40A2-9418-904ECFC1EF47}.Release|x86.Build.0 = Release|Any CPU {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x64.ActiveCfg = Debug|x64 - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x64.Build.0 = Debug|x64 - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x86.ActiveCfg = Debug|x86 - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x86.Build.0 = Debug|x86 + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x64.ActiveCfg = Debug|Any CPU + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x64.Build.0 = Debug|Any CPU + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x86.ActiveCfg = Debug|Any CPU + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Debug|x86.Build.0 = Debug|Any CPU {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|Any CPU.ActiveCfg = Release|Any CPU {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|Any CPU.Build.0 = Release|Any CPU - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x64.ActiveCfg = Release|x64 - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x64.Build.0 = Release|x64 - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x86.ActiveCfg = Release|x86 - {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x86.Build.0 = Release|x86 + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x64.ActiveCfg = Release|Any CPU + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x64.Build.0 = Release|Any CPU + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x86.ActiveCfg = Release|Any CPU + {F778A9E5-FC1A-4934-A6B9-98C84BE9A667}.Release|x86.Build.0 = Release|Any CPU {9E26B2AE-856A-42B6-9670-8766919F7D25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9E26B2AE-856A-42B6-9670-8766919F7D25}.Debug|Any CPU.Build.0 = Debug|Any CPU {9E26B2AE-856A-42B6-9670-8766919F7D25}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 29e87524ebc..4d42c7c430b 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -112,36 +112,31 @@ let forceFakeContext () = invalidOp "no Fake Execution context was found. You can initialize one via Fake.Core.Context.setExecutionContext" | RuntimeContext.Fake e -> e -let getFakeVar<'a> name = +[] +let getFakeVar name = forceFakeContext() |> getFakeContext name |> Option.map (fun o -> o :?> 'a) -let getFakeVarOrFail<'a> name = - match getFakeVar<'a> name with - | Some v -> v - | _ -> failwithf "Unable to find FakeVar '%s'" name - -let getFakeVarOrDefault<'a> name defaultValue = - match getFakeVar<'a> name with - | Some v -> v - | _ -> defaultValue - +[] let removeFakeVar name = forceFakeContext() |> removeFakeContext name |> Option.map (fun o -> o :?> 'a) +[] let setFakeVar name (v:'a) = forceFakeContext() |> setFakeContext name v (fun _ -> v :> obj) :?> 'a +[] let fakeVar name = (fun () -> getFakeVar name : 'a option), (fun () -> (removeFakeVar name : 'a option) |> ignore), (fun (v : 'a) -> setFakeVar name v |> ignore) +[] let fakeVarAllowNoContext name = let mutable varWithoutContext = None (fun () -> diff --git a/src/app/Fake.Core.Process/Fake.Core.Process.fsproj b/src/app/Fake.Core.Process/Fake.Core.Process.fsproj index 848c4a6b99e..cfe5d01ad2b 100644 --- a/src/app/Fake.Core.Process/Fake.Core.Process.fsproj +++ b/src/app/Fake.Core.Process/Fake.Core.Process.fsproj @@ -22,6 +22,7 @@ + @@ -38,4 +39,4 @@ - \ No newline at end of file + diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 8690c940f23..9eda7197c4f 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -263,7 +263,7 @@ module Process = //let startedProcesses = HashSet() let private startedProcessesVar = "Fake.Core.Process.startedProcesses" let private getStartedProcesses, _, private setStartedProcesses = - Fake.Core.Context.fakeVar startedProcessesVar + Fake.Core.Variables.fakeVar startedProcessesVar let private doWithProcessList f = if Fake.Core.Context.isFakeContext () then @@ -337,7 +337,7 @@ module Process = //let mutable redirectOutputToTrace = false let private redirectOutputToTraceVar = "Fake.Core.Process.redirectOutputToTrace" let private tryGetRedirectOutputToTrace, _, public setRedirectOutputToTrace = - Fake.Core.Context.fakeVarAllowNoContext redirectOutputToTraceVar + Fake.Core.Variables.fakeVarAllowNoContext redirectOutputToTraceVar let getRedirectOutputToTrace () = match tryGetRedirectOutputToTrace() with | Some v -> v @@ -350,7 +350,7 @@ module Process = //let mutable enableProcessTracing = true let private enableProcessTracingVar = "Fake.Core.Process.enableProcessTracing" let private getEnableProcessTracing, private removeEnableProcessTracing, public setEnableProcessTracing = - Fake.Core.Context.fakeVarAllowNoContext enableProcessTracingVar + Fake.Core.Variables.fakeVarAllowNoContext enableProcessTracingVar let shouldEnableProcessTracing () = match getEnableProcessTracing() with | Some v -> v diff --git a/src/app/Fake.Core.Target/Fake.Core.Target.fsproj b/src/app/Fake.Core.Target/Fake.Core.Target.fsproj index 20be84566c2..331e21c5d0c 100644 --- a/src/app/Fake.Core.Target/Fake.Core.Target.fsproj +++ b/src/app/Fake.Core.Target/Fake.Core.Target.fsproj @@ -17,6 +17,7 @@ + diff --git a/src/app/Fake.Core.Target/Target.fs b/src/app/Fake.Core.Target/Target.fs index 94a6c431ca1..2fade0f5a5a 100644 --- a/src/app/Fake.Core.Target/Target.fs +++ b/src/app/Fake.Core.Target/Target.fs @@ -105,13 +105,13 @@ module Target = //let mutable PrintStackTraceOnError = false let private printStackTraceOnErrorVar = "Fake.Core.Target.PrintStackTraceOnError" let private getPrintStackTraceOnError, _, (setPrintStackTraceOnError:bool -> unit) = - Fake.Core.Context.fakeVar printStackTraceOnErrorVar + Fake.Core.Variables.fakeVar printStackTraceOnErrorVar /// [omit] //let mutable LastDescription = null let private lastDescriptionVar = "Fake.Core.Target.LastDescription" let private getLastDescription, removeLastDescription, setLastDescription = - Fake.Core.Context.fakeVar lastDescriptionVar + Fake.Core.Variables.fakeVar lastDescriptionVar /// Sets the Description for the next target. /// [omit] @@ -132,7 +132,7 @@ module Target = let internal getVarWithInit name f = let varName = sprintf "Fake.Core.Target.%s" name let getVar, _, setVar = - Fake.Core.Context.fakeVar varName + Fake.Core.Variables.fakeVar varName fun () -> match getVar() with | Some d -> d diff --git a/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj b/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj index b38eab541fd..9e638d9a3a0 100644 --- a/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj +++ b/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj @@ -19,6 +19,7 @@ + - \ No newline at end of file + diff --git a/src/app/Fake.Core.Trace/TraceListener.fs b/src/app/Fake.Core.Trace/TraceListener.fs index e17a8a95990..79477d1b60d 100644 --- a/src/app/Fake.Core.Trace/TraceListener.fs +++ b/src/app/Fake.Core.Trace/TraceListener.fs @@ -270,7 +270,7 @@ type TraceSecret = module TraceSecrets = let private traceSecretsVar = "Fake.Core.Trace.TraceSecrets" let private getTraceSecrets, _, (setTraceSecrets:TraceSecret list -> unit) = - Fake.Core.Context.fakeVar traceSecretsVar + Fake.Core.Variables.fakeVar traceSecretsVar let getAll () = match getTraceSecrets() with @@ -302,7 +302,7 @@ module CoreTracing = let private traceListenersVar = "Fake.Core.Trace.TraceListeners" let private getTraceListeners, _, (setTraceListenersPrivate:ITraceListener list -> unit) = - Fake.Core.Context.fakeVar traceListenersVar + Fake.Core.Variables.fakeVar traceListenersVar let areListenersSet () = match getTraceListeners() with diff --git a/src/app/Fake.Core.Variables/AssemblyInfo.fs b/src/app/Fake.Core.Variables/AssemblyInfo.fs new file mode 100644 index 00000000000..dc7146a8030 --- /dev/null +++ b/src/app/Fake.Core.Variables/AssemblyInfo.fs @@ -0,0 +1,17 @@ +// Auto-Generated by FAKE; do not edit +namespace System +open System.Reflection + +[] +[] +[] +[] +[] +do () + +module internal AssemblyVersionInformation = + let [] AssemblyTitle = "FAKE - F# Make Core Variables" + let [] AssemblyProduct = "FAKE - F# Make" + let [] AssemblyVersion = "5.0.0" + let [] AssemblyInformationalVersion = "5.0.0-rc016" + let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj b/src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj new file mode 100644 index 00000000000..af6a02f6844 --- /dev/null +++ b/src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj @@ -0,0 +1,18 @@ + + + net46;netstandard1.6;netstandard2.0 + Fake.Core.Variables + Library + + + $(DefineConstants);RELEASE + + + + + + + + + + diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs new file mode 100644 index 00000000000..a4051a45055 --- /dev/null +++ b/src/app/Fake.Core.Variables/Variables.fs @@ -0,0 +1,49 @@ +/// This module contains helpers for managing build time variables +module Fake.Core.Variables + +open Fake.Core.Context + +let getFakeVar<'a> name = + forceFakeContext() + |> getFakeContext name + |> Option.map (fun o -> o :?> 'a) + +let getFakeVarOrFail<'a> name = + match getFakeVar<'a> name with + | Some v -> v + | _ -> failwithf "Unable to find FakeVar '%s'" name + +let getFakeVarOrDefault<'a> name defaultValue = + match getFakeVar<'a> name with + | Some v -> v + | _ -> defaultValue + +let removeFakeVar name = + forceFakeContext() + |> removeFakeContext name + |> Option.map (fun o -> o :?> 'a) + +let setFakeVar name (v:'a) = + forceFakeContext() + |> setFakeContext name v (fun _ -> v :> obj) + :?> 'a + +let fakeVar name = + (fun () -> getFakeVar name : 'a option), + (fun () -> (removeFakeVar name : 'a option) |> ignore), + (fun (v : 'a) -> setFakeVar name v |> ignore) + +let fakeVarAllowNoContext name = + let mutable varWithoutContext = None + (fun () -> + if isFakeContext() then + getFakeVar name : 'a option + else varWithoutContext), + (fun () -> + if isFakeContext() then + (removeFakeVar name : 'a option) |> ignore + else varWithoutContext <- None), + (fun (v : 'a) -> + if isFakeContext() then + setFakeVar name v |> ignore + else varWithoutContext <- Some v) diff --git a/src/app/Fake.Core.Variables/paket.references b/src/app/Fake.Core.Variables/paket.references new file mode 100644 index 00000000000..2c8a7ddfd73 --- /dev/null +++ b/src/app/Fake.Core.Variables/paket.references @@ -0,0 +1,4 @@ +group netcore + +FSharp.Core +NETStandard.Library \ No newline at end of file diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs index e6c628765a0..3c384017c86 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Context.fs @@ -1,7 +1,5 @@ module Fake.Core.ContextTests -open System -open Fake.Core open Expecto [] @@ -18,31 +16,4 @@ let tests = Fake.Core.Context.forceFakeContext() |> ignore Tests.failtest "Expected exception" with :? System.InvalidOperationException as e -> () - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables" <| fun _ -> - Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore - let value = Fake.Core.Context.getFakeVar "Test" - Expect.isSome value "FakeVar 'Test' is none" - Expect.equal "TestValue" value.Value "FakeVar 'Test' is incorrect" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> - Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore - let value = Fake.Core.Context.getFakeVarOrDefault "Test" "DefaultValue" - Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when not found" <| fun _ -> - let value = Fake.Core.Context.getFakeVarOrDefault "Test" "DefaultValue" - Expect.equal "DefaultValue" value "FakeVar 'Test' is not the default" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when found" <| fun _ -> - Fake.Core.Context.setFakeVar "Test" "TestValue" |> ignore - let value = Fake.Core.Context.getFakeVarOrFail "Test" - Expect.equal "TestValue" value "FakeVar 'Test' is incorrect" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> - try - Fake.Core.Context.getFakeVarOrFail "Test" |> ignore - Tests.failtest "Expected exception" - with e -> - Expect.equal "Unable to find FakeVar 'Test'" e.Message "Incorrect failure message for FakeVar failure case" ] diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj index e8ccd40be42..9fb4a0b32f4 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj +++ b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj @@ -31,6 +31,7 @@ + diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs new file mode 100644 index 00000000000..e321d9b9312 --- /dev/null +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs @@ -0,0 +1,35 @@ +module Fake.Core.VariablesTests + +open Fake.Core.Variables +open Expecto + +[] +let tests = + testList "Fake.Core.Variables.Tests" [ + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables" <| fun _ -> + set "Test" "TestValue" |> ignore + let value = get "Test" + Expect.isSome value "Variable 'Test' is none" + Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> + set "Test" "TestValue" |> ignore + let value = getOrDefault "Test" "DefaultValue" + Expect.equal "TestValue" value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when not found" <| fun _ -> + let value = getOrDefault "Test" "DefaultValue" + Expect.equal "DefaultValue" value "Variable 'Test' is not the default" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when found" <| fun _ -> + set "Test" "TestValue" |> ignore + let value = getOrFail "Test" + Expect.equal "TestValue" value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> + try + getOrFail "Test" |> ignore + Tests.failtest "Expected exception" + with e -> + Expect.equal "Unable to find variable 'Test'" e.Message "Incorrect failure message for variable failure case" + ] From 73da35074b9394f35399f7d105ac53fa52d9e427 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 14:44:23 +0100 Subject: [PATCH 09/26] Fix AssemblyInfo warnings --- src/app/Fake.Core.Variables/AssemblyInfo.fs | 4 ++-- src/app/Fake.DotNet.Fsc/AssemblyInfo.fs | 4 ++-- src/app/Fake.DotNet.Mage/AssemblyInfo.fs | 4 ++-- src/app/Fake.DotNet.Testing.Expecto/AssemblyInfo.fs | 4 ++-- src/app/Fake.DotNet.Testing.SpecFlow/AssemblyInfo.fs | 4 ++-- src/app/Fake.Installer.InnoSetup/AssemblyInfo.fs | 4 ++-- src/app/Fake.Testing.ReportGenerator/AssemblyInfo.fs | 4 ++-- src/app/Fake.Tools.Pickles/AssemblyInfo.fs | 4 ++-- src/app/Fake.Windows.Registry/AssemblyInfo.fs | 4 ++-- src/legacy/FAKE/AssemblyInfo.fs | 4 ++-- src/legacy/Fake.Deploy.Lib/AssemblyInfo.fs | 4 ++-- src/legacy/Fake.Deploy/AssemblyInfo.fs | 4 ++-- src/legacy/Fake.Experimental/AssemblyInfo.fs | 4 ++-- src/legacy/Fake.FluentMigrator/AssemblyInfo.fs | 4 ++-- src/legacy/Fake.SQL/AssemblyInfo.fs | 4 ++-- src/legacy/FakeLib/AssemblyInfo.fs | 4 ++-- src/legacy/deploy.web/Fake.Deploy.Web/AssemblyInfo.fs | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/app/Fake.Core.Variables/AssemblyInfo.fs b/src/app/Fake.Core.Variables/AssemblyInfo.fs index dc7146a8030..227eddf101a 100644 --- a/src/app/Fake.Core.Variables/AssemblyInfo.fs +++ b/src/app/Fake.Core.Variables/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make Core Variables" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-rc016" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.DotNet.Fsc/AssemblyInfo.fs b/src/app/Fake.DotNet.Fsc/AssemblyInfo.fs index 205ef7d1e2c..27cd877ad33 100644 --- a/src/app/Fake.DotNet.Fsc/AssemblyInfo.fs +++ b/src/app/Fake.DotNet.Fsc/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make FSC Wrapper" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.DotNet.Mage/AssemblyInfo.fs b/src/app/Fake.DotNet.Mage/AssemblyInfo.fs index de1d4db345e..2a165429700 100644 --- a/src/app/Fake.DotNet.Mage/AssemblyInfo.fs +++ b/src/app/Fake.DotNet.Mage/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make Manifest Generation and Editing Tool" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-rc007" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.DotNet.Testing.Expecto/AssemblyInfo.fs b/src/app/Fake.DotNet.Testing.Expecto/AssemblyInfo.fs index 647268e6e47..497c8683ea5 100644 --- a/src/app/Fake.DotNet.Testing.Expecto/AssemblyInfo.fs +++ b/src/app/Fake.DotNet.Testing.Expecto/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make Running Expecto test runner" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.DotNet.Testing.SpecFlow/AssemblyInfo.fs b/src/app/Fake.DotNet.Testing.SpecFlow/AssemblyInfo.fs index 1734f962cd4..969bbbb93ed 100644 --- a/src/app/Fake.DotNet.Testing.SpecFlow/AssemblyInfo.fs +++ b/src/app/Fake.DotNet.Testing.SpecFlow/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make BDD with Gherkin and SpecFlow" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.Installer.InnoSetup/AssemblyInfo.fs b/src/app/Fake.Installer.InnoSetup/AssemblyInfo.fs index f79eabe4372..b1e7a155765 100644 --- a/src/app/Fake.Installer.InnoSetup/AssemblyInfo.fs +++ b/src/app/Fake.Installer.InnoSetup/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make Creating installers with InnoSetup" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-rc007" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.Testing.ReportGenerator/AssemblyInfo.fs b/src/app/Fake.Testing.ReportGenerator/AssemblyInfo.fs index 8f058b53de1..97122e9c08c 100644 --- a/src/app/Fake.Testing.ReportGenerator/AssemblyInfo.fs +++ b/src/app/Fake.Testing.ReportGenerator/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make Convert XML coverage output to various formats" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.Tools.Pickles/AssemblyInfo.fs b/src/app/Fake.Tools.Pickles/AssemblyInfo.fs index e1cae8c93b8..adc7efe8371 100644 --- a/src/app/Fake.Tools.Pickles/AssemblyInfo.fs +++ b/src/app/Fake.Tools.Pickles/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# Make Convert Gherkin to HTML" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-rc005" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/app/Fake.Windows.Registry/AssemblyInfo.fs b/src/app/Fake.Windows.Registry/AssemblyInfo.fs index 904419c9ced..1f524cced0b 100644 --- a/src/app/Fake.Windows.Registry/AssemblyInfo.fs +++ b/src/app/Fake.Windows.Registry/AssemblyInfo.fs @@ -5,7 +5,7 @@ open System.Reflection [] [] [] -[] +[] [] do () @@ -13,5 +13,5 @@ module internal AssemblyVersionInformation = let [] AssemblyTitle = "FAKE - F# CRUD functionality for Windows registry" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/FAKE/AssemblyInfo.fs b/src/legacy/FAKE/AssemblyInfo.fs index fa4c47c7d3c..a80fe38fe49 100644 --- a/src/legacy/FAKE/AssemblyInfo.fs +++ b/src/legacy/FAKE/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "fb2b540f-d97a-4660-972f-5eeff8120fba" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/Fake.Deploy.Lib/AssemblyInfo.fs b/src/legacy/Fake.Deploy.Lib/AssemblyInfo.fs index 2c2115aaf4b..5e93536c902 100644 --- a/src/legacy/Fake.Deploy.Lib/AssemblyInfo.fs +++ b/src/legacy/Fake.Deploy.Lib/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "AA284C42-1396-42CB-BCAC-D27F18D14AC7" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/Fake.Deploy/AssemblyInfo.fs b/src/legacy/Fake.Deploy/AssemblyInfo.fs index 71e7edd43aa..271ab493301 100644 --- a/src/legacy/Fake.Deploy/AssemblyInfo.fs +++ b/src/legacy/Fake.Deploy/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "413E2050-BECC-4FA6-87AA-5A74ACE9B8E1" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/Fake.Experimental/AssemblyInfo.fs b/src/legacy/Fake.Experimental/AssemblyInfo.fs index a347c1daf0a..11f6cf58acc 100644 --- a/src/legacy/Fake.Experimental/AssemblyInfo.fs +++ b/src/legacy/Fake.Experimental/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "5AA28AED-B9D8-4158-A594-32FE5ABC5713" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/Fake.FluentMigrator/AssemblyInfo.fs b/src/legacy/Fake.FluentMigrator/AssemblyInfo.fs index 7ffdbebdb97..031759534fa 100644 --- a/src/legacy/Fake.FluentMigrator/AssemblyInfo.fs +++ b/src/legacy/Fake.FluentMigrator/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "E18BDD6F-1AF8-42BB-AEB6-31CD1AC7E56D" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/Fake.SQL/AssemblyInfo.fs b/src/legacy/Fake.SQL/AssemblyInfo.fs index 13e402f009b..393f90ab9ad 100644 --- a/src/legacy/Fake.SQL/AssemblyInfo.fs +++ b/src/legacy/Fake.SQL/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "A161EAAF-EFDA-4EF2-BD5A-4AD97439F1BE" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/FakeLib/AssemblyInfo.fs b/src/legacy/FakeLib/AssemblyInfo.fs index 7ea9c621cf9..cf6631ad1da 100644 --- a/src/legacy/FakeLib/AssemblyInfo.fs +++ b/src/legacy/FakeLib/AssemblyInfo.fs @@ -9,7 +9,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -19,5 +19,5 @@ module internal AssemblyVersionInformation = let [] Guid = "d6dd5aec-636d-4354-88d6-d66e094dadb5" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" diff --git a/src/legacy/deploy.web/Fake.Deploy.Web/AssemblyInfo.fs b/src/legacy/deploy.web/Fake.Deploy.Web/AssemblyInfo.fs index 6847cc67045..2aa4d3080c0 100644 --- a/src/legacy/deploy.web/Fake.Deploy.Web/AssemblyInfo.fs +++ b/src/legacy/deploy.web/Fake.Deploy.Web/AssemblyInfo.fs @@ -7,7 +7,7 @@ open System.Runtime.InteropServices [] [] [] -[] +[] [] do () @@ -16,5 +16,5 @@ module internal AssemblyVersionInformation = let [] Guid = "27BA7705-3F57-47BE-B607-8A46B27AE876" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" - let [] AssemblyInformationalVersion = "5.0.0-beta025" + let [] AssemblyInformationalVersion = "5.0.0.0" let [] AssemblyFileVersion = "5.0.0" From d5e51e8c70ea600a31ae5ad3d9e2baf98f497466 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 14:44:55 +0100 Subject: [PATCH 10/26] Fix more warnings --- src/app/Fake.Azure.Kudu/Kudu.fs | 6 ++--- src/app/Fake.Core.Process/Process.fs | 4 +-- src/app/Fake.Core.Variables/Variables.fs | 32 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/app/Fake.Azure.Kudu/Kudu.fs b/src/app/Fake.Azure.Kudu/Kudu.fs index 1bd01e37fb7..6826d3940c3 100644 --- a/src/app/Fake.Azure.Kudu/Kudu.fs +++ b/src/app/Fake.Azure.Kudu/Kudu.fs @@ -26,7 +26,7 @@ type WebJobType = Scheduled | Continuous do Directory.ensure deploymentTemp |> ignore Directory.ensure deploymentTarget |> ignore - Shell.CleanDir deploymentTemp + Shell.cleanDir deploymentTemp /// /// Stages a folder and all subdirectories into the temp deployment area, ready for deployment into the website. @@ -34,7 +34,7 @@ do /// The source folder to copy. /// A predicate which includes files from the folder. If the entire directory should be copied, this predicate should always return true. let stageFolder source shouldInclude = - Shell.CopyRecursive source deploymentTemp true + Shell.copyRecursive source deploymentTemp true |> Seq.filter (not << shouldInclude) |> Seq.iter File.Delete @@ -47,7 +47,7 @@ let getWebJobPath webJobType webJobName = let stageWebJob webJobType webJobName files = let webJobPath = getWebJobPath webJobType webJobName Directory.ensure webJobPath |> ignore - files |> Shell.CopyFiles webJobPath + files |> Shell.copyFiles webJobPath /// Synchronises all staged files from the temporary deployment to the actual deployment, removing /// any obsolete files, updating changed files and adding new files. diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 9eda7197c4f..7e8dfd720c0 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -337,7 +337,7 @@ module Process = //let mutable redirectOutputToTrace = false let private redirectOutputToTraceVar = "Fake.Core.Process.redirectOutputToTrace" let private tryGetRedirectOutputToTrace, _, public setRedirectOutputToTrace = - Fake.Core.Variables.fakeVarAllowNoContext redirectOutputToTraceVar + Fake.Core.Variables.fakeVarNoContext redirectOutputToTraceVar let getRedirectOutputToTrace () = match tryGetRedirectOutputToTrace() with | Some v -> v @@ -350,7 +350,7 @@ module Process = //let mutable enableProcessTracing = true let private enableProcessTracingVar = "Fake.Core.Process.enableProcessTracing" let private getEnableProcessTracing, private removeEnableProcessTracing, public setEnableProcessTracing = - Fake.Core.Variables.fakeVarAllowNoContext enableProcessTracingVar + Fake.Core.Variables.fakeVarNoContext enableProcessTracingVar let shouldEnableProcessTracing () = match getEnableProcessTracing() with | Some v -> v diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs index a4051a45055..c4dc522f943 100644 --- a/src/app/Fake.Core.Variables/Variables.fs +++ b/src/app/Fake.Core.Variables/Variables.fs @@ -3,47 +3,47 @@ module Fake.Core.Variables open Fake.Core.Context -let getFakeVar<'a> name = +let get<'a> name = forceFakeContext() |> getFakeContext name |> Option.map (fun o -> o :?> 'a) -let getFakeVarOrFail<'a> name = - match getFakeVar<'a> name with +let getOrFail<'a> name = + match get<'a> name with | Some v -> v - | _ -> failwithf "Unable to find FakeVar '%s'" name + | _ -> failwithf "Unable to find variable '%s'" name -let getFakeVarOrDefault<'a> name defaultValue = - match getFakeVar<'a> name with +let getOrDefault<'a> name defaultValue = + match get<'a> name with | Some v -> v | _ -> defaultValue -let removeFakeVar name = +let remove name = forceFakeContext() |> removeFakeContext name |> Option.map (fun o -> o :?> 'a) -let setFakeVar name (v:'a) = +let set name (v:'a) = forceFakeContext() |> setFakeContext name v (fun _ -> v :> obj) :?> 'a -let fakeVar name = - (fun () -> getFakeVar name : 'a option), - (fun () -> (removeFakeVar name : 'a option) |> ignore), - (fun (v : 'a) -> setFakeVar name v |> ignore) +let fakeVar<'a> name = + (fun () -> get name : 'a option), + (fun () -> (remove name : 'a option) |> ignore), + (fun (v : 'a) -> set name v |> ignore) -let fakeVarAllowNoContext name = +let fakeVarNoContext<'a> name = let mutable varWithoutContext = None (fun () -> if isFakeContext() then - getFakeVar name : 'a option + get name : 'a option else varWithoutContext), (fun () -> if isFakeContext() then - (removeFakeVar name : 'a option) |> ignore + (remove name : 'a option) |> ignore else varWithoutContext <- None), (fun (v : 'a) -> if isFakeContext() then - setFakeVar name v |> ignore + set name v |> ignore else varWithoutContext <- Some v) From 3c44abba1dd757580ab2065fdfe88c0b4718d4ef Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 14:57:13 +0100 Subject: [PATCH 11/26] Fix some more warnings Also remove the obsolete i added on AssemblyInfoFile - if someone wants to directly call, they should be able to... --- src/app/Fake.Core.Process/Process.fs | 19 ++++++++----------- .../AssemblyInfoFile.fs | 8 -------- src/app/Fake.DotNet.NuGet/NuGet.fs | 13 +++++-------- src/app/Fake.DotNet.Xamarin/Xamarin.fs | 6 +++--- .../Fake.Core.IntegrationTests/TestHelpers.fs | 4 ++-- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 7e8dfd720c0..9bc224f1589 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -4,9 +4,6 @@ namespace Fake.Core open System open System.Diagnostics -open System.Collections.Generic -open System.Collections.Generic -open System /// A record type which captures console messages type ConsoleMessage = @@ -250,13 +247,13 @@ module Process = | _ -> () with exn -> Trace.logfn "Killing %d failed with %s" pid exn.Message startedProcesses.Clear() - member x.KillAll() = killProcesses() - member x.Add (pid, startTime) = startedProcesses.Add(pid, startTime) - member x.SetShouldKill (enable) = shouldKillProcesses <- enable - member x.GetShouldKill = shouldKillProcesses + member __.KillAll() = killProcesses() + member __.Add (pid, startTime) = startedProcesses.Add(pid, startTime) + member __.SetShouldKill (enable) = shouldKillProcesses <- enable + member __.GetShouldKill = shouldKillProcesses interface IDisposable with - member x.Dispose() = + member __.Dispose() = if shouldKillProcesses then killProcesses() /// [omit] @@ -648,7 +645,7 @@ module Process = #if FX_CONFIGURATION_MANAGER try System.Configuration.ConfigurationManager.AppSettings.[key] - with exn -> "" + with _ -> "" #else null #endif @@ -731,11 +728,11 @@ module Process = |> Seq.filter (fun p -> try not p.HasExited - with exn -> false) + with _ -> false) |> Seq.filter (fun p -> try p.ProcessName.ToLower().StartsWith(name.ToLower()) - with exn -> false) + with _ -> false) [] let getProcessesByName name = getAllByName name diff --git a/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs b/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs index 6cb0fd368d3..001afd21ce7 100644 --- a/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs +++ b/src/app/Fake.DotNet.AssemblyInfoFile/AssemblyInfoFile.fs @@ -213,7 +213,6 @@ module AssemblyInfoFile = /// Creates a C# AssemblyInfo file with the given attributes and configuration. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. - [] let createCSharpWithConfig outputFileName attributes (config : AssemblyInfoFileConfig) = use __ = Trace.traceTask "AssemblyInfo" outputFileName let generateClass, useNamespace, emitResharperSupressions = config.GenerateClass, config.UseNamespace, config.EmitResharperSuppressions @@ -260,7 +259,6 @@ module AssemblyInfoFile = /// Creates a F# AssemblyInfo file with the given attributes and configuration. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. - [] let createFSharpWithConfig outputFileName attributes (config : AssemblyInfoFileConfig) = use __ = Trace.traceTask "AssemblyInfo" outputFileName let generateClass, useNamespace = config.GenerateClass, config.UseNamespace @@ -292,7 +290,6 @@ module AssemblyInfoFile = /// Creates a VB AssemblyInfo file with the given attributes and configuration. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. - [] let createVisualBasicWithConfig outputFileName attributes (config : AssemblyInfoFileConfig) = use __ = Trace.traceTask "AssemblyInfo" outputFileName let generateClass, _ = config.GenerateClass, config.UseNamespace @@ -321,7 +318,6 @@ module AssemblyInfoFile = /// Creates a C++/CLI AssemblyInfo file with the given attributes and configuration. /// Does not generate an AssemblyVersionInformation class. - [] let createCppCliWithConfig outputFileName attributes (config : AssemblyInfoFileConfig) = use __ = Trace.traceTask "AssemblyInfo" outputFileName let _, _ = config.GenerateClass, config.UseNamespace @@ -342,24 +338,20 @@ module AssemblyInfoFile = /// Creates a C# AssemblyInfo file with the given attributes. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. - [] let createCSharp outputFileName attributes = createCSharpWithConfig outputFileName attributes AssemblyInfoFileConfig.Default /// Creates a F# AssemblyInfo file with the given attributes. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. - [] let createFSharp outputFileName attributes = createFSharpWithConfig outputFileName attributes AssemblyInfoFileConfig.Default /// Creates a VB AssemblyInfo file with the given attributes. /// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. - [] let createVisualBasic outputFileName attributes = createVisualBasicWithConfig outputFileName attributes AssemblyInfoFileConfig.Default /// Creates a C++/CLI AssemblyInfo file with the given attributes. - [] let createCppCli outputFileName attributes = createCppCliWithConfig outputFileName attributes AssemblyInfoFileConfig.Default diff --git a/src/app/Fake.DotNet.NuGet/NuGet.fs b/src/app/Fake.DotNet.NuGet/NuGet.fs index 83693a2bc01..722b052b576 100644 --- a/src/app/Fake.DotNet.NuGet/NuGet.fs +++ b/src/app/Fake.DotNet.NuGet/NuGet.fs @@ -134,9 +134,6 @@ let RequireRange breakingPoint version = let private packageFileName parameters = sprintf "%s.%s.nupkg" parameters.Project parameters.Version -[] -let private FullName = Path.getFullName - /// Gets the version no. for a given package in the deployments folder let GetPackageVersion deploymentsDir package = try @@ -331,10 +328,10 @@ let rec private publish parameters = | Some source, Some symSource -> sprintf "-source %s -SymbolSource %s -SymbolApiKey %s" source symSource parameters.SymbolAccessKey - let args = sprintf "push \"%s\" %s %s" (parameters.OutputPath @@ packageFileName parameters |> FullName) + let args = sprintf "push \"%s\" %s %s" (parameters.OutputPath @@ packageFileName parameters |> Path.getFullName) parameters.AccessKey source Trace.tracefn "%s %s in WorkingDir: %s Trials left: %d" parameters.ToolPath args - (FullName parameters.WorkingDir) parameters.PublishTrials + (Path.getFullName parameters.WorkingDir) parameters.PublishTrials try let result = let tracing = Process.shouldEnableProcessTracing() @@ -343,7 +340,7 @@ let rec private publish parameters = Process.execSimple ((fun info -> { info with FileName = parameters.ToolPath - WorkingDirectory = FullName parameters.WorkingDir + WorkingDirectory = Path.getFullName parameters.WorkingDir Arguments = args }) >> Process.withFramework) parameters.TimeOut finally Process.setEnableProcessTracing tracing if result <> 0 then @@ -359,7 +356,7 @@ let rec private publishSymbols parameters = sprintf "push -source %s \"%s\" %s" parameters.PublishUrl (packageFileName parameters) parameters.AccessKey Trace.tracefn "%s %s in WorkingDir: %s Trials left: %d" parameters.ToolPath args - (FullName parameters.WorkingDir) parameters.PublishTrials + (Path.getFullName parameters.WorkingDir) parameters.PublishTrials try let result = let tracing = Process.shouldEnableProcessTracing() @@ -368,7 +365,7 @@ let rec private publishSymbols parameters = Process.execSimple ((fun info -> { info with FileName = parameters.ToolPath - WorkingDirectory = FullName parameters.WorkingDir + WorkingDirectory = Path.getFullName parameters.WorkingDir Arguments = args }) >> Process.withFramework) parameters.TimeOut finally Process.setEnableProcessTracing tracing if result <> 0 then diff --git a/src/app/Fake.DotNet.Xamarin/Xamarin.fs b/src/app/Fake.DotNet.Xamarin/Xamarin.fs index dbcff42ccf4..220738bb225 100644 --- a/src/app/Fake.DotNet.Xamarin/Xamarin.fs +++ b/src/app/Fake.DotNet.Xamarin/Xamarin.fs @@ -300,13 +300,13 @@ let AndroidBuildPackages setParams = rewriteManifestFile manifestFile specificManifest transformVersion target // workaround for xamarin bug: https://bugzilla.xamarin.com/show_bug.cgi?id=30571 let backupFn = (manifestFile |> Path.GetDirectoryName) @@ ("AndroidManifest-original.xml") - Shell.CopyFile backupFn manifestFile - Shell.CopyFile manifestFile specificManifest + Shell.copyFile backupFn manifestFile + Shell.copyFile manifestFile specificManifest try //buildPackages param (Some name) (Some specificManifest) // to uncomment after xamarin fix there bug buildPackages param (Some name) None finally - Shell.CopyFile manifestFile backupFn + Shell.copyFile manifestFile backupFn let translateAbi = function | AndroidAbiTarget.X86 _ -> "x86" diff --git a/src/test/Fake.Core.IntegrationTests/TestHelpers.fs b/src/test/Fake.Core.IntegrationTests/TestHelpers.fs index 01c8b25bbad..06e470e06fa 100644 --- a/src/test/Fake.Core.IntegrationTests/TestHelpers.fs +++ b/src/test/Fake.Core.IntegrationTests/TestHelpers.fs @@ -37,7 +37,7 @@ let prepare scenario = let directFakeInPath command scenarioPath target = let result = - Process.execWithResult (fun (info:Process.ProcStartInfo) -> + Process.execWithResult (fun (info:ProcStartInfo) -> { info with FileName = fakeToolPath WorkingDirectory = scenarioPath @@ -88,4 +88,4 @@ let checkIntellisense scriptName scenario = let fakeRunAndCheck scriptName runArgs scenario = let result = fakeRun runArgs scenario checkIntellisense scriptName scenario - result \ No newline at end of file + result From cdd194c26e206ae20587132c10b7423f00888ea4 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 15:36:38 +0100 Subject: [PATCH 12/26] Add the new file into FakeLib.fsproj --- src/legacy/FakeLib/FakeLib.fsproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/legacy/FakeLib/FakeLib.fsproj b/src/legacy/FakeLib/FakeLib.fsproj index 9bed927fc95..134c7e6d936 100644 --- a/src/legacy/FakeLib/FakeLib.fsproj +++ b/src/legacy/FakeLib/FakeLib.fsproj @@ -63,6 +63,9 @@ Fake.Core.Context/Context.fs + + Fake.Core.Variables/Variables.fs + Fake.Core.CommandLineParsing/Options.fs From b71163e99885bf45f09402001b67def6cce4845a Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 17:35:33 +0100 Subject: [PATCH 13/26] Added tests for type mismatch Improved interface for remove and set variables --- src/app/Fake.Core.Variables/Variables.fs | 46 +++++++++++-------- .../Fake.Core.Variables.fs | 8 ++++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs index c4dc522f943..f66c7ee71b9 100644 --- a/src/app/Fake.Core.Variables/Variables.fs +++ b/src/app/Fake.Core.Variables/Variables.fs @@ -6,7 +6,11 @@ open Fake.Core.Context let get<'a> name = forceFakeContext() |> getFakeContext name - |> Option.map (fun o -> o :?> 'a) + |> Option.map (fun o -> try + o :?> 'a + with e -> + failwithf "Variable '%s' - %s" name e.Message + ) let getOrFail<'a> name = match get<'a> name with @@ -21,29 +25,35 @@ let getOrDefault<'a> name defaultValue = let remove name = forceFakeContext() |> removeFakeContext name - |> Option.map (fun o -> o :?> 'a) + |> ignore let set name (v:'a) = forceFakeContext() |> setFakeContext name v (fun _ -> v :> obj) - :?> 'a + |> ignore let fakeVar<'a> name = (fun () -> get name : 'a option), - (fun () -> (remove name : 'a option) |> ignore), - (fun (v : 'a) -> set name v |> ignore) + (fun () -> remove name), + (fun (v : 'a) -> set name v) let fakeVarNoContext<'a> name = - let mutable varWithoutContext = None - (fun () -> - if isFakeContext() then - get name : 'a option - else varWithoutContext), - (fun () -> - if isFakeContext() then - (remove name : 'a option) |> ignore - else varWithoutContext <- None), - (fun (v : 'a) -> - if isFakeContext() then - set name v |> ignore - else varWithoutContext <- Some v) + let mutable varWithoutContext = None + (fun () -> + if isFakeContext() then + get name : 'a option + else + varWithoutContext + ), + (fun () -> + if isFakeContext() then + remove name + else + varWithoutContext <- None + ), + (fun (v : 'a) -> + if isFakeContext() then + set name v + else + varWithoutContext <- Some v + ) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs index e321d9b9312..c3acd72404b 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs @@ -12,6 +12,14 @@ let tests = Expect.isSome value "Variable 'Test' is none" Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" + Fake.ContextHelper.fakeContextTestCase "When type does not match, errors" <| fun _ -> + set "Test" "TestValue" |> ignore + try + get "Test" |> ignore + Tests.failtest "Expected exception" + with e -> + Expect.equal "Variable 'Test' - Unable to cast object of type 'System.String' to type 'System.Boolean'." e.Message "Incorrect failure message for variable failure case" + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> set "Test" "TestValue" |> ignore let value = getOrDefault "Test" "DefaultValue" From e1f8edd61f7424bf51bc63772b0a879b33f827c2 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 18:15:31 +0100 Subject: [PATCH 14/26] Add [] to variables.fs --- src/app/Fake.Core.Variables/Variables.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs index f66c7ee71b9..ce261f15e8e 100644 --- a/src/app/Fake.Core.Variables/Variables.fs +++ b/src/app/Fake.Core.Variables/Variables.fs @@ -1,4 +1,5 @@ /// This module contains helpers for managing build time variables +[] module Fake.Core.Variables open Fake.Core.Context From 6dba481a8e968d2574ea6f84de210af8fa8e82ad Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 18:17:20 +0100 Subject: [PATCH 15/26] Update error message on cast error --- src/app/Fake.Core.Variables/Variables.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs index ce261f15e8e..3d47ab335e3 100644 --- a/src/app/Fake.Core.Variables/Variables.fs +++ b/src/app/Fake.Core.Variables/Variables.fs @@ -10,7 +10,7 @@ let get<'a> name = |> Option.map (fun o -> try o :?> 'a with e -> - failwithf "Variable '%s' - %s" name e.Message + raise <| exn(sprintf "Cast error on variable %s" name, e) ) let getOrFail<'a> name = From 5882326b02514bbdb39b097229e25111b0471d2b Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 18:19:31 +0100 Subject: [PATCH 16/26] Fix tests now error has changed --- src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs index c3acd72404b..d8d60fe2f84 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs @@ -18,7 +18,7 @@ let tests = get "Test" |> ignore Tests.failtest "Expected exception" with e -> - Expect.equal "Variable 'Test' - Unable to cast object of type 'System.String' to type 'System.Boolean'." e.Message "Incorrect failure message for variable failure case" + Expect.equal "Cast error on variable 'Test'" e.Message "Incorrect failure message for variable failure case" Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> set "Test" "TestValue" |> ignore From 4a9867b3c1c61d0a2b80016bdeb81368701bef2c Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 18:21:56 +0100 Subject: [PATCH 17/26] Improve cast error message --- src/app/Fake.Core.Variables/Variables.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs index 3d47ab335e3..a43a145c795 100644 --- a/src/app/Fake.Core.Variables/Variables.fs +++ b/src/app/Fake.Core.Variables/Variables.fs @@ -10,7 +10,7 @@ let get<'a> name = |> Option.map (fun o -> try o :?> 'a with e -> - raise <| exn(sprintf "Cast error on variable %s" name, e) + raise <| exn(sprintf "Cast error on variable '%s'" name, e) ) let getOrFail<'a> name = From d662d6349844ec776415cfff39393f34c95b6bd1 Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Mon, 4 Jun 2018 20:06:26 +0200 Subject: [PATCH 18/26] Fix compilation --- .../Fake.Core.Variables.fs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs index d8d60fe2f84..41e79d84703 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs @@ -1,42 +1,42 @@ module Fake.Core.VariablesTests -open Fake.Core.Variables +open Fake.Core open Expecto [] let tests = testList "Fake.Core.Variables.Tests" [ Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables" <| fun _ -> - set "Test" "TestValue" |> ignore - let value = get "Test" + Variables.set "Test" "TestValue" |> ignore + let value = Variables.get "Test" Expect.isSome value "Variable 'Test' is none" Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" Fake.ContextHelper.fakeContextTestCase "When type does not match, errors" <| fun _ -> - set "Test" "TestValue" |> ignore + Variables.set "Test" "TestValue" |> ignore try - get "Test" |> ignore + Variables.get "Test" |> ignore Tests.failtest "Expected exception" with e -> Expect.equal "Cast error on variable 'Test'" e.Message "Incorrect failure message for variable failure case" Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> - set "Test" "TestValue" |> ignore - let value = getOrDefault "Test" "DefaultValue" + Variables.set "Test" "TestValue" |> ignore + let value = Variables.getOrDefault "Test" "DefaultValue" Expect.equal "TestValue" value "Variable 'Test' is incorrect" Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when not found" <| fun _ -> - let value = getOrDefault "Test" "DefaultValue" + let value = Variables.getOrDefault "Test" "DefaultValue" Expect.equal "DefaultValue" value "Variable 'Test' is not the default" Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when found" <| fun _ -> - set "Test" "TestValue" |> ignore - let value = getOrFail "Test" + Variables.set "Test" "TestValue" |> ignore + let value = Variables.getOrFail "Test" Expect.equal "TestValue" value "Variable 'Test' is incorrect" Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> try - getOrFail "Test" |> ignore + Variables.getOrFail "Test" |> ignore Tests.failtest "Expected exception" with e -> Expect.equal "Unable to find variable 'Test'" e.Message "Incorrect failure message for variable failure case" From baca2d8f1ae95fe0f36ffb748cc6d390285e85b6 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Mon, 4 Jun 2018 20:14:36 +0100 Subject: [PATCH 19/26] Rename Fake.Core.Variables to Fake.Core.FakeVar --- Fake.sln | 2 +- src/app/Fake.Core.Context/Context.fs | 10 +-- .../AssemblyInfo.fs | 4 +- .../Fake.Core.FakeVar.fsproj} | 4 +- src/app/Fake.Core.FakeVar/FakeVar.fs | 62 +++++++++++++++ .../paket.references | 0 .../Fake.Core.Process.fsproj | 2 +- src/app/Fake.Core.Process/Process.fs | 6 +- .../Fake.Core.Target/Fake.Core.Target.fsproj | 2 +- src/app/Fake.Core.Target/Target.fs | 6 +- .../Fake.Core.Trace/Fake.Core.Trace.fsproj | 2 +- src/app/Fake.Core.Trace/TraceListener.fs | 4 +- src/app/Fake.Core.Variables/Variables.fs | 60 --------------- src/legacy/FakeLib/FakeLib.fsproj | 4 +- .../Fake.Core.UnitTests/Fake.Core.FakeVar.fs | 77 +++++++++++++++++++ .../Fake.Core.UnitTests.fsproj | 3 +- .../Fake.Core.Variables.fs | 43 ----------- 17 files changed, 164 insertions(+), 127 deletions(-) rename src/app/{Fake.Core.Variables => Fake.Core.FakeVar}/AssemblyInfo.fs (80%) rename src/app/{Fake.Core.Variables/Fake.Core.Variables.fsproj => Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj} (88%) create mode 100644 src/app/Fake.Core.FakeVar/FakeVar.fs rename src/app/{Fake.Core.Variables => Fake.Core.FakeVar}/paket.references (100%) delete mode 100644 src/app/Fake.Core.Variables/Variables.fs create mode 100644 src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs delete mode 100644 src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs diff --git a/Fake.sln b/Fake.sln index 7ac9ca460dc..c6add293bdd 100644 --- a/Fake.sln +++ b/Fake.sln @@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{7BFFAE76-DEE EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Context", "src/app/Fake.Core.Context/Fake.Core.Context.fsproj", "{D3D92ED7-C2B9-46D5-B611-A2CF0C30C8DB}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Variables", "src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj", "{1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.FakeVar", "src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj", "{1CEE1FC0-41F4-4F6C-A409-3849B30D57EF}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.Core.Environment", "src/app/Fake.Core.Environment/Fake.Core.Environment.fsproj", "{A2C4A85F-24C4-4FFA-B165-4807B1127C4E}" EndProject diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 4d42c7c430b..38ba8cf0a69 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -112,31 +112,31 @@ let forceFakeContext () = invalidOp "no Fake Execution context was found. You can initialize one via Fake.Core.Context.setExecutionContext" | RuntimeContext.Fake e -> e -[] +[] let getFakeVar name = forceFakeContext() |> getFakeContext name |> Option.map (fun o -> o :?> 'a) -[] +[] let removeFakeVar name = forceFakeContext() |> removeFakeContext name |> Option.map (fun o -> o :?> 'a) -[] +[] let setFakeVar name (v:'a) = forceFakeContext() |> setFakeContext name v (fun _ -> v :> obj) :?> 'a -[] +[] let fakeVar name = (fun () -> getFakeVar name : 'a option), (fun () -> (removeFakeVar name : 'a option) |> ignore), (fun (v : 'a) -> setFakeVar name v |> ignore) -[] +[] let fakeVarAllowNoContext name = let mutable varWithoutContext = None (fun () -> diff --git a/src/app/Fake.Core.Variables/AssemblyInfo.fs b/src/app/Fake.Core.FakeVar/AssemblyInfo.fs similarity index 80% rename from src/app/Fake.Core.Variables/AssemblyInfo.fs rename to src/app/Fake.Core.FakeVar/AssemblyInfo.fs index 227eddf101a..906ad25a585 100644 --- a/src/app/Fake.Core.Variables/AssemblyInfo.fs +++ b/src/app/Fake.Core.FakeVar/AssemblyInfo.fs @@ -2,7 +2,7 @@ namespace System open System.Reflection -[] +[] [] [] [] @@ -10,7 +10,7 @@ open System.Reflection do () module internal AssemblyVersionInformation = - let [] AssemblyTitle = "FAKE - F# Make Core Variables" + let [] AssemblyTitle = "FAKE - F# Make Core FakeVar" let [] AssemblyProduct = "FAKE - F# Make" let [] AssemblyVersion = "5.0.0" let [] AssemblyInformationalVersion = "5.0.0.0" diff --git a/src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj b/src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj similarity index 88% rename from src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj rename to src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj index af6a02f6844..efdb163ca50 100644 --- a/src/app/Fake.Core.Variables/Fake.Core.Variables.fsproj +++ b/src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj @@ -1,7 +1,7 @@ net46;netstandard1.6;netstandard2.0 - Fake.Core.Variables + Fake.Core.FakeVar Library @@ -9,7 +9,7 @@ - + diff --git a/src/app/Fake.Core.FakeVar/FakeVar.fs b/src/app/Fake.Core.FakeVar/FakeVar.fs new file mode 100644 index 00000000000..a8eac775a31 --- /dev/null +++ b/src/app/Fake.Core.FakeVar/FakeVar.fs @@ -0,0 +1,62 @@ +/// This module contains helpers for managing build time variables +[] +module Fake.Core.FakeVar + +open Fake.Core.Context + +/// Gets a strongly typed FakeVar by name returning an option type +let get<'a> name = + forceFakeContext() + |> getFakeContext name + |> Option.map (fun o -> try + o :?> 'a + with e -> + raise <| exn(sprintf "Cast error on variable '%s'" name, e) + ) + +/// Gets a strongly typed FakeVar by name will fail if variable is not found +let getOrFail<'a> name = + match get<'a> name with + | Some v -> v + | _ -> failwithf "Unable to find variable '%s'" name + +/// Gets a strongly typed FakeVar by name will return default value if variable is not found +let getOrDefault<'a> name defaultValue = + match get<'a> name with + | Some v -> v + | _ -> defaultValue + +/// Removes a FakeVar by name +let remove name = + forceFakeContext() + |> removeFakeContext name + |> ignore + +/// Sets value of a FakeVar +let set name (v:'a) = + forceFakeContext() + |> setFakeContext name v (fun _ -> v :> obj) + |> ignore + +/// Define a named FakeVar providing the get, remove and set +/// Will fail if there is no context +let define<'a> name = + if isFakeContext() then + (fun () -> get name : 'a option), + (fun () -> remove name), + (fun (v : 'a) -> set name v) + else + failwithf "Cannot define variable %s without context" name + +/// Define a named FakeVar providing the get, remove and set +/// Will create a local variable if there is no context +let defineAllowNoContext<'a> name = + if isFakeContext() then + (fun () -> get name : 'a option), + (fun () -> remove name), + (fun (v : 'a) -> set name v) + else + let mutable varWithoutContext = None + (fun () -> varWithoutContext), + (fun () -> varWithoutContext <- None), + (fun (v : 'a) -> varWithoutContext <- Some v) diff --git a/src/app/Fake.Core.Variables/paket.references b/src/app/Fake.Core.FakeVar/paket.references similarity index 100% rename from src/app/Fake.Core.Variables/paket.references rename to src/app/Fake.Core.FakeVar/paket.references diff --git a/src/app/Fake.Core.Process/Fake.Core.Process.fsproj b/src/app/Fake.Core.Process/Fake.Core.Process.fsproj index cfe5d01ad2b..9d4a3ff7400 100644 --- a/src/app/Fake.Core.Process/Fake.Core.Process.fsproj +++ b/src/app/Fake.Core.Process/Fake.Core.Process.fsproj @@ -22,7 +22,7 @@ - + diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index 9bc224f1589..f224017736a 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -260,7 +260,7 @@ module Process = //let startedProcesses = HashSet() let private startedProcessesVar = "Fake.Core.Process.startedProcesses" let private getStartedProcesses, _, private setStartedProcesses = - Fake.Core.Variables.fakeVar startedProcessesVar + Fake.Core.FakeVar.define startedProcessesVar let private doWithProcessList f = if Fake.Core.Context.isFakeContext () then @@ -334,7 +334,7 @@ module Process = //let mutable redirectOutputToTrace = false let private redirectOutputToTraceVar = "Fake.Core.Process.redirectOutputToTrace" let private tryGetRedirectOutputToTrace, _, public setRedirectOutputToTrace = - Fake.Core.Variables.fakeVarNoContext redirectOutputToTraceVar + Fake.Core.FakeVar.defineAllowNoContext redirectOutputToTraceVar let getRedirectOutputToTrace () = match tryGetRedirectOutputToTrace() with | Some v -> v @@ -347,7 +347,7 @@ module Process = //let mutable enableProcessTracing = true let private enableProcessTracingVar = "Fake.Core.Process.enableProcessTracing" let private getEnableProcessTracing, private removeEnableProcessTracing, public setEnableProcessTracing = - Fake.Core.Variables.fakeVarNoContext enableProcessTracingVar + Fake.Core.FakeVar.defineAllowNoContext enableProcessTracingVar let shouldEnableProcessTracing () = match getEnableProcessTracing() with | Some v -> v diff --git a/src/app/Fake.Core.Target/Fake.Core.Target.fsproj b/src/app/Fake.Core.Target/Fake.Core.Target.fsproj index 331e21c5d0c..25918174e05 100644 --- a/src/app/Fake.Core.Target/Fake.Core.Target.fsproj +++ b/src/app/Fake.Core.Target/Fake.Core.Target.fsproj @@ -17,7 +17,7 @@ - + diff --git a/src/app/Fake.Core.Target/Target.fs b/src/app/Fake.Core.Target/Target.fs index 2fade0f5a5a..93178615fe1 100644 --- a/src/app/Fake.Core.Target/Target.fs +++ b/src/app/Fake.Core.Target/Target.fs @@ -105,13 +105,13 @@ module Target = //let mutable PrintStackTraceOnError = false let private printStackTraceOnErrorVar = "Fake.Core.Target.PrintStackTraceOnError" let private getPrintStackTraceOnError, _, (setPrintStackTraceOnError:bool -> unit) = - Fake.Core.Variables.fakeVar printStackTraceOnErrorVar + Fake.Core.FakeVar.define printStackTraceOnErrorVar /// [omit] //let mutable LastDescription = null let private lastDescriptionVar = "Fake.Core.Target.LastDescription" let private getLastDescription, removeLastDescription, setLastDescription = - Fake.Core.Variables.fakeVar lastDescriptionVar + Fake.Core.FakeVar.define lastDescriptionVar /// Sets the Description for the next target. /// [omit] @@ -132,7 +132,7 @@ module Target = let internal getVarWithInit name f = let varName = sprintf "Fake.Core.Target.%s" name let getVar, _, setVar = - Fake.Core.Variables.fakeVar varName + Fake.Core.FakeVar.define varName fun () -> match getVar() with | Some d -> d diff --git a/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj b/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj index 9e638d9a3a0..a860ada9908 100644 --- a/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj +++ b/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj @@ -19,7 +19,7 @@ - + diff --git a/src/app/Fake.Core.Trace/TraceListener.fs b/src/app/Fake.Core.Trace/TraceListener.fs index 79477d1b60d..9bc8e0266a5 100644 --- a/src/app/Fake.Core.Trace/TraceListener.fs +++ b/src/app/Fake.Core.Trace/TraceListener.fs @@ -270,7 +270,7 @@ type TraceSecret = module TraceSecrets = let private traceSecretsVar = "Fake.Core.Trace.TraceSecrets" let private getTraceSecrets, _, (setTraceSecrets:TraceSecret list -> unit) = - Fake.Core.Variables.fakeVar traceSecretsVar + Fake.Core.FakeVar.define traceSecretsVar let getAll () = match getTraceSecrets() with @@ -302,7 +302,7 @@ module CoreTracing = let private traceListenersVar = "Fake.Core.Trace.TraceListeners" let private getTraceListeners, _, (setTraceListenersPrivate:ITraceListener list -> unit) = - Fake.Core.Variables.fakeVar traceListenersVar + Fake.Core.FakeVar.define traceListenersVar let areListenersSet () = match getTraceListeners() with diff --git a/src/app/Fake.Core.Variables/Variables.fs b/src/app/Fake.Core.Variables/Variables.fs deleted file mode 100644 index a43a145c795..00000000000 --- a/src/app/Fake.Core.Variables/Variables.fs +++ /dev/null @@ -1,60 +0,0 @@ -/// This module contains helpers for managing build time variables -[] -module Fake.Core.Variables - -open Fake.Core.Context - -let get<'a> name = - forceFakeContext() - |> getFakeContext name - |> Option.map (fun o -> try - o :?> 'a - with e -> - raise <| exn(sprintf "Cast error on variable '%s'" name, e) - ) - -let getOrFail<'a> name = - match get<'a> name with - | Some v -> v - | _ -> failwithf "Unable to find variable '%s'" name - -let getOrDefault<'a> name defaultValue = - match get<'a> name with - | Some v -> v - | _ -> defaultValue - -let remove name = - forceFakeContext() - |> removeFakeContext name - |> ignore - -let set name (v:'a) = - forceFakeContext() - |> setFakeContext name v (fun _ -> v :> obj) - |> ignore - -let fakeVar<'a> name = - (fun () -> get name : 'a option), - (fun () -> remove name), - (fun (v : 'a) -> set name v) - -let fakeVarNoContext<'a> name = - let mutable varWithoutContext = None - (fun () -> - if isFakeContext() then - get name : 'a option - else - varWithoutContext - ), - (fun () -> - if isFakeContext() then - remove name - else - varWithoutContext <- None - ), - (fun (v : 'a) -> - if isFakeContext() then - set name v - else - varWithoutContext <- Some v - ) diff --git a/src/legacy/FakeLib/FakeLib.fsproj b/src/legacy/FakeLib/FakeLib.fsproj index 134c7e6d936..c3fe72ee94c 100644 --- a/src/legacy/FakeLib/FakeLib.fsproj +++ b/src/legacy/FakeLib/FakeLib.fsproj @@ -63,8 +63,8 @@ Fake.Core.Context/Context.fs - - Fake.Core.Variables/Variables.fs + + Fake.Core.FakeVar/FakeVar.fs Fake.Core.CommandLineParsing/Options.fs diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs b/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs new file mode 100644 index 00000000000..d9702c78122 --- /dev/null +++ b/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs @@ -0,0 +1,77 @@ +module Fake.Core.FakeVarTests + +open Fake.Core +open Expecto + +[] +let tests = + testList "Fake.Core.FakeVar.Tests" [ + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables" <| fun _ -> + FakeVar.set "Test" "TestValue" + let value = FakeVar.get "Test" + Expect.isSome value "Variable 'Test' is none" + Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to remove fake variables after set" <| fun _ -> + FakeVar.set "Test" "TestValue" + FakeVar.remove "Test" + let value = FakeVar.get "Test" + Expect.isNone value "Variable 'Test' is some" + + Fake.ContextHelper.fakeContextTestCase "When type does not match, errors" <| fun _ -> + FakeVar.set "Test" "TestValue" + try + FakeVar.get "Test" |> ignore + Tests.failtest "Expected exception" + with e -> + Expect.equal "Cast error on variable 'Test'" e.Message "Incorrect failure message for variable failure case" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> + FakeVar.set "Test" "TestValue" + let value = FakeVar.getOrDefault "Test" "DefaultValue" + Expect.equal "TestValue" value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when not found" <| fun _ -> + let value = FakeVar.getOrDefault "Test" "DefaultValue" + Expect.equal "DefaultValue" value "Variable 'Test' is not the default" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when found" <| fun _ -> + FakeVar.set "Test" "TestValue" + let value = FakeVar.getOrFail "Test" + Expect.equal "TestValue" value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> + try + FakeVar.getOrFail "Test" |> ignore + Tests.failtest "Expected exception" + with e -> + Expect.equal "Unable to find variable 'Test'" e.Message "Incorrect failure message for variable failure case" + + Fake.ContextHelper.fakeContextTestCase "Ability to define variable" <| fun _ -> + let myGet, myRemove, mySet = FakeVar.define "Test" + mySet "TestValue" + let value = myGet "Test" + Expect.isSome value "Variable 'Test' is none" + Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" + + Fake.ContextHelper.fakeContextTestCase "Ability to define variable allowing non context" <| fun _ -> + let myGet, myRemove, mySet = FakeVar.defineAllowNoContext "Test" + mySet "TestValue" + let value = myGet "Test" + Expect.isSome value "Variable 'Test' is none" + Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" + + TestCase "Ability to define variable with no context" <| fun _ -> + let myGet, myRemove, mySet = FakeVar.defineAllowNoContext "Test" + mySet "TestValue" + let value = myGet "Test" + Expect.isSome value "Variable 'Test' is none" + Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" + + TestCase "Ability to define variable with no context when context required" <| fun _ -> + try + let myGet, myRemove, mySet = FakeVar.define "Test" + Tests.failtest "Expected exception" + with e -> + Expect.equal "Cannot define 'Test' without context" e.Message "Incorrect failure message for variable failure case" + ] diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj index 9fb4a0b32f4..5497572b258 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj +++ b/src/test/Fake.Core.UnitTests/Fake.Core.UnitTests.fsproj @@ -10,6 +10,7 @@ + @@ -31,7 +32,7 @@ - + diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs deleted file mode 100644 index 41e79d84703..00000000000 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Variables.fs +++ /dev/null @@ -1,43 +0,0 @@ -module Fake.Core.VariablesTests - -open Fake.Core -open Expecto - -[] -let tests = - testList "Fake.Core.Variables.Tests" [ - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables" <| fun _ -> - Variables.set "Test" "TestValue" |> ignore - let value = Variables.get "Test" - Expect.isSome value "Variable 'Test' is none" - Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" - - Fake.ContextHelper.fakeContextTestCase "When type does not match, errors" <| fun _ -> - Variables.set "Test" "TestValue" |> ignore - try - Variables.get "Test" |> ignore - Tests.failtest "Expected exception" - with e -> - Expect.equal "Cast error on variable 'Test'" e.Message "Incorrect failure message for variable failure case" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when found" <| fun _ -> - Variables.set "Test" "TestValue" |> ignore - let value = Variables.getOrDefault "Test" "DefaultValue" - Expect.equal "TestValue" value "Variable 'Test' is incorrect" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with default - when not found" <| fun _ -> - let value = Variables.getOrDefault "Test" "DefaultValue" - Expect.equal "DefaultValue" value "Variable 'Test' is not the default" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when found" <| fun _ -> - Variables.set "Test" "TestValue" |> ignore - let value = Variables.getOrFail "Test" - Expect.equal "TestValue" value "Variable 'Test' is incorrect" - - Fake.ContextHelper.fakeContextTestCase "Ability to set and get fake variables with failure - when not found" <| fun _ -> - try - Variables.getOrFail "Test" |> ignore - Tests.failtest "Expected exception" - with e -> - Expect.equal "Unable to find variable 'Test'" e.Message "Incorrect failure message for variable failure case" - ] From 2b66f5a87aeec9306d46beaa76ccd221f8202943 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 10:44:06 +0100 Subject: [PATCH 20/26] add vscode restore task & nest FakeVar project in Fake.sln --- .vscode/tasks.json | 10 ++++++++++ Fake.sln | 1 + 2 files changed, 11 insertions(+) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9d1731cec75..5925c9a8835 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,6 +3,16 @@ // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ + { + "label": "dotnet:restore:fake.sln", + "group": "build", + "command": "dotnet restore FAKE.sln", + "type": "shell", + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, { "label": "dotnet:build:fake.sln", "group": "build", diff --git a/Fake.sln b/Fake.sln index c6add293bdd..592d83f7310 100644 --- a/Fake.sln +++ b/Fake.sln @@ -906,6 +906,7 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {D3D92ED7-C2B9-46D5-B611-A2CF0C30C8DB} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} + {1CEE1FC0-41F4-4F6C-A409-3849B30D57EF} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} {A2C4A85F-24C4-4FFA-B165-4807B1127C4E} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} {DB09FF66-8750-40B8-9E25-70FADD9CF0BD} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} {FEDE1F15-C0A5-4DA1-B20D-0A0C28F6858E} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A} From 167163686791a61848ca8d02bdae0aae50847c65 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 12:13:55 +0100 Subject: [PATCH 21/26] Test fixes --- .../Fake.Core.UnitTests/Fake.Core.FakeVar.fs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs b/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs index d9702c78122..75d106967f7 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.FakeVar.fs @@ -48,30 +48,30 @@ let tests = Expect.equal "Unable to find variable 'Test'" e.Message "Incorrect failure message for variable failure case" Fake.ContextHelper.fakeContextTestCase "Ability to define variable" <| fun _ -> - let myGet, myRemove, mySet = FakeVar.define "Test" + let myGet, _, mySet = FakeVar.define "Test" mySet "TestValue" - let value = myGet "Test" + let value = myGet() Expect.isSome value "Variable 'Test' is none" Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" Fake.ContextHelper.fakeContextTestCase "Ability to define variable allowing non context" <| fun _ -> - let myGet, myRemove, mySet = FakeVar.defineAllowNoContext "Test" + let myGet, _, mySet = FakeVar.defineAllowNoContext "Test" mySet "TestValue" - let value = myGet "Test" + let value = myGet() Expect.isSome value "Variable 'Test' is none" Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" - TestCase "Ability to define variable with no context" <| fun _ -> - let myGet, myRemove, mySet = FakeVar.defineAllowNoContext "Test" + testCase "Ability to define variable with no context" <| fun _ -> + let myGet, _, mySet = FakeVar.defineAllowNoContext "Test" mySet "TestValue" - let value = myGet "Test" + let value = myGet() Expect.isSome value "Variable 'Test' is none" Expect.equal "TestValue" value.Value "Variable 'Test' is incorrect" - TestCase "Ability to define variable with no context when context required" <| fun _ -> + testCase "Ability to define variable with no context when context required" <| fun _ -> try - let myGet, myRemove, mySet = FakeVar.define "Test" + let _, _, _ = FakeVar.define "Test" Tests.failtest "Expected exception" with e -> - Expect.equal "Cannot define 'Test' without context" e.Message "Incorrect failure message for variable failure case" + Expect.equal "Cannot define variable 'Test' without context" e.Message "Incorrect failure message for variable failure case" ] From 9448868a2bfe4bb2e042696eb0000e5745a4ed95 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 12:46:53 +0100 Subject: [PATCH 22/26] Remove redundant statements --- src/app/Fake.Tools.Git/CommandHelper.fs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/app/Fake.Tools.Git/CommandHelper.fs b/src/app/Fake.Tools.Git/CommandHelper.fs index 9d175dc41bd..6e6361a84f3 100644 --- a/src/app/Fake.Tools.Git/CommandHelper.fs +++ b/src/app/Fake.Tools.Git/CommandHelper.fs @@ -2,11 +2,7 @@ module Fake.Tools.Git.CommandHelper open System -open System.Diagnostics open System.IO -open System.Threading -open System.Text -open System.Collections.Generic open Fake.Core open Fake.Core.String.Operators open Fake.IO @@ -72,7 +68,7 @@ let gitCommandf repositoryDir fmt = Printf.ksprintf (gitCommand repositoryDir) f /// Runs the given git command, waits for its completion. /// This version doesn't throw an exception if an error occurs. It just traces the error. let showGitCommand repositoryDir command = - let ok,msg,errors = runGitCommand repositoryDir command + let _,msg,errors = runGitCommand repositoryDir command msg |> Seq.iter (Trace.logfn "%s") if errors <> "" then Trace.traceError <| sprintf "Errors: %s" errors @@ -80,7 +76,7 @@ let showGitCommand repositoryDir command = /// Runs the git command and returns the first line of the result. let runSimpleGitCommand repositoryDir command = try - let ok,msg,errors = runGitCommand repositoryDir command + let _,msg,errors = runGitCommand repositoryDir command let errorText = String.toLines msg + Environment.NewLine + errors if errorText.Contains "fatal: " then From 7faa14ca18ee30c3f676639c80e87a6fbd89d3f4 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 12:49:01 +0100 Subject: [PATCH 23/26] Correct FakeVar error message --- src/app/Fake.Core.FakeVar/FakeVar.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/Fake.Core.FakeVar/FakeVar.fs b/src/app/Fake.Core.FakeVar/FakeVar.fs index a8eac775a31..9e8bd59a87f 100644 --- a/src/app/Fake.Core.FakeVar/FakeVar.fs +++ b/src/app/Fake.Core.FakeVar/FakeVar.fs @@ -46,7 +46,7 @@ let define<'a> name = (fun () -> remove name), (fun (v : 'a) -> set name v) else - failwithf "Cannot define variable %s without context" name + failwithf "Cannot define variable '%s' without context" name /// Define a named FakeVar providing the get, remove and set /// Will create a local variable if there is no context From e6497746238f17800ce5e418b801b994097c1572 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 14:20:56 +0100 Subject: [PATCH 24/26] Test fixes --- src/app/Fake.Core.Process/Process.fs | 2 +- src/test/Fake.Core.UnitTests/Fake.Core.Process.fs | 4 ++-- src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index f224017736a..e00baf53076 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -260,7 +260,7 @@ module Process = //let startedProcesses = HashSet() let private startedProcessesVar = "Fake.Core.Process.startedProcesses" let private getStartedProcesses, _, private setStartedProcesses = - Fake.Core.FakeVar.define startedProcessesVar + Fake.Core.FakeVar.define startedProcessesVar let private doWithProcessList f = if Fake.Core.Context.isFakeContext () then diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs index 5e5b0d73fca..92b65648377 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs @@ -8,7 +8,7 @@ open Expecto [] let tests = testList "Fake.Core.Process.Tests" [ - testCase "Test that we have a nice error message when a file doesn't exist" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Test that we have a nice error message when a file doesn't exist" <| fun _ -> try Process.start(fun proc -> { proc with @@ -20,7 +20,7 @@ let tests = let s = e.Message.Contains "FileDoesntExist.exe" Expect.isTrue s ("Expected file-path as part of the message '" + e.Message + "'") - testCase "Test that we can read messages correctly" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Test that we can read messages correctly" <| fun _ -> let shell, command = if Environment.isWindows then "cmd", "/C \"echo 1&& echo 2\"" diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index 6ef6f0df168..69d92656374 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -7,7 +7,7 @@ open Expecto [] let tests = testList "Fake.DotNet.MSBuild.Tests" [ - testCase "Test that we can create simple msbuild cmdline" <| fun _ -> + Fake.ContextHelper.fakeContextTestCase "Test that we can create simple msbuild cmdline" <| fun _ -> let cmdLine = { MSBuildParams.Create() with Properties = ["OutputPath", "C:\\Test\\"] } From b9fb1c2573a391a645bce3d6fb368e42d376296d Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 15:11:55 +0100 Subject: [PATCH 25/26] Simplify and add P2P="true" --- src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj | 2 +- src/app/Fake.Core.Target/Fake.Core.Target.fsproj | 2 +- src/app/Fake.Core.Tasks/Fake.Core.Tasks.fsproj | 6 ++---- src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj | 2 +- src/app/Fake.Core.Xml/Fake.Core.Xml.fsproj | 4 +--- .../Fake.DotNet.AssemblyInfoFile.fsproj | 4 +--- .../Fake.DotNet.FSFormatting.fsproj | 4 +--- src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj | 6 ++---- src/app/Fake.DotNet.Paket/Fake.DotNet.Paket.fsproj | 4 +--- .../Fake.DotNet.Testing.Expecto.fsproj | 8 ++------ .../Fake.DotNet.Testing.MSTest.fsproj | 8 ++------ .../Fake.DotNet.Testing.MSpec.fsproj | 8 ++------ .../Fake.DotNet.Testing.NUnit.fsproj | 8 ++------ .../Fake.DotNet.Testing.XUnit2.fsproj | 8 ++------ .../Fake.Testing.Common/Fake.Testing.Common.fsproj | 8 +++----- src/app/Fake.Tools.Git/Fake.Tools.Git.fsproj | 4 +--- .../Fake.Windows.Chocolatey.fsproj | 4 +--- src/app/Fake.netcore/Fake.netcore.fsproj | 12 +++--------- src/app/dotnet-fake/dotnet-fake.fsproj | 8 ++------ src/app/fake-cli/fake-cli.fsproj | 8 ++------ 20 files changed, 33 insertions(+), 85 deletions(-) diff --git a/src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj b/src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj index efdb163ca50..d0cfa879320 100644 --- a/src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj +++ b/src/app/Fake.Core.FakeVar/Fake.Core.FakeVar.fsproj @@ -12,7 +12,7 @@ - + diff --git a/src/app/Fake.Core.Target/Fake.Core.Target.fsproj b/src/app/Fake.Core.Target/Fake.Core.Target.fsproj index 25918174e05..a578c5de2f1 100644 --- a/src/app/Fake.Core.Target/Fake.Core.Target.fsproj +++ b/src/app/Fake.Core.Target/Fake.Core.Target.fsproj @@ -17,7 +17,7 @@ - + diff --git a/src/app/Fake.Core.Tasks/Fake.Core.Tasks.fsproj b/src/app/Fake.Core.Tasks/Fake.Core.Tasks.fsproj index 7ec1a094ccf..3997c189ddc 100644 --- a/src/app/Fake.Core.Tasks/Fake.Core.Tasks.fsproj +++ b/src/app/Fake.Core.Tasks/Fake.Core.Tasks.fsproj @@ -21,9 +21,7 @@ - - true - + - \ No newline at end of file + diff --git a/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj b/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj index a860ada9908..5f669864df3 100644 --- a/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj +++ b/src/app/Fake.Core.Trace/Fake.Core.Trace.fsproj @@ -19,7 +19,7 @@ - + diff --git a/src/app/Fake.Core.Xml/Fake.Core.Xml.fsproj b/src/app/Fake.Core.Xml/Fake.Core.Xml.fsproj index 7afef7693a8..4884d59307d 100644 --- a/src/app/Fake.Core.Xml/Fake.Core.Xml.fsproj +++ b/src/app/Fake.Core.Xml/Fake.Core.Xml.fsproj @@ -21,9 +21,7 @@ - - true - + \ No newline at end of file diff --git a/src/app/Fake.DotNet.AssemblyInfoFile/Fake.DotNet.AssemblyInfoFile.fsproj b/src/app/Fake.DotNet.AssemblyInfoFile/Fake.DotNet.AssemblyInfoFile.fsproj index 047abcbde0c..b91d15c230e 100644 --- a/src/app/Fake.DotNet.AssemblyInfoFile/Fake.DotNet.AssemblyInfoFile.fsproj +++ b/src/app/Fake.DotNet.AssemblyInfoFile/Fake.DotNet.AssemblyInfoFile.fsproj @@ -15,9 +15,7 @@ - - true - + \ No newline at end of file diff --git a/src/app/Fake.DotNet.FSFormatting/Fake.DotNet.FSFormatting.fsproj b/src/app/Fake.DotNet.FSFormatting/Fake.DotNet.FSFormatting.fsproj index 0b061c85003..75c9ee7d3e1 100644 --- a/src/app/Fake.DotNet.FSFormatting/Fake.DotNet.FSFormatting.fsproj +++ b/src/app/Fake.DotNet.FSFormatting/Fake.DotNet.FSFormatting.fsproj @@ -21,9 +21,7 @@ - - true - + \ No newline at end of file diff --git a/src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj b/src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj index ebecaf41be8..d5ea9369379 100644 --- a/src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj +++ b/src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj @@ -28,9 +28,7 @@ - - true - + - \ No newline at end of file + diff --git a/src/app/Fake.DotNet.Paket/Fake.DotNet.Paket.fsproj b/src/app/Fake.DotNet.Paket/Fake.DotNet.Paket.fsproj index 2fb99894579..79da316bfa1 100644 --- a/src/app/Fake.DotNet.Paket/Fake.DotNet.Paket.fsproj +++ b/src/app/Fake.DotNet.Paket/Fake.DotNet.Paket.fsproj @@ -22,9 +22,7 @@ - - true - + \ No newline at end of file diff --git a/src/app/Fake.DotNet.Testing.Expecto/Fake.DotNet.Testing.Expecto.fsproj b/src/app/Fake.DotNet.Testing.Expecto/Fake.DotNet.Testing.Expecto.fsproj index 7c9595fd0d6..34223c65969 100644 --- a/src/app/Fake.DotNet.Testing.Expecto/Fake.DotNet.Testing.Expecto.fsproj +++ b/src/app/Fake.DotNet.Testing.Expecto/Fake.DotNet.Testing.Expecto.fsproj @@ -21,12 +21,8 @@ - - true - - - true - + + \ No newline at end of file diff --git a/src/app/Fake.DotNet.Testing.MSTest/Fake.DotNet.Testing.MSTest.fsproj b/src/app/Fake.DotNet.Testing.MSTest/Fake.DotNet.Testing.MSTest.fsproj index 9c0324854a6..9d0598e9532 100644 --- a/src/app/Fake.DotNet.Testing.MSTest/Fake.DotNet.Testing.MSTest.fsproj +++ b/src/app/Fake.DotNet.Testing.MSTest/Fake.DotNet.Testing.MSTest.fsproj @@ -21,12 +21,8 @@ - - true - - - true - + + \ No newline at end of file diff --git a/src/app/Fake.DotNet.Testing.MSpec/Fake.DotNet.Testing.MSpec.fsproj b/src/app/Fake.DotNet.Testing.MSpec/Fake.DotNet.Testing.MSpec.fsproj index a1c2ded0120..00d5be55d5f 100644 --- a/src/app/Fake.DotNet.Testing.MSpec/Fake.DotNet.Testing.MSpec.fsproj +++ b/src/app/Fake.DotNet.Testing.MSpec/Fake.DotNet.Testing.MSpec.fsproj @@ -21,12 +21,8 @@ - - true - - - true - + + \ No newline at end of file diff --git a/src/app/Fake.DotNet.Testing.NUnit/Fake.DotNet.Testing.NUnit.fsproj b/src/app/Fake.DotNet.Testing.NUnit/Fake.DotNet.Testing.NUnit.fsproj index 9230e63902a..32c08d40ca6 100644 --- a/src/app/Fake.DotNet.Testing.NUnit/Fake.DotNet.Testing.NUnit.fsproj +++ b/src/app/Fake.DotNet.Testing.NUnit/Fake.DotNet.Testing.NUnit.fsproj @@ -25,12 +25,8 @@ - - true - - - true - + + \ No newline at end of file diff --git a/src/app/Fake.DotNet.Testing.XUnit2/Fake.DotNet.Testing.XUnit2.fsproj b/src/app/Fake.DotNet.Testing.XUnit2/Fake.DotNet.Testing.XUnit2.fsproj index 44c636f4fd3..afa399a134b 100644 --- a/src/app/Fake.DotNet.Testing.XUnit2/Fake.DotNet.Testing.XUnit2.fsproj +++ b/src/app/Fake.DotNet.Testing.XUnit2/Fake.DotNet.Testing.XUnit2.fsproj @@ -21,12 +21,8 @@ - - true - - - true - + + \ No newline at end of file diff --git a/src/app/Fake.Testing.Common/Fake.Testing.Common.fsproj b/src/app/Fake.Testing.Common/Fake.Testing.Common.fsproj index 91b352e6bc2..f150f83b1c3 100644 --- a/src/app/Fake.Testing.Common/Fake.Testing.Common.fsproj +++ b/src/app/Fake.Testing.Common/Fake.Testing.Common.fsproj @@ -1,6 +1,6 @@ - 1.0.0-alpha-10 + 1.0.0 net46;netstandard1.6;netstandard2.0 $(DefineConstants);NO_DOTNETCORE_BOOTSTRAP Fake.Testing.Common @@ -22,9 +22,7 @@ - - true - + - \ No newline at end of file + diff --git a/src/app/Fake.Tools.Git/Fake.Tools.Git.fsproj b/src/app/Fake.Tools.Git/Fake.Tools.Git.fsproj index d9c8ff95446..44af7714cce 100644 --- a/src/app/Fake.Tools.Git/Fake.Tools.Git.fsproj +++ b/src/app/Fake.Tools.Git/Fake.Tools.Git.fsproj @@ -36,9 +36,7 @@ - - true - + \ No newline at end of file diff --git a/src/app/Fake.Windows.Chocolatey/Fake.Windows.Chocolatey.fsproj b/src/app/Fake.Windows.Chocolatey/Fake.Windows.Chocolatey.fsproj index 075dec1a5af..0b82e17a402 100644 --- a/src/app/Fake.Windows.Chocolatey/Fake.Windows.Chocolatey.fsproj +++ b/src/app/Fake.Windows.Chocolatey/Fake.Windows.Chocolatey.fsproj @@ -22,9 +22,7 @@ - - true - + \ No newline at end of file diff --git a/src/app/Fake.netcore/Fake.netcore.fsproj b/src/app/Fake.netcore/Fake.netcore.fsproj index 0cb01558fc6..742a3056102 100644 --- a/src/app/Fake.netcore/Fake.netcore.fsproj +++ b/src/app/Fake.netcore/Fake.netcore.fsproj @@ -21,15 +21,9 @@ - - true - - - true - - - true - + + + diff --git a/src/app/dotnet-fake/dotnet-fake.fsproj b/src/app/dotnet-fake/dotnet-fake.fsproj index dc0e6c8c44b..480a6ef5efb 100644 --- a/src/app/dotnet-fake/dotnet-fake.fsproj +++ b/src/app/dotnet-fake/dotnet-fake.fsproj @@ -20,12 +20,8 @@ - - true - - - true - + + diff --git a/src/app/fake-cli/fake-cli.fsproj b/src/app/fake-cli/fake-cli.fsproj index 8835669edc2..e60cfa262bc 100644 --- a/src/app/fake-cli/fake-cli.fsproj +++ b/src/app/fake-cli/fake-cli.fsproj @@ -17,12 +17,8 @@ - - true - - - true - + + From 99e7402b6cbaf53e467ebf94fd3c3454ee9b6805 Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Tue, 5 Jun 2018 15:26:38 +0100 Subject: [PATCH 26/26] Fixing INT tests --- .vscode/tasks.json | 39 ++++++++++++++++++- src/app/Fake.Core.Process/Process.fs | 2 +- .../Fake.Core.UnitTests/Fake.Core.Process.fs | 4 +- .../Fake.DotNet.MSBuild.fs | 2 +- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5925c9a8835..619ac290d19 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -21,7 +21,10 @@ "presentation": { "reveal": "always" }, - "problemMatcher": "$msCompile" + "problemMatcher": "$msCompile", + "dependsOn": [ + "dotnet:restore:fake.sln" + ] }, { "label": "dotnet:run:unitTests", @@ -32,6 +35,40 @@ "reveal": "always" }, "problemMatcher": "$msCompile" + }, + { + "label": "dotnet:run:commandLineUnitTests", + "group": "test", + "command": "dotnet run -p src/test/Fake.Core.CommandLine.UnitTests/Fake.Core.CommandLine.UnitTests.fsproj", + "type": "shell", + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "dotnet:run:integrationTests", + "group": "test", + "command": "dotnet run -p src/test/Fake.Core.IntegrationTests/Fake.Core.IntegrationTests.fsproj", + "type": "shell", + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "dotnet:run:allTests", + "group": "test", + "dependsOn": [ + "dotnet:run:integrationTests", + "dotnet:run:commandLineUnitTests", + "dotnet:run:unitTests" + ], + "type": "shell", + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" } ] } diff --git a/src/app/Fake.Core.Process/Process.fs b/src/app/Fake.Core.Process/Process.fs index e00baf53076..90d8bae424d 100644 --- a/src/app/Fake.Core.Process/Process.fs +++ b/src/app/Fake.Core.Process/Process.fs @@ -260,7 +260,7 @@ module Process = //let startedProcesses = HashSet() let private startedProcessesVar = "Fake.Core.Process.startedProcesses" let private getStartedProcesses, _, private setStartedProcesses = - Fake.Core.FakeVar.define startedProcessesVar + Fake.Core.FakeVar.defineAllowNoContext startedProcessesVar let private doWithProcessList f = if Fake.Core.Context.isFakeContext () then diff --git a/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs b/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs index 92b65648377..5e5b0d73fca 100644 --- a/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs +++ b/src/test/Fake.Core.UnitTests/Fake.Core.Process.fs @@ -8,7 +8,7 @@ open Expecto [] let tests = testList "Fake.Core.Process.Tests" [ - Fake.ContextHelper.fakeContextTestCase "Test that we have a nice error message when a file doesn't exist" <| fun _ -> + testCase "Test that we have a nice error message when a file doesn't exist" <| fun _ -> try Process.start(fun proc -> { proc with @@ -20,7 +20,7 @@ let tests = let s = e.Message.Contains "FileDoesntExist.exe" Expect.isTrue s ("Expected file-path as part of the message '" + e.Message + "'") - Fake.ContextHelper.fakeContextTestCase "Test that we can read messages correctly" <| fun _ -> + testCase "Test that we can read messages correctly" <| fun _ -> let shell, command = if Environment.isWindows then "cmd", "/C \"echo 1&& echo 2\"" diff --git a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs index 69d92656374..6ef6f0df168 100644 --- a/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs +++ b/src/test/Fake.Core.UnitTests/Fake.DotNet.MSBuild.fs @@ -7,7 +7,7 @@ open Expecto [] let tests = testList "Fake.DotNet.MSBuild.Tests" [ - Fake.ContextHelper.fakeContextTestCase "Test that we can create simple msbuild cmdline" <| fun _ -> + testCase "Test that we can create simple msbuild cmdline" <| fun _ -> let cmdLine = { MSBuildParams.Create() with Properties = ["OutputPath", "C:\\Test\\"] }