8000 Analyze code coverage by nulltoken · Pull Request #1106 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Analyze code coverage #1106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion LibGit2Sharp.Tests/MetaFixture.cs
10000
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
using Moq;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -107,6 +108,28 @@ public void TypesInLibGit2SharpMustBeExtensibleInATestingContext()
{
nonTestableTypes.Add(type, new List<string>());
}

if (type.IsAbstract)
{
continue;
}

try
{
if (type.ContainsGenericParameters)
{
var constructType = type.MakeGenericType(Enumerable.Repeat(typeof(object), type.GetGenericArguments().Length).ToArray());
Activator.CreateInstance(constructType, true);
}
else
{
Activator.CreateInstance(type, true);
}
}
catch (Exception ex)
{
nonTestableTypes.Add(type, new List<string>());
}
}

if (nonTestableTypes.Any())
Expand Down Expand Up @@ -246,7 +269,7 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
var nonVirtualGetEnumeratorMethods = Assembly.GetAssembly(typeof(IRepository))
.GetExportedTypes()
.Where(t =>
t.Namespace == typeof (IRepository).Namespace &&
t.Namespace == typeof(IRepository).Namespace &&
!t.IsSealed &&
!t.IsAbstract &&
t.GetInterfaces().Any(i => i.IsAssignableFrom(typeof(IEnumerable<>))))
Expand Down
45 changes: 44 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ skip_tags: true
clone_folder: C:\projects\libgit2sharp

environment:
coveralls_token:
secure: ixIsBslo9NheDb5lJknF58EYdgvZ0r3/L0ecRiXjfXmjHBLvoSU6/ZRwaMM+BAlG
coverity_token:
secure: nuzUT+HecXGIi3KaPd/1hgFEZJan/j6+oNbPV75JKjk=
coverity_email:
Expand Down Expand Up @@ -60,6 +62,11 @@ install:
Write-Host "Should package Nuget artifact = " -NoNewLine
Write-Host $Env:SHOULD_PACKAGE_NUGET_ARTIFACT -ForegroundColor "Green"

$Env:SHOULD_RUN_COVERALLS = $($Env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null `
-and $Env:APPVEYOR_SCHEDULED_BUILD -eq $False)
Write-Host "Should run Coveralls = " -NoNewLine
Write-Host $Env:SHOULD_RUN_COVERALLS -ForegroundColor "Green"

Write-Host "Should publish on success = " -NoNewLine
Write-Host $Env:publish_on_success -ForegroundColor "Green"

Expand All @@ -68,6 +75,12 @@ install:
cinst sourcelink -y
}

If ($Env:SHOULD_RUN_COVERALLS -eq $True)
{
nuget install OpenCover -Version 4.5.3723 -ExcludeVersion -OutputDirectory .\packages
nuget install coveralls.net -Version 0.5.0 -ExcludeVersion -OutputDirectory .\packages
}

If ($Env:SHOULD_RUN_COVERITY_ANALYSIS -eq $True)
{
cinst curl -y
Expand Down Expand Up @@ -98,7 +111,20 @@ test_script:
- ps: |
If ($Env:SHOULD_RUN_COVERITY_ANALYSIS -eq $False)
{
& "$Env:xunit_runner" "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.Tests\bin\Release\LibGit2Sharp.Tests.dll" /appveyor
If ($Env:SHOULD_RUN_COVERALLS -eq $True -and $Env:publish_on_success -eq $True)
{
.\packages\OpenCover\OpenCover.Console.exe `
-register:user `
-target:$Env:xunit_runner `
"-targetargs:""$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.Tests\bin\Release\LibGit2Sharp.Tests.dll"" /noshadow /appveyor" `
"-filter:+[LibGit2Sharp]* -[LibGit2Sharp.Tests]*" `
-hideskipped:All `
-output:opencoverCoverage.xml
}
Else
{
& "$Env:xunit_runner" "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.Tests\bin\Release\LibGit2Sharp.Tests.dll" /appveyor
}
}

after_test:
Expand All @@ -122,6 +148,23 @@ after_test:
Get-ChildItem "$Env:APPVEYOR_BUILD_FOLDER\LibGit2sharp\*.nupkg" | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
}

If ($Env:SHOULD_RUN_COVERALLS -eq $True -and $Env:publish_on_success -eq $True)
{
Write-Host "Uploading code coverage result..." -ForegroundColor "Green"

.\packages\coveralls.net\csmacnz.Coveralls.exe `
--opencover -i opencoverCoverage.xml `
--repoToken $Env:coveralls_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 `
--useRelativePaths `
--basePath "$Env:APPVEYOR_BUILD_FOLDER\"`
--jobId $Env:APPVEYOR_JOB_ID
}

If ($Env:SHOULD_RUN_COVERITY_ANALYSIS -eq $True -and $Env:publish_on_success -eq $True)
{
7z a "$Env:APPVEYOR_BUILD_FOLDER\$Env:APPVEYOR_PROJECT_NAME.zip" "$Env:APPVEYOR_BUILD_FOLDER\cov-int\"
Expand Down
0