diff options
author | nulltoken <emeric.fermas@gmail.com> | 2015-06-22 20:35:44 +0300 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2015-06-22 20:35:44 +0300 |
commit | c25c6e4310fc706eb4cb53285b52844377c90f61 (patch) | |
tree | 943f822c5b9aa36f5f2cf19e53b8bfd85eacb198 | |
parent | 9d3fe4d3b91f63249d78c0779841c3f59665f41d (diff) | |
parent | 9ab380596487686ff2b89e35e5f6520cece3c008 (diff) |
Merge pull request #1106 from libgit2/ntk/coverage
Analyze code coverage
-rw-r--r-- | LibGit2Sharp.Tests/MetaFixture.cs | 25 | ||||
-rw-r--r-- | appveyor.yml | 45 |
2 files changed, 68 insertions, 2 deletions
diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs index 86ecdf3c..3d0a4898 100644 --- a/LibGit2Sharp.Tests/MetaFixture.cs +++ b/LibGit2Sharp.Tests/MetaFixture.cs @@ -9,6 +9,7 @@ using System.Text; using LibGit2Sharp.Tests.TestHelpers; using Xunit; using Xunit.Extensions; +using Moq; namespace LibGit2Sharp.Tests { @@ -107,6 +108,28 @@ namespace LibGit2Sharp.Tests { 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()) @@ -246,7 +269,7 @@ namespace LibGit2Sharp.Tests 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<>)))) diff --git a/appveyor.yml b/appveyor.yml index c2ae0150..063c758d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: @@ -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" @@ -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 @@ -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: @@ -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\" |