Skip to content

Commit d7bef17

Browse files
committed
Update AppVeyor build to use opencover-report.ps1
1 parent a41ff45 commit d7bef17

2 files changed

Lines changed: 38 additions & 17 deletions

File tree

appveyor.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ build:
88
project: StyleCopAnalyzers.sln
99
verbosity: minimal
1010
test_script:
11-
- .\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"C:\projects\stylecopanalyzers\StyleCop.Analyzers\StyleCop.Analyzers.Test\bin\Debug\net452\StyleCop.Analyzers.Test.dll -noshadow -appveyor" -returntargetcode -filter:"+[StyleCop*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -excludebyfile:*\*Designer.cs -hideskipped:All -output:.\StyleCopAnalyzers_coverage.xml
12-
- .\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"C:\projects\stylecopanalyzers\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp7\bin\Debug\net46\StyleCop.Analyzers.Test.CSharp7.dll -noshadow -appveyor" -returntargetcode -filter:"+[StyleCop*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -excludebyfile:*\*Designer.cs -hideskipped:All -mergebyhash -mergeoutput -output:.\StyleCopAnalyzers_coverage.xml
13-
- .\packages\Codecov.1.0.1\tools\codecov.exe -f "StyleCopAnalyzers_coverage.xml"
11+
- cd build
12+
- ps: .\opencover-report.ps1 -Debug -NoBuild -NoReport -AppVeyor
13+
- cd ..
14+
- .\packages\Codecov.1.0.1\tools\codecov.exe -f ".\build\OpenCover.Reports\OpenCover.StyleCopAnalyzers.xml"
1415
cache:
1516
- packages -> **\packages.config
1617
- C:\Users\appveyor\.nuget\packages -> appveyor.yml

build/opencover-report.ps1

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
param (
2-
[switch]$Debug
2+
[switch]$Debug,
3+
[switch]$NoBuild,
4+
[switch]$NoReport,
5+
[switch]$AppVeyor
36
)
47

5-
# Run a build to ensure everything is up-to-date
6-
If ($Debug) {
7-
.\build.ps1 -Debug -Incremental
8-
} Else {
9-
.\build.ps1 -Incremental
10-
}
8+
If (-not $NoBuild) {
9+
# Run a build to ensure everything is up-to-date
10+
If ($Debug) {
11+
.\build.ps1 -Debug -Incremental
12+
} Else {
13+
.\build.ps1 -Incremental
14+
}
1115

12-
If (-not $?) {
13-
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
14-
Exit $LASTEXITCODE
16+
If (-not $?) {
17+
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
18+
Exit $LASTEXITCODE
19+
}
1520
}
1621

1722
If ($Debug) {
@@ -39,6 +44,10 @@ If (Test-Path $report_folder) {
3944

4045
mkdir $report_folder | Out-Null
4146

47+
If ($AppVeyor) {
48+
$AppVeyorArg = '-appveyor'
49+
}
50+
4251
&$opencover_console `
4352
-register:user `
4453
-returntargetcode `
@@ -48,7 +57,12 @@ mkdir $report_folder | Out-Null
4857
-excludebyfile:*\*Designer.cs `
4958
-output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" `
5059
-target:"$xunit_runner_console" `
51-
-targetargs:"$target_dll -noshadow"
60+
-targetargs:"$target_dll -noshadow $AppVeyorArg"
61+
62+
If ($AppVeyor -and -not $?) {
63+
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
64+
Exit $LASTEXITCODE
65+
}
5266

5367
&$opencover_console `
5468
-register:user `
@@ -60,8 +74,14 @@ mkdir $report_folder | Out-Null
6074
-output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" `
6175
-mergebyhash -mergeoutput `
6276
-target:"$xunit_runner_console" `
63-
-targetargs:"$target_dll_csharp7 -noshadow"
77+
-targetargs:"$target_dll_csharp7 -noshadow $AppVeyorArg"
6478

65-
&$report_generator -targetdir:$report_folder -reports:$report_folder\OpenCover.*.xml
79+
If ($AppVeyor -and -not $?) {
80+
$host.UI.WriteErrorLine('Build failed; coverage analysis aborted.')
81+
Exit $LASTEXITCODE
82+
}
6683

67-
$host.UI.WriteLine("Open $report_folder\index.htm to see code coverage results.")
84+
If (-not $NoReport) {
85+
&$report_generator -targetdir:$report_folder -reports:$report_folder\OpenCover.*.xml
86+
$host.UI.WriteLine("Open $report_folder\index.htm to see code coverage results.")
87+
}

0 commit comments

Comments
 (0)