diff --git a/FAKE.sln b/FAKE.sln index cec77a348e5..3eec2b2a0ba 100644 --- a/FAKE.sln +++ b/FAKE.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F0488CC-2580-4C07-9E16-3997480F0221}" ProjectSection(SolutionItems) = preProject @@ -120,6 +120,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assemblyinfo", "assemblyinf EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testscripts", "testscripts", "{16D0306A-E2D0-444B-87F8-22605A1EC57C}" ProjectSection(SolutionItems) = preProject + src\test\testscripts\fake-powershell-redirected.fsx = src\test\testscripts\fake-powershell-redirected.fsx + src\test\testscripts\fake-powershell-redirected.ps1 = src\test\testscripts\fake-powershell-redirected.ps1 + src\test\testscripts\run-fake-powershell-redirected.bat = src\test\testscripts\run-fake-powershell-redirected.bat src\test\testscripts\test1.fsx = src\test\testscripts\test1.fsx EndProjectSection EndProject diff --git a/build.fsx b/build.fsx index 415375a5a2a..75fe750031e 100644 --- a/build.fsx +++ b/build.fsx @@ -167,6 +167,38 @@ Target "Test" (fun _ -> |> xUnit id ) +Target "RunTestScripts" (fun _ -> + + // copy all test scripts into the test directory and run them there so they don't mess up the source tree + + let testScriptDir = testDir @@ "testScripts" + + !! ("src/test/testscripts/*.*") + |> CopyFiles testScriptDir + + let absFakeExe = "build/FAKE.exe" |> Path.absolute + let absBuildDir = "build" |> Path.absolute + + !! (testScriptDir @@ "run-*.bat") + |> Seq.iter (fun ts -> + let currentDir = System.Environment.CurrentDirectory + try + System.Environment.CurrentDirectory <- testScriptDir + let result = + ExecProcess (fun info -> + info.FileName <- ts + info.WorkingDirectory <- "." + info.EnvironmentVariables.["FAKE"] <- absFakeExe + info.EnvironmentVariables.["FAKE_DIR"] <- absBuildDir + ) (System.TimeSpan.FromMinutes 3.0) + + if result <> 0 then + failwithf "TestScript %s failed with %i" (Path.GetFileName ts) result + finally + System.Environment.CurrentDirectory <- currentDir + ) +) + Target "Bootstrap" (fun _ -> let buildScript = "build.fsx" let testScript = "testbuild.fsx" @@ -364,6 +396,7 @@ Target "Default" DoNothing ==> "BuildSolution" //==> "ILRepack" ==> "Test" + ==> "RunTestScripts" ==> "Bootstrap" ==> "Default" ==> "CopyLicense" diff --git a/src/test/testscripts/fake-powershell-redirected.fsx b/src/test/testscripts/fake-powershell-redirected.fsx new file mode 100644 index 00000000000..80059b5ff36 --- /dev/null +++ b/src/test/testscripts/fake-powershell-redirected.fsx @@ -0,0 +1,7 @@ +#r @"FakeLib.dll" + +open Fake + +Target "Default" DoNothing + +RunTargetOrDefault "Default" diff --git a/src/test/testscripts/fake-powershell-redirected.ps1 b/src/test/testscripts/fake-powershell-redirected.ps1 new file mode 100644 index 00000000000..d8d31bb02df --- /dev/null +++ b/src/test/testscripts/fake-powershell-redirected.ps1 @@ -0,0 +1,11 @@ +$fake_exe = $env:FAKE +$fake_dir = $env:FAKE_DIR +if ([string]::IsNullOrWhiteSpace($fake_exe)) { + $fake_dir = "..\..\..\build" + $fake_exe = "$fake_dir\fake.exe" +} + +# when this is set, powershell throws an exception when any process writes to STDERR +$ErrorActionPreference = "Stop" +# this issue only appears if the FAKE output is redirected to a file +&"$fake_exe" "fake-powershell-redirected.fsx" 2>&1 > out-run-fake-powershell-redirected.log diff --git a/src/test/testscripts/run-fake-powershell-redirected.bat b/src/test/testscripts/run-fake-powershell-redirected.bat new file mode 100644 index 00000000000..6c3855808d7 --- /dev/null +++ b/src/test/testscripts/run-fake-powershell-redirected.bat @@ -0,0 +1 @@ +powershell -ExecutionPolicy Bypass %cd%\fake-powershell-redirected.ps1