Skip to content

Commit

Permalink
Refactored build to publish tests before executing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tillig committed Aug 5, 2015
1 parent c41aa4e commit c9af8b2
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ function Restore-Packages
& dnu restore ("""" + $DirectoryName + """")
}

function Build-Projects
function Build-Project
{
param([string] $DirectoryName)
& dnu pack ("""" + $DirectoryName + """") --configuration Release --out .\artifacts\packages; if($LASTEXITCODE -ne 0) { exit 1 }
}

function Test-Projects
function Publish-TestProject
{
param([string] $DirectoryName)
& dnx ("""" + $DirectoryName + """") test; if($LASTEXITCODE -ne 0) { exit 2 }
param([string] $DirectoryName, [int]$Index)

# Publish to a numbered/indexed folder rather than the full test project name
# because the package paths get long and start exceeding OS limitations.
& dnu publish ("""" + $DirectoryName + """") --configuration Release --no-source --out .\artifacts\tests\$Index; if($LASTEXITCODE -ne 0) { exit 2 }
}

function Invoke-Tests
{
Get-ChildItem .\artifacts\tests -Filter test.cmd -Recurse | ForEach-Object { & $_.FullName; if($LASTEXITCODE -ne 0) { exit 3 } }
}

function Remove-PathVariable
Expand Down Expand Up @@ -86,15 +94,18 @@ $env:DNX_BUILD_VERSION = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1}[$env
Write-Host "Build number:" $env:DNX_BUILD_VERSION

# Build/package
Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_.DirectoryName }
Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Build-Project $_.DirectoryName }

# Publish tests so we can test without recompiling
Get-ChildItem -Path .\test -Filter *.xproj -Exclude Autofac.Test.Scenarios.ScannedAssembly.xproj -Recurse | ForEach-Object -Begin { $TestIndex = 0 } -Process { Publish-TestProject -DirectoryName $_.DirectoryName -Index $TestIndex; $TestIndex++; }

# Test
Get-ChildItem -Path .\test -Filter *.xproj -Exclude Autofac.Test.Scenarios.ScannedAssembly.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
# Test under CLR
Invoke-Tests

# Switch to Core CLR
dnvm use $dnxVersion -r CoreCLR

# Test again
Get-ChildItem -Path .\test -Filter *.xproj -Exclude Autofac.Test.Scenarios.ScannedAssembly.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
# Test under Core CLR
Invoke-Tests

Pop-Location

0 comments on commit c9af8b2

Please sign in to comment.