Skip to content

Commit

Permalink
coverlet.msbuild.tasks unit tests (#1534)
Browse files Browse the repository at this point in the history
* add CoverletCoverageCollector.cs

* add .runsettings

* update build pipeline

* remove Console.WriteLine

* enable coverage report

* remove .runsettings

* use MSBuildLogger

* remove BaseTask class name

* add message "Generating report ..."

* update changelog.md

* remove condition variable EnableCoverage

* update assert statements

* fix build pipeline

* remove IConsole from serviceCollection

* use _logger instead of Log
  • Loading branch information
Bertk authored Oct 19, 2023
1 parent 89f2f3e commit cceb71d
Show file tree
Hide file tree
Showing 23 changed files with 106,123 additions and 624 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>preview</AnalysisLevel>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<LangVersion>preview</LangVersion>
<NoWarn>$(NoWarn);NU5105;CS1591</NoWarn>
Expand All @@ -31,7 +31,7 @@
</ItemGroup>

<PropertyGroup>
<VSTestResultsDirectory>$(RepoRoot)/artifacts/tests</VSTestResultsDirectory>
<VSTestResultsDirectory>$(RepoRoot)artifacts/tests</VSTestResultsDirectory>
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
</PropertyGroup>

Expand Down
10 changes: 6 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
</PropertyGroup>

<ItemGroup>
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
</ItemGroup>

<ItemGroup>
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.5.0"/>
<PackageVersion Include="Microsoft.Build.Framework" Version="17.5.0"/>
<PackageVersion Include="Microsoft.Build.Locator" Version="1.5.5" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
Expand Down Expand Up @@ -54,9 +56,9 @@
-->
<PackageVersion Include="Tmds.ExecFunction" Version="0.6.0" />
<PackageVersion Include="xunit" Version="2.5.0" />
<PackageVersion Include="xunit.assemblyfixture" Version="2.2.0" />
<PackageVersion Include="xunit.assert" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0"/>


<PackageVersion Include="envdte" Version="17.7.37355" />
</ItemGroup>
</Project>
248 changes: 125 additions & 123 deletions Documentation/Changelog.md

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions coverlet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.tests.projectsampl
{6ACF69B1-C01F-44A4-8F8E-2501884238D4} = {6ACF69B1-C01F-44A4-8F8E-2501884238D4}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.msbuild.tasks.tests", "test\coverlet.msbuild.tasks.tests\coverlet.msbuild.tasks.tests.csproj", "{3ABC2066-D1C5-4CAA-8867-9C5DC777CBF8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.msbuild.tasks.tests", "test\coverlet.msbuild.tasks.tests\coverlet.msbuild.tasks.tests.csproj", "{351A034E-E642-4DB9-A21D-F71C8151C243}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -164,10 +164,10 @@ Global
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F508CCDD-5BC8-4AB6-97B3-D37498813C41}.Release|Any CPU.Build.0 = Release|Any CPU
{3ABC2066-D1C5-4CAA-8867-9C5DC777CBF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3ABC2066-D1C5-4CAA-8867-9C5DC777CBF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3ABC2066-D1C5-4CAA-8867-9C5DC777CBF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3ABC2066-D1C5-4CAA-8867-9C5DC777CBF8}.Release|Any CPU.Build.0 = Release|Any CPU
{351A034E-E642-4DB9-A21D-F71C8151C243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{351A034E-E642-4DB9-A21D-F71C8151C243}.Debug|Any CPU.Build.0 = Debug|Any CPU
{351A034E-E642-4DB9-A21D-F71C8151C243}.Release|Any CPU.ActiveCfg = Release|Any CPU
{351A034E-E642-4DB9-A21D-F71C8151C243}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -195,6 +195,7 @@ Global
{988A5FF0-4326-4F5B-9F05-CB165543A555} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
{6ACF69B1-C01F-44A4-8F8E-2501884238D4} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
{F508CCDD-5BC8-4AB6-97B3-D37498813C41} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
{351A034E-E642-4DB9-A21D-F71C8151C243} = {2FEBDE1B-83E3-445B-B9F8-5644B0E0E134}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9CA57C02-97B0-4C38-A027-EA61E8741F10}
Expand Down
8 changes: 4 additions & 4 deletions eng/azure-pipelines-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ pool:
steps:
- task: UseDotNet@2
inputs:
version: 6.0.413
displayName: Install .NET Core SDK 6.0.413
version: 6.0.415
displayName: Install .NET Core SDK 6.0.415

- task: UseDotNet@2
inputs:
version: 7.0.400
displayName: Install .NET Core SDK 7.0.400
version: 7.0.402
displayName: Install .NET Core SDK 7.0.402

- task: NuGetAuthenticate@0
displayName: Authenticate with NuGet feeds
Expand Down
3 changes: 3 additions & 0 deletions eng/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ trigger:
paths:
exclude: [".github", "Documentation", "*.md"]

variables:
system.debug: false

jobs:
- job: Windows
displayName: Windows
Expand Down
10 changes: 5 additions & 5 deletions eng/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
steps:
- task: UseDotNet@2
inputs:
version: 6.0.413
displayName: Install .NET Core SDK 6.0.413
version: 6.0.415
displayName: Install .NET Core SDK 6.0.415

- task: UseDotNet@2
inputs:
version: 7.0.400
displayName: Install .NET Core SDK 7.0.400
version: 7.0.402
displayName: Install .NET Core SDK 7.0.402

- script: dotnet restore
displayName: Restore packages
Expand All @@ -19,7 +19,7 @@ steps:
displayName: Pack

- task: DotNetCoreCLI@2
displayName: Run tests
displayName: Run tests with coverage
inputs:
command: test
arguments: -c $(BuildConfiguration) --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[coverlet.collector]*%2c[coverlet.core]*%2c[coverlet.msbuild.tasks]*" /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*"
Expand Down
1 change: 1 addition & 0 deletions eng/publish-coverlet-result-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ steps:

- task: CopyFiles@2
displayName: Copy trx files
condition: always()
inputs:
SourceFolder: '$(Agent.TempDirectory)'
Contents: '**/*.trx'
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "7.0.400"
"version": "7.0.402"
}
}
2 changes: 1 addition & 1 deletion src/coverlet.core/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Coverlet.Core.Exceptions
{
[Serializable]
internal class CoverletException : Exception
public class CoverletException : Exception
{
public CoverletException() { }
public CoverletException(string message) : base(message) { }
Expand Down
2 changes: 1 addition & 1 deletion src/coverlet.msbuild.tasks/BaseTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Coverlet.MSbuild.Tasks
{
public abstract class BaseTask : Task
{
protected static IServiceProvider ServiceProvider { get; set; }
public static IServiceProvider ServiceProvider { get; protected internal set; }
}
}
Loading

0 comments on commit cceb71d

Please sign in to comment.