-
Notifications
You must be signed in to change notification settings - Fork 2
/
coverage.ps1
54 lines (46 loc) · 2.06 KB
/
coverage.ps1
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
44
45
46
47
48
49
50
51
52
53
54
# Run locally to see html report: powershell ./coverage.ps1 -generateReport
# To publish results to Codecov, set var: CODECOV_TOKEN, powershell ./coverage.ps1 -uploadCodecov
# appveyor has variable CODECOV_TOKEN set
Param (
[switch] $generateReport,
[switch] $uploadCodecov
)
$currentPath = Split-Path $MyInvocation.MyCommand.Path
$coverageOutputDirectory = Join-Path $currentPath "coverage"
$coverageFile = "coverage-results.xml"
Remove-Item $coverageOutputDirectory -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $coverageFile -ErrorAction SilentlyContinue
nuget install -Verbosity quiet -OutputDirectory packages -Version 4.6.519 OpenCover
$openCoverConsole = "packages\OpenCover.4.6.519\tools\OpenCover.Console.exe"
# OpenCover currently not supporting portable pdbs (https://github.com/OpenCover/opencover/issues/601)
$configuration = "Coverage"
Get-ChildItem -Filter .\test\ |
ForEach-Object {
$csprojPath = $_.FullName
$testProjectName = $_.Name
$projectName = $testProjectName -replace ".{6}$"
cmd.exe /c $openCoverConsole `
-target:"c:\Program Files\dotnet\dotnet.exe" `
-targetargs:"test -c $configuration $csprojPath\$testProjectName.csproj" `
-mergeoutput `
-hideskipped:File `
-output:$coverageFile `
-oldStyle `
-filter:"+[$projectName]* -[$testProjectName]* -[Greentube.Messaging]*Attribute -[xunit*]*" `
-searchdirs:"$csprojPath\bin\$configuration\netcoreapp2.0\" `
-register:user
}
If ($generateReport) {
nuget install -Verbosity quiet -OutputDirectory packages -Version 3.0.2 ReportGenerator
$reportGenerator = "packages\ReportGenerator.3.0.2\tools\ReportGenerator.exe"
cmd.exe /c $reportGenerator `
-reports:$coverageFile `
-targetdir:$coverageOutputDirectory `
-verbosity:Error
}
# requires variable set: CODECOV_TOKEN
If ($uploadCodeCov) {
nuget install -Verbosity quiet -OutputDirectory packages -Version 1.0.3 Codecov
$Codecov = "packages\Codecov.1.0.3\tools\Codecov.exe"
cmd.exe /c $Codecov -f $coverageFile
}