From 75385b1fa21f14076f05ca1045fc487d09337064 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 9 Jan 2018 16:25:22 -0800 Subject: [PATCH] Update perflab tests to execute in a fixed order Goal is to pin class init overhead on one test consistently. Also we were not picking up the "optimize for benchmark" attribute and so likely risking having tests execute concurrently. --- tests/src/performance/perflab/PerfLab.csproj | 1 + .../performance/perflab/Properties/AssemblyInfo.cs | 42 ---------------------- tests/src/performance/perflab/XunitPerformance.cs | 27 ++++++++++++++ 3 files changed, 28 insertions(+), 42 deletions(-) delete mode 100644 tests/src/performance/perflab/Properties/AssemblyInfo.cs create mode 100644 tests/src/performance/perflab/XunitPerformance.cs diff --git a/tests/src/performance/perflab/PerfLab.csproj b/tests/src/performance/perflab/PerfLab.csproj index ccacb0b..f295d94 100644 --- a/tests/src/performance/perflab/PerfLab.csproj +++ b/tests/src/performance/perflab/PerfLab.csproj @@ -37,6 +37,7 @@ + diff --git a/tests/src/performance/perflab/Properties/AssemblyInfo.cs b/tests/src/performance/perflab/Properties/AssemblyInfo.cs deleted file mode 100644 index b4d55dc..0000000 --- a/tests/src/performance/perflab/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.Xunit.Performance; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PerfLabTests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PerfLabTests")] -[assembly: AssemblyCopyright("Copyright \u00A9 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8761596f-209c-4277-a6ab-b7696ecf8f30")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: OptimizeForBenchmarks] \ No newline at end of file diff --git a/tests/src/performance/perflab/XunitPerformance.cs b/tests/src/performance/perflab/XunitPerformance.cs new file mode 100644 index 0000000..72e99f8 --- /dev/null +++ b/tests/src/performance/perflab/XunitPerformance.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Xunit.Performance; +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +[assembly: OptimizeForBenchmarks] + +// Constrain tests to execute in a predetermined order +[assembly: TestCaseOrderer("PerfLabTests.DisplayNameTestCaseOrderer", "PerfLab")] + +namespace PerfLabTests +{ + + public class DisplayNameTestCaseOrderer : ITestCaseOrderer + { + public IEnumerable OrderTestCases(IEnumerable testCases) + where TTestCase : ITestCase + => testCases.OrderBy(test => test.DisplayName); + } + +} -- 2.7.4