Skip to content

Commit c8cace2

Browse files
new code coverage (#5169)
* test new code coverage * change coverage path * fix failure * try test code coverage * fix build * try new file filters * fix coverage report path * fix coverage report path * try remove GC.Collect * remove unnecessary new line
1 parent 413cf82 commit c8cace2

File tree

6 files changed

+42
-24
lines changed

6 files changed

+42
-24
lines changed

build.proj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
$(TraversalBuildDependsOn);
3939
DownloadExternalTestFiles;
4040
DownloadTensorflowMetaFiles;
41+
DeleteTestHost;
4142
</TraversalBuildDependsOn>
4243
</PropertyGroup>
4344

@@ -116,6 +117,18 @@
116117
</DownloadFile>
117118
</Target>
118119

120+
<!-- Delete testhost.dll and testhost.exe from output folder,
121+
start test from dotnet.exe to keep consistent behavior with older version of Microsoft.NET.Test.Sdk -->
122+
<Target Name="DeleteTestHost">
123+
<Message Importance="High" Text="Delete testhost.dll and testhost.exe from output folder..." />
124+
<ItemGroup>
125+
<FilesToClean Include="$(MSBuildThisFileDirectory)\bin\**\testhost.dll" />
126+
<FilesToClean Include="$(MSBuildThisFileDirectory)\bin\**\testhost.exe" />
127+
</ItemGroup>
128+
<Delete Files="@(FilesToClean)"/>
129+
<RemoveDir Directories="@(FoldersToClean)" />
130+
</Target>
131+
119132
<Target Name="RunTests">
120133
<MSBuild Projects="test\run-tests.proj"
121134
Targets="RunTests" />

build/Codecoverage.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<_ReportGeneratorPath>$(PkgReportGenerator)\tools\net47\ReportGenerator.exe</_ReportGeneratorPath>
1717
</PropertyGroup>
1818

19-
<Message Importance="high" Text="&quot;$(_ReportGeneratorPath)&quot; -reports:$(BaseOutputPath)$(PlatformConfig)\coverage\*.coverage -targetdir:$(BaseOutputPath)$(PlatformConfig)\coverage -filefilters:+https*;+*.fs -reporttypes:Cobertura" />
20-
<Exec Command="&quot;$(_ReportGeneratorPath)&quot; -reports:$(BaseOutputPath)$(PlatformConfig)\coverage\*.coverage -targetdir:$(BaseOutputPath)$(PlatformConfig)\coverage -filefilters:+https*;+*.fs -reporttypes:Cobertura" />
19+
<Message Importance="high" Text="&quot;$(_ReportGeneratorPath)&quot; -reports:$(BaseOutputPath)$(PlatformConfig)\*\*\coverage.opencover.xml -targetdir:$(BaseOutputPath)$(PlatformConfig)\coverage -filefilters:+*.cs;+*.fs -reporttypes:Cobertura" />
20+
<Exec Command="&quot;$(_ReportGeneratorPath)&quot; -reports:$(BaseOutputPath)$(PlatformConfig)\*\*\coverage.opencover.xml -targetdir:$(BaseOutputPath)$(PlatformConfig)\coverage -filefilters:+*.cs;+*.fs -reporttypes:Cobertura" />
2121

2222
<ItemGroup>
2323
<_CodecovArgs Include="-f;$(BaseOutputPath)$(PlatformConfig)\coverage\Cobertura.xml" />

build/Dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<PropertyGroup>
4444
<PublishSymbolsPackageVersion>1.0.0-beta-62824-02</PublishSymbolsPackageVersion>
4545
<CodecovVersion>1.9.0</CodecovVersion>
46-
<CoverletVersion>2.7.0</CoverletVersion>
46+
<CoverletCollectorVersion>1.2.1</CoverletCollectorVersion>
4747
<ReportGeneratorVersion>4.3.6</ReportGeneratorVersion>
4848
<MicrosoftDotNetApiCompatPackageVersion>1.0.0-beta.19225.5</MicrosoftDotNetApiCompatPackageVersion>
4949
</PropertyGroup>

test/Directory.Build.props

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
30+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
3131
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
3232
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
3333
<PackageReference Include="xunit" Version="2.4.0" />
3434
<PackageReference Include="Xunit.Combinatorial" Version="$(XunitCombinatorialVersion)" />
3535
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
3636
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" Version="2.4.0-prerelease-63213-02" />
37-
<PackageReference Include="coverlet.msbuild" Version="$(CoverletVersion)" />
37+
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)" />
3838
</ItemGroup>
3939

4040
<ItemGroup>
@@ -54,22 +54,4 @@
5454
</ProjectReference>
5555
</ItemGroup>
5656

57-
<PropertyGroup Condition="'$(Coverage)' == 'true'">
58-
<!-- https://github.com/tonerdo/coverlet/issues/618 -->
59-
<IncludeTestAssembly>true</IncludeTestAssembly>
60-
61-
<CollectCoverage>true</CollectCoverage>
62-
<SingleHit>true</SingleHit>
63-
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- https://github.com/tonerdo/coverlet/issues/72 -->
64-
<CoverletOutputFormat>opencover</CoverletOutputFormat>
65-
<CoverletOutput>$(BaseOutputPath)$(PlatformConfig)\coverage\$(MSBuildProjectName).coverage</CoverletOutput>
66-
<Include>[Microsoft.ML.*]*</Include>
67-
<!-- Excluding for perf reasons. These classes have tests that can be run conditionally
68-
but they need to be migrated. Excluding these classes should have very minimal effect on code coverage.
69-
-->
70-
<Exclude>[*]Microsoft.ML.*Contracts*,[*]Microsoft.ML.Internal.Utilities*,[*]Microsoft.ML.Data.VBuffer*</Exclude>
71-
<ExcludeByAttribute>Obsolete,ExcludeFromCodeCoverage</ExcludeByAttribute>
72-
<ExcludeByFile>$(RepoRoot)src\Microsoft.ML.OnnxConverter\OnnxMl.cs,$(RepoRoot)src\Microsoft.ML.TensorFlow\TensorFlow\Buffer.cs,$(RepoRoot)src\Microsoft.ML.TensorFlow\TensorFlow\Tensor.cs,$(RepoRoot)src\Microsoft.ML.TensorFlow\TensorFlow\Tensorflow.cs</ExcludeByFile>
73-
</PropertyGroup>
74-
7557
</Project>

test/coverlet.runsettings

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<RunSettings>
3+
<DataCollectionRunSettings>
4+
<DataCollectors>
5+
<DataCollector friendlyName="XPlat code coverage">
6+
<Configuration>
7+
<Format>opencover</Format>
8+
<Exclude>[*]Microsoft.ML.*Contracts*,[*]Microsoft.ML.Internal.Utilities*,[*]Microsoft.ML.Data.VBuffer*</Exclude> <!-- [Assembly-Filter]Type-Filter -->
9+
<Include>[Microsoft.ML.*]*</Include> <!-- [Assembly-Filter]Type-Filter -->
10+
<ExcludeByAttribute>Obsolete,ExcludeFromCodeCoverage</ExcludeByAttribute>
11+
<ExcludeByFile>$(RepoRoot)src\Microsoft.ML.OnnxConverter\OnnxMl.cs,$(RepoRoot)src\Microsoft.ML.TensorFlow\TensorFlow\Buffer.cs,$(RepoRoot)src\Microsoft.ML.TensorFlow\TensorFlow\Tensor.cs,$(RepoRoot)src\Microsoft.ML.TensorFlow\TensorFlow\Tensorflow.cs</ExcludeByFile> <!-- Globbing filter -->
12+
<SingleHit>true</SingleHit>
13+
<IncludeTestAssembly>true</IncludeTestAssembly>
14+
</Configuration>
15+
</DataCollector>
16+
</DataCollectors>
17+
</DataCollectionRunSettings>
18+
</RunSettings>

test/run-tests.proj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
<Target Name="RunTests">
1010
<Message Importance="High" Text="Running tests ..." />
11-
<MSBuild Targets="VSTest"
11+
<MSBuild Condition="'$(Coverage)' == 'true'"
12+
Targets="VSTest"
13+
Projects="@(Project)"
14+
Properties="VSTestNoBuild=true;VSTestBlame=true;VSTestCollect=XPlat Code Coverage;VSTestSetting=$(MSBuildThisFileDirectory)\coverlet.runsettings" />
15+
<MSBuild Condition="'$(Coverage)' == 'false'"
16+
Targets="VSTest"
1217
Projects="@(Project)"
1318
Properties="VSTestNoBuild=true;VSTestBlame=true" />
1419
</Target>

0 commit comments

Comments
 (0)