Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't merge] demonstrate #1187 #1207

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions FAKE.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -364,6 +396,7 @@ Target "Default" DoNothing
==> "BuildSolution"
//==> "ILRepack"
==> "Test"
==> "RunTestScripts"
==> "Bootstrap"
==> "Default"
==> "CopyLicense"
Expand Down
7 changes: 7 additions & 0 deletions src/test/testscripts/fake-powershell-redirected.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#r @"FakeLib.dll"

open Fake

Target "Default" DoNothing

RunTargetOrDefault "Default"
11 changes: 11 additions & 0 deletions src/test/testscripts/fake-powershell-redirected.ps1
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/test/testscripts/run-fake-powershell-redirected.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
powershell -ExecutionPolicy Bypass %cd%\fake-powershell-redirected.ps1