Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix performance runs and enable full coverage runs
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer committed Dec 3, 2018
1 parent 33440b2 commit 1ffab72
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
7 changes: 6 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
<ApiCompatExcludeAttributeList>$(RepositoryEngineeringDir)DefaultGenApiDocIds.txt</ApiCompatExcludeAttributeList>
<!-- Build as portable by default -->
<PortableBuild Condition="'$(PortableBuild)' == ''">true</PortableBuild>
<Performance Condition="'$(Performance)' == ''">false</Performance>
<!-- Used for launchSettings.json and runtime config files. -->
<AppDesignerFolder>Properties</AppDesignerFolder>
</PropertyGroup>
Expand Down Expand Up @@ -450,6 +449,12 @@
<EnableVSTestReferences Condition="'$(EnableVSTestReferences)' == ''">true</EnableVSTestReferences>
</PropertyGroup>

<!-- Test properties for full build. -->
<PropertyGroup Condition="'$(BuildAllProjects)' == 'true'">
<GenerateFullCoverageReport Condition="'$(GenerateFullCoverageReport)' == ''">true</GenerateFullCoverageReport>
<Performance Condition="'$(Performance)' == ''">false</Performance>
</PropertyGroup>

<!-- TODO: Fix VB test project reference to Test SDK. -->
<Import Condition="'$(IsTestProject)' == 'true' AND '$(IsTestSupportProject)' != 'true' AND '$(EnableVSTestReferences)' == 'true' AND '$(Language)' != 'VB'" Project="$(RuntimePath)Microsoft.Net.Test.Sdk.props" />

Expand Down
20 changes: 6 additions & 14 deletions Documentation/project-docs/performance-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Performance test files (if present) are stored within a library's ```tests/Perfo
**Step # 2:** Change directory to the performance tests directory: ```cd path/to/library/tests/Performance```

**Step # 3:** Build and run the tests:
- Windows ```dotnet msbuild /t:BuildAndTest /p:Performance=true /p:ConfigurationGroup=Release```
- Linux: ```dotnet msbuild /t:BuildAndTest /p:Performance=true /p:ConfigurationGroup=Release```
- Windows ```dotnet msbuild /t:BuildAndTest /p:ConfigurationGroup=Release```
- Linux: ```dotnet msbuild /t:BuildAndTest /p:ConfigurationGroup=Release```

**Note: Because test build runs tests concurrently, do not use it for executing performance tests. If you still want to run them concurrently you need to pass the flag `/p:Performance=true` to it: `build -test -release /p:Performance=true`.**

Expand All @@ -32,20 +32,12 @@ Performance tests should reside within their own "Performance" folder within the
It's easiest to copy and modify an existing example like the one above. Notice that you'll need these lines in the tests csproj:
```
<ItemGroup>
<!-- Performance Tests -->
<Compile Include="Performance\Perf.Dictionary.cs" />
<Compile Include="Performance\Perf.List.cs" />
<Compile Include="$(CommonTestPath)\System\PerfUtils.cs">
<Link>Common\System\PerfUtils.cs</Link>
</Compile>
<ProjectReference Include="$(CommonTestPath)\Performance\PerfRunner\PerfRunner.csproj">
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
<Name>PerfRunner</Name>
</ProjectReference>
</ItemGroup>
<!-- Optimizations to configure Xunit for performance -->
<PropertyGroup>
<IncludePerformanceTests>true</IncludePerformanceTests>
</PropertyGroup>
```
(Replace Dictionary/List with whatever class you’re testing.)

Once that’s all done, you can actually add tests to the file.

Writing Test Cases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TestCategories>InnerLoop;OuterLoop</TestCategories>
<IncludePerformanceTests>true</IncludePerformanceTests>
<ProjectGuid>{1BD5C9BF-D7F2-4249-AA31-43B1850A5DB3}</ProjectGuid>
<Configurations>netcoreapp-Debug;netcoreapp-Release</Configurations>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IncludePerformanceTests>true</IncludePerformanceTests>
<ProjectGuid>{66AE57BA-B56C-4A1E-ACA6-7C18431D416B}</ProjectGuid>
<Configurations>netstandard-Debug;netstandard-Release</Configurations>
</PropertyGroup>
<ItemGroup>
<Compile Include="Perf.Pipe.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(CommonPath)\..\perf\PerfRunner\PerfRunner.csproj">
<ProjectReference Include="$(CommonTestPath)\Performance\PerfRunner\PerfRunner.csproj">
<Project>{69e46a6f-9966-45a5-8945-2559fe337827}</Project>
<Name>PerfRunner</Name>
</ProjectReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Import Project="$(CommonTestPath)\Tests.props" />
<PropertyGroup>
<ProjectGuid>{7EAFC2D8-48D2-4A56-A9C6-6BADF2053499}</ProjectGuid>
<IncludePerformanceTests>true</IncludePerformanceTests>
<Configurations>netstandard-Debug;netstandard-Release</Configurations>
</PropertyGroup>
<ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions src/tests.builds
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<EnableFullCoverageReportTarget>true</EnableFullCoverageReportTarget>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />

<PropertyGroup>
<!-- When building through build-tests.cmd tests.builds is the main project that is being built. We set IsTestProject to true when the project path has /tests/.
Since IsTestProject is set to false in this case, when TargetGroup = netfx it will add net462 and net47 build configurations if they exist on the test project.
We only want to build tests against current TargetGroup -->
<AdditionalBuildConfigurations Condition="'$(TargetGroup)' == 'netfx'"></AdditionalBuildConfigurations>
<GenerateCodeCoverageReportForAll>true</GenerateCodeCoverageReportForAll>

<GenerateFullCoverageReport>true</GenerateFullCoverageReport>
<CoverageReportInputPath>$(TestWorkingDir)**/coverage.xml</CoverageReportInputPath>
<CoverageReportDir>$(ArtifactsDir)coverage</CoverageReportDir>
<EnableBenchviewTarget>true</EnableBenchviewTarget>
</PropertyGroup>

Expand All @@ -19,7 +26,7 @@
</ItemGroup>

<!-- For UAP we are using an APPX that is registered with a unique ID. Because of that we need to run tests sequentially -->
<PropertyGroup Condition="'$(BuildingUAPVertical)'=='true' and '$(SkipTests)' != 'true'">
<PropertyGroup Condition="('$(BuildingUAPVertical)'=='true' AND '$(SkipTests)' != 'true') OR '$(Coverage)' == 'true'">
<SerializeProjects>true</SerializeProjects>
</PropertyGroup>

Expand Down

0 comments on commit 1ffab72

Please sign in to comment.