added coverage measurement

This commit is contained in:
Christian Köllner 2020-02-25 21:46:15 +01:00
parent 18fa473196
commit 420ba4f8ef
16 changed files with 83 additions and 0 deletions

3
.gitignore vendored
View File

@ -336,3 +336,6 @@ ASALocalRun/
# Capnp code behind # Capnp code behind
*.capnp.cs *.capnp.cs
/globalPackages /globalPackages
# Coverage results folder
coverage/

View File

@ -3,6 +3,7 @@
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class DeserializationTests public class DeserializationTests
{ {
[TestMethod] [TestMethod]

View File

@ -7,6 +7,7 @@ using System.IO;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class DynamicSerializerStateTests public class DynamicSerializerStateTests
{ {
[TestMethod] [TestMethod]

View File

@ -10,6 +10,7 @@ using System.Threading.Tasks;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class FramePumpTests public class FramePumpTests
{ {
class MyStruct : SerializerState class MyStruct : SerializerState

View File

@ -14,6 +14,7 @@ using System.Threading.Tasks.Dataflow;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class Interception: TestBase public class Interception: TestBase
{ {
class MyPolicy : IInterceptionPolicy class MyPolicy : IInterceptionPolicy

View File

@ -3,6 +3,7 @@
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class MessageBuilderTests public class MessageBuilderTests
{ {
class Struct2D0P : SerializerState class Struct2D0P : SerializerState

View File

@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class RpcSchemaTests public class RpcSchemaTests
{ {
[TestMethod] [TestMethod]

View File

@ -3,6 +3,7 @@
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class SegmentAllocatorTests public class SegmentAllocatorTests
{ {
[TestMethod] [TestMethod]

View File

@ -12,6 +12,7 @@ namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class TcpRpc public class TcpRpc
{ {
public static int TcpPort = 49153; public static int TcpPort = 49153;

View File

@ -10,6 +10,7 @@ using System.Threading.Tasks;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class TcpRpcAdvancedStuff : TestBase public class TcpRpcAdvancedStuff : TestBase
{ {
[TestMethod, Timeout(10000)] [TestMethod, Timeout(10000)]

View File

@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class TcpRpcPorted: TestBase public class TcpRpcPorted: TestBase
{ {
[TestMethod] [TestMethod]

View File

@ -4,6 +4,7 @@ using System;
namespace Capnp.Net.Runtime.Tests namespace Capnp.Net.Runtime.Tests
{ {
[TestClass] [TestClass]
[TestCategory("Coverage")]
public class WirePointerTests public class WirePointerTests
{ {
[TestMethod] [TestMethod]

View File

@ -11,9 +11,15 @@ install:
- vcpkg install capnproto - vcpkg install capnproto
- cd %APPVEYOR_BUILD_FOLDER% - cd %APPVEYOR_BUILD_FOLDER%
- dotnet tool install -g nbgv - dotnet tool install -g nbgv
- choco install opencover --version=4.7.922 --force -y
- choco install reportgenerator.portable --version=2.5.0.0 --force -y
- dotnet tool install -g coveralls.net --version 1.0.0
init: init:
# Good practise, because Windows line endings are different from Unix/Linux ones # Good practise, because Windows line endings are different from Unix/Linux ones
- cmd: git config --global core.autocrlf true - cmd: git config --global core.autocrlf true
environment:
COVERALLS_REPO_TOKEN:
secure: mwxwOymoS7vB56iQN5Obbt8+oMqbRpK8Ei2GZUI7Mm46C8asDR/Wu0RAXYlhp85Q
before_build: before_build:
- cmd: nbgv cloud - cmd: nbgv cloud
- cmd: dotnet --version - cmd: dotnet --version
@ -51,6 +57,9 @@ artifacts:
- path: capnpc-csharp\nupkg\*.nupkg - path: capnpc-csharp\nupkg\*.nupkg
name: capnpc-csharp name: capnpc-csharp
type: NuGetPackage type: NuGetPackage
- path: coverage\report\*
name: Coverage report
type: zip
test_script: test_script:
- cmd: | - cmd: |
nbgv get-version -v NuGetPackageVersion >> version.txt nbgv get-version -v NuGetPackageVersion >> version.txt
@ -80,6 +89,10 @@ test_script:
vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests\bin\Release\net471\Capnp.Net.Runtime.Tests.Std20.dll vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests\bin\Release\net471\Capnp.Net.Runtime.Tests.Std20.dll
vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests.Core21\bin\Debug\netcoreapp2.1\Capnp.Net.Runtime.Tests.Core21.dll vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests.Core21\bin\Debug\netcoreapp2.1\Capnp.Net.Runtime.Tests.Core21.dll
vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests.Core21\bin\Release\netcoreapp2.1\Capnp.Net.Runtime.Tests.Core21.dll vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests.Core21\bin\Release\netcoreapp2.1\Capnp.Net.Runtime.Tests.Core21.dll
- ps: |
.\scipts\measure-coverage.ps1
$coveralls = ".\tools\csmacnz.coveralls.exe"
& $coveralls --reportgenerator -i coverage/report --repoToken $env:COVERALLS_REPO_TOKEN --commitId $env:APPVEYOR_REPO_COMMIT --commitBranch $env:APPVEYOR_REPO_BRANCH --commitAuthor $env:APPVEYOR_REPO_COMMIT_AUTHOR --commitEmail $env:APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL --commitMessage $env:APPVEYOR_REPO_COMMIT_MESSAGE --jobId $env:APPVEYOR_JOB_ID
on_finish : on_finish :
# any cleanup in here # any cleanup in here
deploy: deploy:

View File

@ -0,0 +1,4 @@
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
choco install opencover --version=4.7.922
choco install reportgenerator.portable --version=2.5.0.0

View File

@ -0,0 +1,48 @@
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$rootDir = "$scriptDir\.."
$coverageDir = "$rootDir\coverage"
$coverageReportDir = "$rootDir\coverage\report"
$openCover = "$env:LOCALAPPDATA\Apps\OpenCover\OpenCover.Console.exe"
$vsTestConsole = where.exe vstest.console
$runtimeTestsDnc21 = "$rootDir\Capnp.Net.Runtime.Tests.Core21\bin\Release\netcoreapp2.1\Capnp.Net.Runtime.Tests.Core21.dll"
$coverageOutputRuntimeDnc21 = "$coverageDir\cov-Capnp.Net.Runtime-dnc21.xml"
$runtimeTestsNet471 = "$rootDir\Capnp.Net.Runtime.Tests\bin\Release\net471\Capnp.Net.Runtime.Tests.Std20.dll"
$coverageOutputRuntimeNet471 = "$coverageDir\cov-Capnp.Net.Runtime-net471.xml"
$generatorTests = "$rootDir\CapnpC.CSharp.Generator.Tests\bin\Release\netcoreapp3.0\CapnpC.CSharp.Generator.Tests.dll"
$coverageOutputGenerator = "$coverageDir\cov-CapnpC.CSharp.Generator.xml"
If(!(test-path $coverageDir))
{
New-Item -ItemType Directory -Force -Path $coverageDir
}
If(!(test-path $coverageReportDir))
{
New-Item -ItemType Directory -Force -Path $coverageReportDir
}
& $openCover -target:"$vsTestConsole" `
-targetArgs:"/inIsolation $runtimeTestsDnc21 /TestCaseFilter:`"TestCategory=Coverage`"" `
-filter:"+[Capnp.Net.Runtime]Capnp.*" `
-excludebyattribute:"System.CodeDom.Compiler.GeneratedCodeAttribute" `
-output:"$coverageOutputRuntimeDnc21" `
-mergebyhash -register:user -oldStyle
& $openCover -target:"$vsTestConsole" `
-targetArgs:"/inIsolation $runtimeTestsNet471 /TestCaseFilter:`"TestCategory=Coverage`"" `
-filter:"+[Capnp.Net.Runtime]Capnp.*" `
-excludebyattribute:"System.CodeDom.Compiler.GeneratedCodeAttribute" `
-output:"$coverageOutputRuntimeNet471" `
-mergebyhash -register:user -oldStyle
& $openCover -target:"$vsTestConsole" `
-targetArgs:"/inIsolation $generatorTests" `
-filter:"+[CapnpC.CSharp.Generator]*" `
-excludebyattribute:"System.CodeDom.Compiler.GeneratedCodeAttribute" `
-output:"$coverageOutputGenerator" `
-mergebyhash -register:user -oldStyle
ReportGenerator.exe -reports:"$coverageOutputRuntimeDnc21;$coverageOutputRuntimeNet471;$coverageOutputGenerator" -targetdir:"$coverageReportDir" -reportTypes:"Html;Xml"

View File

@ -0,0 +1,4 @@
rem This batch file assumes to be run from a Visual Studio developer command prompt
rem This is necessary because we need to locate vstest.console.exe
powershell -File measure-coverage.ps1