forked from ful-stackz/SharpCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeCoverage.ps1
More file actions
43 lines (35 loc) · 1.23 KB
/
CodeCoverage.ps1
File metadata and controls
43 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
param (
[string] $ReportTypes = "Cobertura"
)
$codeCoverage = "$env:USERPROFILE\.nuget\packages\microsoft.codecoverage\16.7.1\build\netstandard1.0\CodeCoverage\CodeCoverage.exe"
$reportGenerator = "dotnet $env:USERPROFILE\.nuget\packages\reportgenerator\4.6.7\tools\netcoreapp3.0\ReportGenerator.dll"
$testResultsDir = "..\src\SharpCode.Test\TestResults"
$outputDir = "..\coverage"
function AsSingleLine {
param ([string] $text)
# Remove line breaks, normalize excess spacing and trim
(($text -replace "\r?\n", "") -replace "\s+", " ").Trim()
}
function RunCmd {
param ([string] $command)
AsSingleLine $command | Invoke-Expression
}
$coverageFiles = Get-ChildItem $testResultsDir -Filter "*.coverage" -Recurse | Select-Object FullName
if ($coverageFiles.Length -eq 0) {
Write-Host "Could not find coverage report generated by dotnet test" -ForegroundColor DarkRed
Get-ChildItem $testResultsDir | Write-Host
exit 1
}
$coverageFile = $coverageFiles[0].FullName
RunCmd @"
$codeCoverage analyze
/output:$outputDir/coverage.xml
$coverageFile
"@
RunCmd @"
$reportGenerator
"-reports:$outputDir/coverage.xml"
"-reporttypes:$ReportTypes"
"-targetdir:$outputDir"
"-classfilters:+SharpCode.*;-SharpCode.Test*"
"@