Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<Import Condition="'$(EnableBenchviewTarget)' == 'true' AND '$(Performance)' == 'true' AND '$(SkipTests)' != 'true'" Project="$([MSBuild]::NormalizePath('$(TestCoreDir)', 'performance', 'Benchview.targets'))" />

<!-- Full coverage report. -->
<Import Condition="'$(EnableFullCoverageReportTarget)' == 'true' AND '$(Coverage)' == 'true' AND '$(SkipTests)' != 'true'" Project="$([MSBuild]::NormalizePath('$(TestCoreDir)', 'coverage', 'CoverageReport.targets'))" />
<Import Condition="'$(EnableFullCoverageReportTarget)' == 'true' AND '$(SkipCoverageReport)' != 'true' AND '$(Coverage)' == 'true' AND '$(SkipTests)' != 'true'" Project="$([MSBuild]::NormalizePath('$(TestCoreDir)', 'coverage', 'CoverageReport.targets'))" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From looking at these set of conditions it seems that there are a lot of conditions that can cause this to not be imported. Just to understand, SkipCoverageReport == true, but SkipTests==false, will cause to run code coverage and not to create a report? I just want to clarify what is the purpose of this property. Because we can also disable that with Coverage == false.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore SkipTests which will be removed with #1704


<!-- Import the core testing infrastructure only for test projects. -->
<Import Condition="'$(IsTestProject)' == 'true' AND '$(IsTestSupportProject)' != 'true'" Project="$(TestCoreDir)Core.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
<GenerateRunScriptDependsOn>$(GenerateRunScriptDependsOn);SetupCoverageFilter</GenerateRunScriptDependsOn>
</PropertyGroup>

<!-- Interlocked is used to record code hits in Coverlet. Measuring it itself would cause an infinite loop. -->
<ItemGroup>
<CoverageExclude Include="[System.Private.CoreLib]System.Threading.Interlocked" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@
<CoverageExecutablePath Condition="'$(CoverageExecutablePath)' == ''">$(GlobalToolsDir)coverlet</CoverageExecutablePath>
<RunArguments>"$(TestAssembly)" --target "$(RunCommand)" --targetargs "$(RunArguments)" --format "$(CoverageFormat)" --output "$(CoverageOutputPath)" --threshold "$(CoverageThreshold)" --threshold-type "$(CoverageThresholdType)"</RunArguments>
<RunArguments Condition="'$(CoverageSourceLink)' == 'true'">$(RunArguments) --use-source-link</RunArguments>
<RunArguments Condition="'$(CoverageExclude)' != ''">$(RunArguments) --exclude "$(CoverageExclude)"</RunArguments>
<RunCommand>$(CoverageExecutablePath)</RunCommand>
</PropertyGroup>

<Target Name="SetupCoverageFilter">

<PropertyGroup>
<CoverageExcludeByFile>--exclude-by-file @(CoverageExcludeFile -> '"%(Identity)"', ' --exclude-by-file ')</CoverageExcludeByFile>
<RunArguments>$(RunArguments) $(CoverageExcludeByFile)</RunArguments>
<PropertyGroup Condition="'@(CoverageExcludeFile -> Count())' &gt; 0">
<CoverageExcludeByFileFilter>--exclude-by-file @(CoverageExcludeFile -> '"%(Identity)"', ' --exclude-by-file ')</CoverageExcludeByFileFilter>
<RunArguments>$(RunArguments) $(CoverageExcludeByFileFilter)</RunArguments>
</PropertyGroup>

<PropertyGroup>
<PropertyGroup Condition="'@(CoverageProbePath -> Count())' &gt; 0">
<IncludeDirectoriesFilter>--include-directory @(CoverageProbePath -> '"$(RunScriptHostDir)%(Identity)"', ' --include-directory ')</IncludeDirectoriesFilter>
<RunArguments>$(RunArguments) $(IncludeDirectoriesFilter)</RunArguments>
</PropertyGroup>

<PropertyGroup Condition="'@(CoverageExclude -> Count())' &gt; 0">
<CoverageExcludeFilter>--exclude @(CoverageExclude -> '"%(Identity)"', ' --exclude ')</CoverageExcludeFilter>
<RunArguments>$(RunArguments) $(CoverageExcludeFilter)</RunArguments>
</PropertyGroup>

<!--
We need to filter the data to only the assembly being tested. Otherwise we will gather tons of data about other assemblies.
If the code being tested is part of the runtime itself, it requires special treatment.
Expand Down Expand Up @@ -50,6 +54,6 @@

</Target>

<Import Project="$(MSBuildThisFileDirectory)CoverageReport.targets" />
<Import Condition="'$(SkipCoverageReport)' != 'true'" Project="$(MSBuildThisFileDirectory)CoverageReport.targets" />

</Project>