Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. properties {
  2.     $baseDir = Resolve-Path .\..
  3.     $buildDir = "$baseDir\BuildDir"
  4.     $releaseDir = "$baseDir\BuildDrops"
  5.     $toolsDir = "$baseDir\Tools"
  6.     $gallioExe = "$toolsDir\Gallio\Gallio.Echo.exe"
  7.     $partCoverExe = "$toolsDir\PartCover\PartCover.exe"
  8.     $coverageReportGeneratorExe = "$toolsDir\CoverageReportGenerator\ReportGenerator.exe"
  9.     $solutionFile = "$baseDir\Sources\IAUsersClub.Downloader.sln"
  10.     $testAssembly = "$buildDir\IAUsersClub.Downloader.Test.dll"
  11.     #$env:Path += ";$gallioDir;$partCoverDir"
  12. }
  13.  
  14. FormatTaskName ("[ {0} ]" + "-" * 50)
  15.  
  16. task default -depends Test
  17.  
  18. task Clean {
  19.     Write-Host "Cleaning Solution. Please wait..." -ForegroundColor Green
  20.     if (Test-Path -Path $buildDir) { del $buildDir -Force -Recurse }
  21. }
  22.  
  23. task Compile -depends Clean {
  24.     Write-Host "Compiling Solution. Please wait..." -ForegroundColor Green
  25.     if (!(Test-Path -Path $buildDir)) { md $buildDir }
  26.     $buildDirWithSlash = "$buildDir\"
  27.     Exec { msbuild $solutionFile `
  28.         /t:Build `
  29.         /m `
  30.         /p:BuildInParallel=true `
  31.         /v:quiet `
  32.         /p:OutDir=$buildDirWithSlash }
  33. }
  34.  
  35. task Test -depends Compile {
  36.     Write-Host "Running Unit Tests could take some time, please be patient..." -ForegroundColor Green
  37.  
  38.     $reportDir = "$buildDir\Reports"
  39.     $codeCoverageHtmlDir = "$reportDir\CodeCoverageHtml"
  40.     $partCoverXmlReport = "$reportDir\PartCoverReport.xml"
  41.    
  42.     if (!(Test-Path -Path $codeCoverageHtmlDir)) { md $codeCoverageHtmlDir }
  43.  
  44.     # PartCover uses Gallio.Echo as a target and because of this only in process test runner is applicable.
  45.     # Gallio.Echo ignores /runtime-version parameter when in process test runner is used.
  46.     # Because of the limitations described above, Gallio.Echo.exe.config must be configured
  47.     # to use the same .NET Framework runtime version as for target project.
  48.     $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"
  49.  
  50.     # Pass to PartCover following exclusion rules:
  51.     # [*]*Delegate - delegates have all inherited methods, and we don’t need to really test those.
  52.     # [*]Microsoft.Xml.Serialization.GeneratedAssembly - XmlSerializer generates dyamic assembly on runtime.
  53.     # Exclude assembly with unit tests which are usually ends with Test or Tests words.
  54.     # Exclude all third-party assembly.
  55.     &$partCoverExe --register `
  56.         --target $gallioExe `
  57.         --target-args $gallioArgs `
  58.         --target-work-dir $buildDir `
  59.         --output $partCoverXmlReport `
  60.         --errors-to-stdout `
  61.         --include [*]* `
  62.         --exclude [*]Microsoft.Xml.Serialization.GeneratedAssembly* `
  63.         --exclude [*]*Delegate `
  64.         --exclude [*Test]* `
  65.         --exclude [*Tests]* `
  66.         --exclude [log4net*]* `
  67.         --exclude [nunit*]* `
  68.         --exclude [NVelocity*]* `
  69.         --exclude [Moq*]* `
  70.         --exclude [Rhino.Mocks*]* `
  71.         --exclude [Gallio*]*
  72.  
  73.     if ($lastExitCode -ne 0 -and !(Test-Path -Path $partCoverXmlReport)) {
  74.         throw "ERROR: Test runner have not prepared Test Coverage Xml report and was completed with error code."
  75.     }
  76.  
  77.     if ($lastExitCode -ne 0 -and (Test-Path -Path $partCoverXmlReport)) {
  78.         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
  79.     }
  80.    
  81.     Write-Host "Generating Html report with Test Code Coverage..." -ForegroundColor Green
  82.  
  83.     Exec { &$coverageReportGeneratorExe $partCoverXmlReport $codeCoverageHtmlDir }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement