Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- properties {
- $baseDir = Resolve-Path .\..
- $buildDir = "$baseDir\BuildDir"
- $releaseDir = "$baseDir\BuildDrops"
- $toolsDir = "$baseDir\Tools"
- $gallioExe = "$toolsDir\Gallio\Gallio.Echo.exe"
- $partCoverExe = "$toolsDir\PartCover\PartCover.exe"
- $coverageReportGeneratorExe = "$toolsDir\CoverageReportGenerator\ReportGenerator.exe"
- $solutionFile = "$baseDir\Sources\IAUsersClub.Downloader.sln"
- $testAssembly = "$buildDir\IAUsersClub.Downloader.Test.dll"
- #$env:Path += ";$gallioDir;$partCoverDir"
- }
- FormatTaskName ("[ {0} ]" + "-" * 50)
- task default -depends Test
- task Clean {
- Write-Host "Cleaning Solution. Please wait..." -ForegroundColor Green
- if (Test-Path -Path $buildDir) { del $buildDir -Force -Recurse }
- }
- task Compile -depends Clean {
- Write-Host "Compiling Solution. Please wait..." -ForegroundColor Green
- if (!(Test-Path -Path $buildDir)) { md $buildDir }
- $buildDirWithSlash = "$buildDir\"
- Exec { msbuild $solutionFile `
- /t:Build `
- /m `
- /p:BuildInParallel=true `
- /v:quiet `
- /p:OutDir=$buildDirWithSlash }
- }
- task Test -depends Compile {
- Write-Host "Running Unit Tests could take some time, please be patient..." -ForegroundColor Green
- $reportDir = "$buildDir\Reports"
- $codeCoverageHtmlDir = "$reportDir\CodeCoverageHtml"
- $partCoverXmlReport = "$reportDir\PartCoverReport.xml"
- if (!(Test-Path -Path $codeCoverageHtmlDir)) { md $codeCoverageHtmlDir }
- # PartCover uses Gallio.Echo as a target and because of this only in process test runner is applicable.
- # Gallio.Echo ignores /runtime-version parameter when in process test runner is used.
- # Because of the limitations described above, Gallio.Echo.exe.config must be configured
- # to use the same .NET Framework runtime version as for target project.
- $gallioArgs = "$testAssembly /runner:Local /report-directory:$reportDir /report-type:Xml-Inline /report-type:XHtml /report-formatter-property:AttachmentContentDisposition=Inline /report-name-format:TestReport /verbosity:Verbose"
- # Pass to PartCover following exclusion rules:
- # [*]*Delegate - delegates have all inherited methods, and we donβt need to really test those.
- # [*]Microsoft.Xml.Serialization.GeneratedAssembly - XmlSerializer generates dyamic assembly on runtime.
- # Exclude assembly with unit tests which are usually ends with Test or Tests words.
- # Exclude all third-party assembly.
- &$partCoverExe --register `
- --target $gallioExe `
- --target-args $gallioArgs `
- --target-work-dir $buildDir `
- --output $partCoverXmlReport `
- --errors-to-stdout `
- --include [*]* `
- --exclude [*]Microsoft.Xml.Serialization.GeneratedAssembly* `
- --exclude [*]*Delegate `
- --exclude [*Test]* `
- --exclude [*Tests]* `
- --exclude [log4net*]* `
- --exclude [nunit*]* `
- --exclude [NVelocity*]* `
- --exclude [Moq*]* `
- --exclude [Rhino.Mocks*]* `
- --exclude [Gallio*]*
- if ($lastExitCode -ne 0 -and !(Test-Path -Path $partCoverXmlReport)) {
- throw "ERROR: Test runner have not prepared Test Coverage Xml report and was completed with error code."
- }
- if ($lastExitCode -ne 0 -and (Test-Path -Path $partCoverXmlReport)) {
- Write-Host "WARNING: Test runner creates Test Coverage Xml report but was completed with error code. The build process will continue..." -ForegroundColor Yellow -BackgroundColor Black
- }
- Write-Host "Generating Html report with Test Code Coverage..." -ForegroundColor Green
- Exec { &$coverageReportGeneratorExe $partCoverXmlReport $codeCoverageHtmlDir }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement