Skip to content

Commit

Permalink
Runs unit tests as part of the build process
Browse files Browse the repository at this point in the history
Former-commit-id: 85f90127775d071efb52c37e708406e73e7da7cf
  • Loading branch information
tbroust-trepia committed Sep 19, 2014
1 parent ab73833 commit 4173515
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
51 changes: 42 additions & 9 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ Properties {
$cairpluginversion = "1.0.0.0"

# build paths to various files
$PROJ_PATH = (Resolve-Path ".")
$BIN_PATH = (Join-Path $PROJ_PATH "_BuildOutput")
$NUGET_EXE = (Resolve-Path "..\src\.nuget\NuGet.exe")
$NUSPECS_PATH = (Join-Path $PROJ_PATH "NuSpecs")
$NUGET_OUTPUT = (Join-Path $BIN_PATH "NuGets")
# TODO: add opencover and nunit runner binaries
$PROJ_PATH = Resolve-Path "."
$SRC_PATH = Resolve-Path "..\src"
$BIN_PATH = Join-Path $PROJ_PATH "_BuildOutput"
$NUGET_EXE = Join-Path $SRC_PATH ".nuget\NuGet.exe"
$NUSPECS_PATH = Join-Path $PROJ_PATH "NuSpecs"
$NUGET_OUTPUT = Join-Path $BIN_PATH "NuGets"

# nunit runner binaries
$NUNIT_EXE = Join-Path $SRC_PATH "packages\NUnit.Runners.2.6.3\tools\nunit-console.exe"
}

Framework "4.0x86"
FormatTaskName "-------- {0} --------"

task default -depends Cleanup-Binaries, Build-Solution, Generate-Package
task default -depends Cleanup-Binaries, Build-Solution, Run-Tests, Generate-Package

# cleans up the binaries output folder
task Cleanup-Binaries {
Expand All @@ -30,14 +33,44 @@ task Cleanup-Binaries {
# builds the solutions
task Build-Solution -depends Cleanup-Binaries {
Write-Host "Building projects"
$projects = @("Build.ImageProcessor.proj", "Build.ImageProcessor.Web.proj", "Build.ImageProcessor.Plugins.WebP.proj", "Build.ImageProcessor.Plugins.Cair.proj")
$projects = @(
"Build.ImageProcessor.proj",
"Build.ImageProcessor.Web.proj",
"Build.ImageProcessor.Plugins.WebP.proj",
"Build.ImageProcessor.Plugins.Cair.proj"
)

$projects | % {
Write-Host "Building project $_"
Exec {
msbuild (Join-Path $PROJ_PATH $_) /p:BUILD_RELEASE="$version"
}
}
}

# runs the unit tests
task Run-Tests {
Write-Host "Building the unit test projects"

$projects = @(
"ImageProcessor.UnitTests",
"ImageProcessor.Web.UnitTests"
)

$projects | % {
Write-Host "Building project $_"
Exec {
msbuild (Join-Path $SRC_PATH "$_\$_.csproj") /t:Build /p:Configuration=Release /p:Platform="AnyCPU" /p:Warnings=true /v:Normal /nologo /clp:WarningsOnly`;ErrorsOnly`;Summary`;PerformanceSummary
}
}

Write-Host "Running unit tests"
$projects | % {
Write-Host "Running tests on project $_"
& $NUNIT_EXE (Join-Path $SRC_PATH "$_\bin\Release\$_.dll")
}
}

# generates a Nuget package
task Generate-Package -depends Build-Solution {
Write-Host "Generating Nuget packages for each project"
Expand All @@ -58,7 +91,7 @@ task Generate-Package -depends Build-Solution {

$nuspecs.GetEnumerator() | % {
$nuspec_local_path = (Join-Path $NUSPECS_PATH $_.Key)
Write-Host "Building package from $nuspec_local_path"
Write-Host "Building Nuget package from $nuspec_local_path"

# change the version values
[xml]$nuspec_contents = Get-Content $nuspec_local_path
Expand Down
5 changes: 5 additions & 0 deletions src/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit.Runners" version="2.6.3" />
<package id="OpenCover" version="4.5.3207" />
</packages>
6 changes: 0 additions & 6 deletions src/packages/repositories.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\ImageProcessor.UnitTests\packages.config" />
<repository path="..\ImageProcessor.UnitTests2\packages.config" />
<repository path="..\ImageProcessor.Web.UnitTests\packages.config" />
<repository path="..\ImageProcessor.Web\NET4\packages.config" />
<repository path="..\TestWebsites\MVC\packages.config" />
<repository path="..\TestWebsites\NET4\packages.config" />
<repository path="..\TestWebsites\NET45\Test_Website_NET45\packages.config" />
<repository path="..\TestWebsites\NET45\Test_Website_Webforms_NET45\packages.config" />
<repository path="..\TestWebsites\WebForms\packages.config" />
</repositories>

0 comments on commit 4173515

Please sign in to comment.