Browse Source

Runs unit tests as part of the build process

Former-commit-id: 85f90127775d071efb52c37e708406e73e7da7cf
pull/17/head
Thomas Broust 12 years ago
parent
commit
2e6beaa75d
  1. 51
      build/build.ps1
  2. 5
      src/.nuget/packages.config
  3. 6
      src/packages/repositories.config

51
build/build.ps1

@ -6,18 +6,21 @@ Properties {
$cairpluginversion = "1.0.0.0" $cairpluginversion = "1.0.0.0"
# build paths to various files # build paths to various files
$PROJ_PATH = (Resolve-Path ".") $PROJ_PATH = Resolve-Path "."
$BIN_PATH = (Join-Path $PROJ_PATH "_BuildOutput") $SRC_PATH = Resolve-Path "..\src"
$NUGET_EXE = (Resolve-Path "..\src\.nuget\NuGet.exe") $BIN_PATH = Join-Path $PROJ_PATH "_BuildOutput"
$NUSPECS_PATH = (Join-Path $PROJ_PATH "NuSpecs") $NUGET_EXE = Join-Path $SRC_PATH ".nuget\NuGet.exe"
$NUGET_OUTPUT = (Join-Path $BIN_PATH "NuGets") $NUSPECS_PATH = Join-Path $PROJ_PATH "NuSpecs"
# TODO: add opencover and nunit runner binaries $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" Framework "4.0x86"
FormatTaskName "-------- {0} --------" 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 # cleans up the binaries output folder
task Cleanup-Binaries { task Cleanup-Binaries {
@ -30,14 +33,44 @@ task Cleanup-Binaries {
# builds the solutions # builds the solutions
task Build-Solution -depends Cleanup-Binaries { task Build-Solution -depends Cleanup-Binaries {
Write-Host "Building projects" 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 | % { $projects | % {
Write-Host "Building project $_"
Exec { Exec {
msbuild (Join-Path $PROJ_PATH $_) /p:BUILD_RELEASE="$version" 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 # generates a Nuget package
task Generate-Package -depends Build-Solution { task Generate-Package -depends Build-Solution {
Write-Host "Generating Nuget packages for each project" Write-Host "Generating Nuget packages for each project"
@ -58,7 +91,7 @@ task Generate-Package -depends Build-Solution {
$nuspecs.GetEnumerator() | % { $nuspecs.GetEnumerator() | % {
$nuspec_local_path = (Join-Path $NUSPECS_PATH $_.Key) $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 # change the version values
[xml]$nuspec_contents = Get-Content $nuspec_local_path [xml]$nuspec_contents = Get-Content $nuspec_local_path

5
src/.nuget/packages.config

@ -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
src/packages/repositories.config

@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<repositories> <repositories>
<repository path="..\ImageProcessor.UnitTests\packages.config" /> <repository path="..\ImageProcessor.UnitTests\packages.config" />
<repository path="..\ImageProcessor.UnitTests2\packages.config" />
<repository path="..\ImageProcessor.Web.UnitTests\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\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> </repositories>
Loading…
Cancel
Save