diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000..367bc806eb
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+# Verify snapshot files must keep LF line endings on every platform.
+# Verify.XunitV3 rejects a verified file that contains a CR with core.autocrlf.
+*.verified.* text eol=lf
+*.received.* text eol=lf
diff --git a/.github/workflows/generate-coverage-report.yaml b/.github/workflows/generate-coverage-report.yaml
index 9656efd86e..3a64f5d8ae 100644
--- a/.github/workflows/generate-coverage-report.yaml
+++ b/.github/workflows/generate-coverage-report.yaml
@@ -8,7 +8,7 @@ on:
type: boolean
description: Set `true` to skip integration tests.
default: true
-
+
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.skip_integration_tests }}-${{ github.head_ref || github.ref || github.run_id }}
cancel-in-progress: true
@@ -49,13 +49,13 @@ jobs:
- name: Collect Code Coverage
run: |
- dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Tests -c Release --no-build --framework net10.0"
- dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net10.0"
+ dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Tests -c Release --no-build --framework net10.0 --no-ansi --output Detailed"
+ dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net10.0 --no-ansi --output Detailed"
- name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests
if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
run: |
- dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net10.0"
+ dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net10.0 --no-ansi --output Detailed"
- name: Shutdown dotnet-coverage server.
run: dotnet coverage shutdown bdn_coverage --timeout 60000
@@ -77,7 +77,7 @@ jobs:
- name: Setup additional tools for Wasm/NativeAot tests
if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
uses: ./.github/actions/setup-additional-tools
-
+
- name: Install dotnet-coverage
run: dotnet tool install --global dotnet-coverage
@@ -89,13 +89,13 @@ jobs:
- name: Collect Code Coverage
run: |
- dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Tests -c Release --no-build --framework net472"
- dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net472"
+ dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Tests -c Release --no-build --framework net472 --no-ansi --output Detailed"
+ dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net472 --no-ansi --output Detailed"
- - name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests
- if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
+ - name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests
+ if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
run: |
- dotnet coverage connect bdn_coverage 'dotnet test tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472'
+ dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472 --no-ansi --output Detailed
- name: Shutdown dotnet-coverage server.
run: dotnet coverage shutdown bdn_coverage --timeout 60000
diff --git a/.github/workflows/run-tests-selected.yaml b/.github/workflows/run-tests-selected.yaml
index 0e2f436810..fac15e347c 100644
--- a/.github/workflows/run-tests-selected.yaml
+++ b/.github/workflows/run-tests-selected.yaml
@@ -89,12 +89,13 @@ jobs:
run: |
$PSNativeCommandUseErrorActionPreference = $true
$iterationCount = ${{ inputs.iteration_count }}
+
+ Write-Host ("OSArchitecture" + [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)
foreach($i in 1..$iterationCount) {
Write-Output ('##[group]Executing Iteration: {0}/${{ inputs.iteration_count }}' -f $i)
- dotnet test -c Release --framework ${{ inputs.framework }} --filter ${{ inputs.filter }} -tl:off --no-build --logger "console;verbosity=normal"
-
+ dotnet test -c Release --framework ${{ inputs.framework }} --no-build --filter "${{ inputs.filter }}" --no-ansi --progress off --output Detailed
Write-Output '##[endgroup]'
}
diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml
index b3ea72e473..39be091cc2 100644
--- a/.github/workflows/run-tests.yaml
+++ b/.github/workflows/run-tests.yaml
@@ -57,7 +57,9 @@ jobs:
if: always()
with:
name: test-windows-core-trx-${{ github.run_id }}-${{ matrix.os }}
- path: "**/*.trx"
+ path: |
+ **/*.trx
+ **/log_*.diag
test-windows-full:
strategy:
@@ -100,7 +102,9 @@ jobs:
if: always()
with:
name: test-windows-full-trx-${{ github.run_id }}-${{ matrix.os }}
- path: "**/*.trx"
+ path: |
+ **/*.trx
+ **/log_*.diag
test-linux:
strategy:
@@ -136,7 +140,9 @@ jobs:
if: always()
with:
name: test-linux-trx-${{ github.run_id }}-${{ matrix.os }}
- path: "**/*.trx"
+ path: |
+ **/*.trx
+ **/log_*.diag
test-macos:
name: test-macos (${{ matrix.os.arch }})
@@ -177,7 +183,9 @@ jobs:
if: always()
with:
name: test-macos(${{ matrix.os.arch }})-trx-${{ github.run_id }}
- path: "**/*.trx"
+ path: |
+ **/*.trx
+ **/log_*.diag
test-pack:
runs-on: ubuntu-latest
diff --git a/BenchmarkDotNet.slnx b/BenchmarkDotNet.slnx
index 2d5a3cf0dd..a54f83da97 100644
--- a/BenchmarkDotNet.slnx
+++ b/BenchmarkDotNet.slnx
@@ -28,6 +28,7 @@
+
diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs
index ab3833d129..07aff4737a 100644
--- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs
+++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs
@@ -1,8 +1,10 @@
using BenchmarkDotNet.Build.Helpers;
using Cake.Common.Diagnostics;
using Cake.Common.Tools.DotNet;
-using Cake.Common.Tools.DotNet.Test;
+using Cake.Common.Tools.DotNet.Run;
+using Cake.Core;
using Cake.Core.IO;
+using System.Linq;
using System.Runtime.InteropServices;
namespace BenchmarkDotNet.Build.Runners;
@@ -32,19 +34,34 @@ public class UnitTestRunner(BuildContext context)
private DirectoryPath TestOutputDirectory { get; } = context.RootDirectory
.Combine("TestResults");
- private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tfm)
+ private DotNetRunSettings GetTestSettingsParameters(FilePath logFile, string tfm)
{
- var settings = new DotNetTestSettings
+ // Enabled `Trace` level logging when debug logging is enabled on GitHub Actions.
+ // https://docs.github.com/en/actions/how-tos/monitor-workflows/enable-debug-logging
+ var diagnosticVerbosity = context.Environment.GetEnvironmentVariable("ACTIONS_STEP_DEBUG") == "true"
+ ? "Trace"
+ : "Warning"; // Logging Warning/Error/Critical level logs by default.
+
+ var settings = new DotNetRunSettings
{
Configuration = context.BuildConfiguration,
Framework = tfm,
NoBuild = true,
NoRestore = true,
- Loggers = new[] { "trx", $"trx;LogFileName={logFile.FullPath}", "console;verbosity=detailed" },
EnvironmentVariables =
{
["Platform"] = "" // force the tool to not look for the .dll in platform-specific directory
- }
+ },
+ ArgumentCustomization = args
+ => args.Append("--report-xunit-trx")
+ .AppendSwitchQuoted("--report-xunit-trx-filename", System.IO.Path.GetFileName(logFile.FullPath))
+ .Append("--no-ansi")
+ .AppendSwitch("--progress", "off")
+ .AppendSwitch("--output", "Detailed")
+ .AppendSwitch("--show-stdout", "Failed")
+ .Append("--diagnostic")
+ .AppendSwitch("--diagnostic-verbosity", diagnosticVerbosity)
+ .Append("--no-launch-profile"),
};
return settings;
}
@@ -58,7 +75,7 @@ private void RunTests(FilePath projectFile, string alias, string tfm)
var settings = GetTestSettingsParameters(trxFile, tfm);
context.Information($"Run tests for {projectFile} ({tfm}), result file: '{trxFile}'");
- context.DotNetTest(projectFile.FullPath, settings);
+ context.DotNetRun(projectFile.FullPath, settings);
}
private void RunUnitTests(string tfm)
diff --git a/global.json b/global.json
new file mode 100644
index 0000000000..3140116df3
--- /dev/null
+++ b/global.json
@@ -0,0 +1,5 @@
+{
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
+ }
+}
diff --git a/src/BenchmarkDotNet/Exporters/HtmlExporter.cs b/src/BenchmarkDotNet/Exporters/HtmlExporter.cs
index c335ac75a0..b4eca64101 100644
--- a/src/BenchmarkDotNet/Exporters/HtmlExporter.cs
+++ b/src/BenchmarkDotNet/Exporters/HtmlExporter.cs
@@ -9,10 +9,10 @@ public class HtmlExporter : ExporterBase
{
private const string CssDefinition = @"
";
protected override string FileExtension => "html";
diff --git a/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt b/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt
index f005cd82b4..39fbaa7a9d 100644
--- a/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt
+++ b/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt
@@ -1,4 +1,4 @@
-
+
$CSPROJPATH$
$([System.IO.Path]::ChangeExtension('$(OriginalCSProjPath)', '.Mono.props'))
diff --git a/src/BenchmarkDotNet/Templates/WasmCsProj.txt b/src/BenchmarkDotNet/Templates/WasmCsProj.txt
index 68915fe4f6..d566244f03 100644
--- a/src/BenchmarkDotNet/Templates/WasmCsProj.txt
+++ b/src/BenchmarkDotNet/Templates/WasmCsProj.txt
@@ -1,4 +1,4 @@
-
+
$CSPROJPATH$
$([System.IO.Path]::ChangeExtension('$(OriginalCSProjPath)', '.Wasm.props'))
@@ -27,6 +27,8 @@ $CORECLR_OVERRIDES$
false
false
BenchmarkDotNet.Autogenerated.UniqueProgramName
+
+ false
diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs
index 7ce4b32a5e..ef5ac5cbb2 100644
--- a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs
+++ b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs
@@ -151,6 +151,7 @@ private string GenerateProjectForNuGetBuild(string projectFilePath, BuildPartiti
false
false
true
+ false
{ilcOptimizationPreference}
{ilcOptimizationPreference}
{GetTrimmingSettings()}
diff --git a/tests/.editorconfig b/tests/.editorconfig
new file mode 100644
index 0000000000..a0bc3cface
--- /dev/null
+++ b/tests/.editorconfig
@@ -0,0 +1,11 @@
+root = false
+
+# C# files
+[*.cs]
+# xUnit1051: Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.
+dotnet_diagnostic.xUnit1051.severity = suggestion
+
+# Verify settings
+[*.{received,verified}.{txt}]
+charset = utf-8-bom
+trim_trailing_whitespace = false
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs
index 58db3ff85b..b78ab7b819 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs
@@ -559,7 +559,7 @@ public async Task Providing_expected_value_type_should_not_trigger_diagnostic(
{
var testCode = /* lang=c#-test */ $$"""
using DifferentNamespace;
-
+
using BenchmarkDotNet.Attributes;
public class BenchmarkClass
@@ -1114,7 +1114,7 @@ public void BenchmarkMethod({{integerValueAndType.Value2}} a)
}
public static IEnumerable DummyAttributeUsage
- => DummyAttributeUsageTheoryData;
+ => DummyAttributeUsageTheoryData.Select(x => x.Data);
public static TheoryData EmptyArgumentsAttributeUsagesWithMismatchingValueCount()
{
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs
index 16bf923259..3249f36163 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs
@@ -159,7 +159,7 @@ public class BenchmarkClass
}
public static TheoryData UniqueParameterAttributeUsages
- => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)];
+ => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)];
public static TheoryData DuplicateSameParameterAttributeUsages
=> DuplicateSameAttributeUsagesTheoryData;
@@ -321,7 +321,7 @@ public class BenchmarkClass
await RunAsync();
}
- public static TheoryData UniqueParameterAttributeUsages => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)];
+ public static TheoryData UniqueParameterAttributeUsages => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)];
public static TheoryData DuplicateSameParameterAttributeUsages => DuplicateSameAttributeUsagesTheoryData;
@@ -480,21 +480,19 @@ public static IEnumerable
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs
index bc5fcc258c..1970ab058d 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs
@@ -6,5 +6,5 @@ namespace BenchmarkDotNet.Analyzers.Tests.Fixtures;
public static class TheoryDataExtensions
{
public static ReadOnlyCollection AsReadOnly(this TheoryData theoryData)
- => (theoryData as IEnumerable).ToList().AsReadOnly();
+ => theoryData.Select(x => x.Data).ToList().AsReadOnly();
}
\ No newline at end of file
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs
index 5642d4c615..56819e9cf2 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs
@@ -1,4 +1,4 @@
-using Xunit.Abstractions;
+using Xunit.Sdk;
namespace BenchmarkDotNet.Analyzers.Tests.Fixtures;
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs
index 0b19f5c211..82b871d3a3 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs
@@ -1,4 +1,4 @@
-using Xunit.Abstractions;
+using Xunit.Sdk;
namespace BenchmarkDotNet.Analyzers.Tests.Fixtures;
@@ -29,4 +29,4 @@ public static implicit operator ValueTupleTriple((T1, T2, T3) valueT
public override string ToString()
=> Value1 == null || Value2 == null || Value3 == null ? "" : $"{Value1} · {Value2} · {Value3}";
-}
\ No newline at end of file
+}
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..22131f407f
--- /dev/null
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Runtime.InteropServices;
+
+[assembly: Guid("dfaa2493-0fd1-4d10-83b1-6014693da3d7")]
+
+[assembly: CaptureConsole]
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Properties/launchSettings.json b/tests/BenchmarkDotNet.Analyzers.Tests/Properties/launchSettings.json
new file mode 100644
index 0000000000..88b9648915
--- /dev/null
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/Properties/launchSettings.json
@@ -0,0 +1,20 @@
+{
+ "profiles": {
+ "Default": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "--list-test json": {
+ "commandName": "Project",
+ "commandLineArgs": "--list-test json"
+ },
+ "--info": {
+ "commandName": "Project",
+ "commandLineArgs": "--info"
+ },
+ "--help": {
+ "commandName": "Project",
+ "commandLineArgs": "--help"
+ }
+ }
+}
diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json b/tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json
new file mode 100644
index 0000000000..f04e503158
--- /dev/null
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json
@@ -0,0 +1,14 @@
+{
+ "commandLineOptions": {
+ "report-xunit-html": true,
+ "report-xunit-trx": true
+ },
+ "platformOptions": {
+ },
+ "environmentVariables": {
+ "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_UI_LANGUAGE": "en-us"
+ },
+ "xUnit": {
+ }
+}
diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj
index d18c1d327c..d68b6a4692 100644
--- a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj
+++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj
@@ -2,12 +2,12 @@
net10.0;net472
+ Exe
true
false
-
@@ -15,12 +15,7 @@
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..24d36fdb3a
--- /dev/null
+++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Runtime.InteropServices;
+
+[assembly: Guid("bde280f4-7829-4095-8385-a73f5f7acdc3")]
+
+[assembly: CaptureConsole]
diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/launchSettings.json b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/launchSettings.json
new file mode 100644
index 0000000000..6b34abfe26
--- /dev/null
+++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/launchSettings.json
@@ -0,0 +1,24 @@
+{
+ "profiles": {
+ "Default": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "Run filtered tests": {
+ "commandName": "Project",
+ "commandLineArgs": "--filter ScottPlotExporterTests --output Detailed"
+ },
+ "--list-test json": {
+ "commandName": "Project",
+ "commandLineArgs": "--list-test json"
+ },
+ "--info": {
+ "commandName": "Project",
+ "commandLineArgs": "--info"
+ },
+ "--help": {
+ "commandName": "Project",
+ "commandLineArgs": "--help"
+ }
+ }
+}
diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs
index bb481d3ea8..1d5118dc69 100644
--- a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs
+++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs
@@ -3,6 +3,9 @@
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Tests.Mocks;
using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+using Xunit;
namespace BenchmarkDotNet.Exporters.Plotting.Tests
{
diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json
new file mode 100644
index 0000000000..9d8a9fd932
--- /dev/null
+++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json
@@ -0,0 +1,15 @@
+{
+ "commandLineOptions": {
+ "report-xunit-html": true,
+ "report-xunit-trx": true
+ },
+ "platformOptions": {
+ },
+ "environmentVariables": {
+ "DOTNET_CLI_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_UI_LANGUAGE": "en-us"
+ },
+ "xUnit": {
+ }
+}
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj
index 24ce7ba476..462d92aa72 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj
@@ -2,7 +2,7 @@
BenchmarkDotNet.IntegrationTests.ConfigPerAssembly
- net472;net10.0
+ net472;net8.0;net10.0
true
BenchmarkDotNet.IntegrationTests.ConfigPerAssembly
BenchmarkDotNet.IntegrationTests.ConfigPerAssembly
diff --git a/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj b/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj
index 55839c1d79..9ad2394109 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj
@@ -2,14 +2,14 @@
BenchmarkDotNet.IntegrationTests.DisabledOptimizations
- net472;net10.0
+ net472;net8.0;net10.0
true
BenchmarkDotNet.IntegrationTests.DisabledOptimizations
BenchmarkDotNet.IntegrationTests.DisabledOptimizations
true
false
AnyCPU
-
+
false
diff --git a/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj b/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj
index f237f23791..cd2db5690c 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj
@@ -2,14 +2,14 @@
BenchmarkDotNet.IntegrationTests.EnabledOptimizations
- net472;net10.0
+ net472;net8.0;net10.0
true
BenchmarkDotNet.IntegrationTests.EnabledOptimizations
BenchmarkDotNet.IntegrationTests.EnabledOptimizations
true
false
AnyCPU
-
+
true
diff --git a/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj b/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj
index 055142f3ef..3b0efbd4ab 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj
+++ b/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj
@@ -11,7 +11,7 @@
-
+
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj
index 96d84f4943..f513999a11 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj
@@ -1,8 +1,9 @@
-
+
BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks
net462;net48;net8.0;net10.0
+ Exe
$(MSBuildWarningsAsMessages);MSB3277
false
@@ -16,13 +17,10 @@
true
-
-
-
-
-
-
-
+
+
+
+
@@ -34,12 +32,8 @@
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs
index b04e8d3640..d94a580e6c 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs
@@ -2,6 +2,7 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Extensions;
using BenchmarkDotNet.Jobs;
+using BenchmarkDotNet.Tests;
namespace BenchmarkDotNet.IntegrationTests.ManualRunning
{
@@ -9,15 +10,11 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor
{
private const string TfmEnvVarName = "TfmEnvVarName";
- public MultipleFrameworksTest(ITestOutputHelper output) : base(output)
- {
- }
-
- [Theory]
- [InlineData(RuntimeMoniker.Net462)]
- [InlineData(RuntimeMoniker.Net48)]
- [InlineData(RuntimeMoniker.Net80)]
- [InlineData(RuntimeMoniker.Net10_0)]
+ [Test]
+ [TUnit.Core.Arguments(RuntimeMoniker.Net462)]
+ [TUnit.Core.Arguments(RuntimeMoniker.Net48)]
+ [TUnit.Core.Arguments(RuntimeMoniker.Net80)]
+ [TUnit.Core.Arguments(RuntimeMoniker.Net10_0)]
public void EachFrameworkIsRebuilt(RuntimeMoniker runtime)
{
var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString()));
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..84dd4b071d
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs
@@ -0,0 +1,5 @@
+using System.Runtime.InteropServices;
+
+[assembly: Guid("f8203913-4b95-4fd9-b640-08d58dd563e2")]
+
+[assembly: NotInParallel]
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/launchSettings.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/launchSettings.json
new file mode 100644
index 0000000000..7563185165
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/launchSettings.json
@@ -0,0 +1,12 @@
+{
+ "profiles": {
+ "Default": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "--help": {
+ "commandName": "Project",
+ "commandLineArgs": "--help"
+ }
+ }
+}
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs
new file mode 100644
index 0000000000..874ad6d08a
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs
@@ -0,0 +1,11 @@
+#if NETFRAMEWORK
+namespace System.Runtime.CompilerServices;
+
+[AttributeUsage(AttributeTargets.Method, Inherited = false)]
+public sealed class ModuleInitializerAttribute : Attribute
+{
+ public ModuleInitializerAttribute()
+ {
+ }
+}
+#endif
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs
new file mode 100644
index 0000000000..a4a367b256
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs
@@ -0,0 +1,93 @@
+using AwesomeAssertions;
+using BenchmarkDotNet.Columns;
+using BenchmarkDotNet.Configs;
+using BenchmarkDotNet.Jobs;
+using BenchmarkDotNet.IntegrationTests;
+using BenchmarkDotNet.Loggers;
+using BenchmarkDotNet.Reports;
+using BenchmarkDotNet.Running;
+using TUnit.Core.Interfaces;
+
+namespace BenchmarkDotNet.Tests;
+
+public class BenchmarkTestExecutor
+{
+ protected ITestOutput Output => TestContext.Current!.Output!;
+
+ ///
+ /// Runs Benchmarks with the most simple config (SingleRunFastConfig)
+ /// combined with any benchmark config applied to TBenchmark (via an attribute)
+ /// By default will verify if every benchmark was successfully executed
+ ///
+ /// type that defines Benchmarks
+ /// Optional custom config to be used instead of the default
+ /// Optional: disable validation (default = true/enabled)
+ /// The summary from the benchmark run
+ public Reports.Summary CanExecute(IConfig? config = null, bool fullValidation = true)
+ {
+ return CanExecute(typeof(TBenchmark), config, fullValidation);
+ }
+
+ ///
+ /// Runs Benchmarks with the most simple config (SingleRunFastConfig)
+ /// combined with any benchmark config applied to Type (via an attribute)
+ /// By default will verify if every benchmark was successfully executed
+ ///
+ /// type that defines Benchmarks
+ /// Optional custom config to be used instead of the default
+ /// Optional: disable validation (default = true/enabled)
+ /// The summary from the benchmark run
+ public Reports.Summary CanExecute(Type type, IConfig? config = null, bool fullValidation = true)
+ {
+ // Add logging, so the Benchmark execution is in the TestRunner output (makes Debugging easier)
+ if (config == null)
+ config = CreateSimpleConfig();
+
+ if (!config.GetLoggers().OfType().Any())
+ config = config.AddLogger(Output != null ? new OutputLogger(Output) : ConsoleLogger.Default);
+ if (!config.GetLoggers().OfType().Any())
+ config = config.AddLogger(ConsoleLogger.Default);
+
+ if (!config.GetColumnProviders().Any())
+ config = config.AddColumnProvider(DefaultColumnProviders.Instance);
+
+ // Make sure we ALWAYS combine the Config (default or passed in) with any Config applied to the Type/Class
+ var summary = BenchmarkRunner.Run(type, config);
+
+ if (fullValidation)
+ {
+ summary.HasCriticalValidationErrors.Should().BeFalse("The \"Summary\" should have NOT \"HasCriticalValidationErrors\"");
+ summary.Reports.Any().Should().BeTrue("The \"Summary\" should contain at least one \"BenchmarkReport\" in the \"Reports\" collection");
+
+ summary.CheckPlatformLinkerIssues();
+
+ summary.Reports.Should().OnlyContain(r => r.BuildResult.IsBuildSuccess,
+ "The following benchmarks have failed to build: " +
+ string.Join(", ", summary.Reports.Where(r => !r.BuildResult.IsBuildSuccess).Select(r => r.BenchmarkCase.DisplayInfo)));
+
+ summary.Reports.Should().OnlyContain(r => r.ExecuteResults != null,
+ "The following benchmarks have failed to execute: " +
+ string.Join(", ", summary.Reports.Where(r => r.ExecuteResults == null || r.ExecuteResults.Any(er => !er.IsSuccess)).Select(r => r.BenchmarkCase.DisplayInfo))); ;
+
+ summary.Reports.SelectMany(x => x.ExecuteResults).Should().OnlyContain(r => r.IsSuccess,
+ "All reports should have succeeded to execute");
+ }
+
+ return summary;
+ }
+
+ protected IConfig CreateSimpleConfig(OutputLogger? logger = null, Job? job = null)
+ {
+ var baseConfig = job == null ? (IConfig)new SingleRunFastConfig() : new SingleJobConfig(job);
+ return baseConfig
+ .AddLogger(logger ?? (Output != null ? new OutputLogger(Output) : ConsoleLogger.Default))
+ .AddColumnProvider(DefaultColumnProviders.Instance)
+ .AddAnalyser(DefaultConfig.Instance.GetAnalysers().ToArray());
+ }
+
+ protected static IReadOnlyList GetSingleStandardOutput(Summary summary)
+ => summary.Reports.Single().ExecuteResults.Single().StandardOutput;
+
+ protected static IReadOnlyList GetCombinedStandardOutput(Summary summary)
+ => summary.Reports.SelectMany(r => r.ExecuteResults).SelectMany(e => e.StandardOutput).ToArray();
+}
\ No newline at end of file
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs
new file mode 100644
index 0000000000..5350d2d9f9
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs
@@ -0,0 +1,39 @@
+using BenchmarkDotNet.Loggers;
+using System.Runtime.CompilerServices;
+using TUnit.Core.Interfaces;
+
+namespace BenchmarkDotNet.Tests;
+
+public class OutputLogger : AccumulationLogger
+{
+ private readonly ITestOutput Output;
+ private string currentLine = "";
+
+ public OutputLogger(ITestOutput output)
+ {
+ Output = output ?? throw new ArgumentNullException(nameof(Output));
+ }
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public override void Write(LogKind logKind, string text)
+ {
+ currentLine += text;
+ base.Write(logKind, text);
+ }
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public override void WriteLine()
+ {
+ Output.WriteLine(currentLine);
+ currentLine = "";
+ base.WriteLine();
+ }
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public override void WriteLine(LogKind logKind, string text)
+ {
+ Output.WriteLine(currentLine + text);
+ currentLine = "";
+ base.WriteLine(logKind, text);
+ }
+}
\ No newline at end of file
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json
new file mode 100644
index 0000000000..18d3492f20
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json
@@ -0,0 +1,14 @@
+{
+ "commandLineOptions": {
+ "report-trx": true
+ },
+ "platformOptions": {
+ },
+ "environmentVariables": {
+ "DOTNET_CLI_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_UI_LANGUAGE": "en-us"
+ },
+ "xUnit": {
+ }
+}
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj
old mode 100755
new mode 100644
index 72dd42c0f4..7135235978
--- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj
@@ -3,6 +3,9 @@
BenchmarkDotNet.IntegrationTests.ManualRunning
net472;net10.0
+
+ $(MSBuildWarningsAsMessages);MSB3277
+ Exe
true
BenchmarkDotNet.IntegrationTests.ManualRunning
BenchmarkDotNet.IntegrationTests.ManualRunning
@@ -14,7 +17,6 @@
-
@@ -24,11 +26,13 @@
$(DefineConstants);$(ExtraDefineConstants)
-
+
-
-
-
+
+
+
+
+
@@ -43,12 +47,7 @@
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs
index efb02f0aea..0020481687 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs
@@ -5,6 +5,7 @@
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
+using Xunit;
namespace BenchmarkDotNet.IntegrationTests.ManualRunning
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs
index dc11404f9f..4a240100c4 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs
@@ -5,6 +5,7 @@
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
+using Xunit;
namespace BenchmarkDotNet.IntegrationTests.ManualRunning
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs
index 6592e76047..434af9df6c 100644
--- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs
@@ -2,6 +2,7 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
+using Xunit;
namespace BenchmarkDotNet.IntegrationTests.ManualRunning
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..bf52573154
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs
@@ -0,0 +1,9 @@
+using System.Runtime.InteropServices;
+using Xunit.Sdk;
+using Xunit.v3;
+
+[assembly: Guid("4d7c0994-2750-45dc-bbe8-750b158ea826")]
+
+[assembly: CaptureConsole]
+[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
+[assembly: Parallelization(Mode = ParallelMode.None)]
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/launchSettings.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/launchSettings.json
new file mode 100644
index 0000000000..c3c6453192
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/launchSettings.json
@@ -0,0 +1,24 @@
+{
+ "profiles": {
+ "Default": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "Run filtered tests": {
+ "commandName": "Project",
+ "commandLineArgs": "--filter DotMemoryTests --output Detailed"
+ },
+ "--list-test json": {
+ "commandName": "Project",
+ "commandLineArgs": "--list-test json"
+ },
+ "--info": {
+ "commandName": "Project",
+ "commandLineArgs": "--info"
+ },
+ "--help": {
+ "commandName": "Project",
+ "commandLineArgs": "--help"
+ }
+ }
+}
diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json
new file mode 100644
index 0000000000..9d8a9fd932
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json
@@ -0,0 +1,15 @@
+{
+ "commandLineOptions": {
+ "report-xunit-html": true,
+ "report-xunit-trx": true
+ },
+ "platformOptions": {
+ },
+ "environmentVariables": {
+ "DOTNET_CLI_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_UI_LANGUAGE": "en-us"
+ },
+ "xUnit": {
+ }
+}
diff --git a/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs b/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs
index 54934cd6a2..94965c50f6 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs
@@ -2,7 +2,7 @@
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
-using BenchmarkDotNet.Tests.XUnit;
+using BenchmarkDotNet.Tests;
namespace BenchmarkDotNet.IntegrationTests
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/AsyncEnumerableBenchmarksTests.cs b/tests/BenchmarkDotNet.IntegrationTests/AsyncEnumerableBenchmarksTests.cs
index d443c43074..56ea41f71f 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/AsyncEnumerableBenchmarksTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/AsyncEnumerableBenchmarksTests.cs
@@ -9,22 +9,22 @@ namespace BenchmarkDotNet.IntegrationTests;
public class AsyncEnumerableBenchmarksTests(ITestOutputHelper output) : BenchmarkTestExecutor(output)
{
- public static TheoryData GetAllToolchains() =>
+ public static TheoryData GetAllToolchains() => new(
[
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }),
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = true }),
new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = false }),
new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = true }),
Job.Default.GetToolchain()
- ];
+ ]);
// InProcessNoEmitToolchain does not support custom async enumerables or [AsyncCallerType].
- public static TheoryData GetCustomSupportedToolchains() =>
+ public static TheoryData GetCustomSupportedToolchains() => new(
[
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }),
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = true }),
Job.Default.GetToolchain()
- ];
+ ]);
[Theory]
[MemberData(nameof(GetAllToolchains), DisableDiscoveryEnumeration = true)]
diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj
index 768cccaaa7..f0b7cb1260 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj
+++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj
@@ -4,6 +4,7 @@
BenchmarkDotNet.IntegrationTests
net10.0
$(TargetFrameworks);net472
+ Exe
true
BenchmarkDotNet.IntegrationTests
BenchmarkDotNet.IntegrationTests
@@ -20,7 +21,6 @@
-
@@ -35,6 +35,8 @@
+
+
@@ -43,16 +45,11 @@
-
+
+
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
@@ -60,6 +57,7 @@
+
diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkSwitcherTest.cs b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkSwitcherTest.cs
index 9f5fcc60a2..8bd664a714 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkSwitcherTest.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkSwitcherTest.cs
@@ -30,7 +30,7 @@ public void WhenInvalidCommandLineArgumentIsPassedAnErrorMessageIsDisplayedAndNo
var summaries = BenchmarkSwitcher
.FromTypes([])
- .Run(["--DOES_NOT_EXIST"], config);
+ .Run(["--DOES_NOT_EXIST"], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries);
Assert.Contains("Option 'DOES_NOT_EXIST' is unknown.", logger.GetLog());
@@ -44,7 +44,7 @@ public void WhenUserAsksForInfoAnInfoIsDisplayedAndNoBenchmarksAreExecuted()
var summaries = BenchmarkSwitcher
.FromTypes([])
- .Run(["--info"], config);
+ .Run(["--info"], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries);
Assert.Contains(HostEnvironmentInfo.GetInformation(), logger.GetLog());
@@ -58,7 +58,7 @@ public void WhenInvalidTypeIsProvidedAnErrorMessageIsDisplayedAndNoBenchmarksAre
var summaries = BenchmarkSwitcher
.FromTypes([typeof(ClassC)])
- .Run(["--filter", "*"], config);
+ .Run(["--filter", "*"], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries);
Assert.Contains(GetValidationErrorForType(typeof(ClassC)), logger.GetLog());
@@ -72,7 +72,7 @@ public void WhenNoTypesAreProvidedAnErrorMessageIsDisplayedAndNoBenchmarksAreExe
var summaries = BenchmarkSwitcher
.FromTypes([])
- .Run(["--filter", "*"], config);
+ .Run(["--filter", "*"], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries);
Assert.Contains("No benchmarks were found.", logger.GetLog());
@@ -87,7 +87,7 @@ public void WhenFilterReturnsNothingAnErrorMessageIsDisplayedAndNoBenchmarksAreE
const string filter = "WRONG";
var summaries = BenchmarkSwitcher
.FromTypes([typeof(ClassA), typeof(ClassB)])
- .Run(["--filter", filter], config);
+ .Run(["--filter", filter], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries);
Assert.Contains($"The filter '{filter}' that you have provided returned 0 benchmarks.", logger.GetLog());
@@ -101,7 +101,7 @@ public void WhenUserAsksToPrintAListWePrintIt()
var summaries = BenchmarkSwitcher
.FromTypes([typeof(ClassA)])
- .Run(["--list", "flat"], config);
+ .Run(["--list", "flat"], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries);
Assert.Contains("BenchmarkDotNet.IntegrationTests.ClassA.Method1", logger.GetLog());
@@ -135,7 +135,7 @@ public void WhenDisableLogFileWeDontWriteToFile()
{
var summaries = BenchmarkSwitcher
.FromTypes([typeof(ClassA)])
- .RunAll(config);
+ .RunAll(config, cancellationToken: TestContext.Current.CancellationToken);
var summary = summaries.Single();
logFilePath = summary.LogFilePath;
@@ -161,7 +161,7 @@ public void EnsureLogFileIsWritten()
{
var summaries = BenchmarkSwitcher
.FromTypes([typeof(ClassA)])
- .RunAll(config);
+ .RunAll(config, cancellationToken: TestContext.Current.CancellationToken);
var summary = summaries.Single();
logFilePath = summary.LogFilePath;
@@ -185,7 +185,7 @@ public void WhenUserDoesNotProvideFilterOrCategoriesViaCommandLineWeAskToChooseB
var summaries = new BenchmarkSwitcher(userInteractionMock)
.With([typeof(WithDryAttributeAndCategory)])
- .Run([], config);
+ .Run([], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries); // summaries is empty because the returnValue configured for mock returns 0 types
Assert.Equal(1, userInteractionMock.AskUserCalledTimes);
@@ -203,7 +203,7 @@ public void WhenUserProvidesCategoriesWithoutFiltersWeDontAskToChooseBenchmarkJu
var summaries = new BenchmarkSwitcher(userInteractionMock)
.With(types)
- .Run([categoriesConsoleLineArgument, TestCategory], config);
+ .Run([categoriesConsoleLineArgument, TestCategory], config, TestContext.Current.CancellationToken);
Assert.Single(summaries);
Assert.Equal(0, userInteractionMock.AskUserCalledTimes);
@@ -221,7 +221,7 @@ public void WhenUserProvidesCategoriesWithFiltersWeDontAskToChooseBenchmarkJustU
var summaries = new BenchmarkSwitcher(userInteractionMock)
.With(types)
- .Run([categoriesConsoleLineArgument, TestCategory, "--filter", "nothing"], config);
+ .Run([categoriesConsoleLineArgument, TestCategory, "--filter", "nothing"], config, TestContext.Current.CancellationToken);
Assert.Empty(summaries); // the summaries is empty because the provided filter returns nothing
Assert.Equal(0, userInteractionMock.AskUserCalledTimes);
@@ -239,7 +239,7 @@ public void ValidCommandLineArgumentsAreProperlyHandled()
var switcher = new BenchmarkSwitcher(types);
// BenchmarkSwitcher only picks up config values via the args passed in, not via class annotations (e.g "[DryConfig]")
- var results = switcher.Run(["-j", "Dry", "--filter", "*ClassB.Method4"], config);
+ var results = switcher.Run(["-j", "Dry", "--filter", "*ClassB.Method4"], config, TestContext.Current.CancellationToken);
Assert.Single(results);
Assert.Single(results.SelectMany(r => r.BenchmarksCases));
Assert.Single(results.SelectMany(r => r.BenchmarksCases.Select(bc => bc.Job)));
@@ -255,7 +255,7 @@ public void WhenJobIsDefinedInTheConfigAndArgumentsDontContainJobArgumentOnlySin
MockExporter mockExporter = new MockExporter();
var configWithJobDefined = ManualConfig.CreateEmpty().AddExporter(mockExporter).AddJob(Job.Dry);
- var results = switcher.Run(["--filter", "*Method3"], configWithJobDefined);
+ var results = switcher.Run(["--filter", "*Method3"], configWithJobDefined, TestContext.Current.CancellationToken);
Assert.True(mockExporter.exported);
@@ -273,7 +273,7 @@ public void WhenJobIsDefinedViaAttributeAndArgumentsDontContainJobArgumentOnlySi
MockExporter mockExporter = new MockExporter();
var configWithoutJobDefined = ManualConfig.CreateEmpty().AddExporter(mockExporter);
- var results = switcher.Run(["--filter", "*WithDryAttribute*"], configWithoutJobDefined);
+ var results = switcher.Run(["--filter", "*WithDryAttribute*"], configWithoutJobDefined, TestContext.Current.CancellationToken);
Assert.True(mockExporter.exported);
@@ -291,7 +291,7 @@ public void JobNotDefinedButStillBenchmarkIsExecuted()
MockExporter mockExporter = new MockExporter();
var configWithoutJobDefined = ManualConfig.CreateEmpty().AddExporter(mockExporter);
- var results = switcher.Run(["--filter", "*"], configWithoutJobDefined);
+ var results = switcher.Run(["--filter", "*"], configWithoutJobDefined, TestContext.Current.CancellationToken);
Assert.True(mockExporter.exported);
@@ -309,7 +309,7 @@ public void WhenUserCreatesStaticBenchmarkMethodWeDisplayAnError_FromTypes()
var summariesForType = BenchmarkSwitcher
.FromTypes([typeof(Static.BenchmarkClassWithStaticMethodsOnly)])
- .Run(["--filter", "*"], config);
+ .Run(["--filter", "*"], config, TestContext.Current.CancellationToken);
Assert.True(summariesForType.Single().HasCriticalValidationErrors);
Assert.Contains("static", logger.GetLog());
@@ -323,7 +323,7 @@ public void WhenUserCreatesStaticBenchmarkMethodWeDisplayAnError_FromAssembly()
var summariesForAssembly = BenchmarkSwitcher
.FromAssembly(typeof(Static.BenchmarkClassWithStaticMethodsOnly).Assembly)
- .Run(["--filter", "*"], config);
+ .Run(["--filter", "*"], config, TestContext.Current.CancellationToken);
Assert.True(summariesForAssembly.Single().HasCriticalValidationErrors);
Assert.Contains("static", logger.GetLog());
@@ -339,9 +339,9 @@ public void WhenUserAddTheResumeAttributeAndRunTheBenchmarks()
var switcher = new BenchmarkSwitcher(types);
// the first run should execute all benchmarks
- Assert.Single(switcher.Run(["--filter", "*WithDryAttributeAndCategory*"], config));
+ Assert.Single(switcher.Run(["--filter", "*WithDryAttributeAndCategory*"], config, TestContext.Current.CancellationToken));
// resuming after succesfull run should run nothing
- Assert.Empty(switcher.Run(["--resume", "--filter", "*WithDryAttributeAndCategory*"], config));
+ Assert.Empty(switcher.Run(["--resume", "--filter", "*WithDryAttributeAndCategory*"], config, TestContext.Current.CancellationToken));
}
private class UserInteractionMock : IUserInteraction
diff --git a/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs b/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs
index fe0b3940cd..9073af2e4e 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs
@@ -19,12 +19,12 @@ namespace BenchmarkDotNet.IntegrationTests;
public class CallerThreadTests(ITestOutputHelper output) : BenchmarkTestExecutor(output)
{
- public static TheoryData GetToolchains() =>
+ public static TheoryData GetToolchains() => new(
[
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }),
new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = false }),
Job.Default.GetToolchain()
- ];
+ ]);
[Theory]
[MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
diff --git a/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs b/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs
index bd8da25d01..3d88695806 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs
@@ -1,5 +1,6 @@
#if NETFRAMEWORK
using BenchmarkDotNet.IntegrationTests.CustomPaths;
+using Xunit;
namespace BenchmarkDotNet.IntegrationTests
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs b/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs
index a08fb99903..e165df196b 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs
@@ -1,12 +1,10 @@
-using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Extensions;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Tests.XUnit;
-#if !DEBUG
-#endif
+using System.Reflection;
namespace BenchmarkDotNet.IntegrationTests
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs
index 26720c6c41..7be2907fed 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs
@@ -91,6 +91,9 @@ public void Recursive()
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, IToolchain toolchain)
{
+ if (OsDetector.IsMacOS() && toolchain.IsInProcess)
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076");
+
var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));
@@ -111,6 +114,9 @@ public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, IToolchain
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleAllMethodCallsUsingFilters(Jit jit, Platform platform, IToolchain toolchain)
{
+ if (OsDetector.IsMacOS())
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076");
+
var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 1, filters: ["*WithCalls*"]));
@@ -137,6 +143,9 @@ public void CanDisassembleAllMethodCallsUsingFilters(Jit jit, Platform platform,
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleGenericTypes(Jit jit, Platform platform, IToolchain toolchain)
{
+ if (OsDetector.IsMacOS())
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076");
+
var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));
@@ -158,6 +167,9 @@ [Benchmark] public void JustReturn() { }
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleInlinableBenchmarks(Jit jit, Platform platform, IToolchain toolchain)
{
+ if (OsDetector.IsMacOS())
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076");
+
var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));
diff --git a/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs b/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs
index e8b054c200..6a824768bd 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs
@@ -73,12 +73,12 @@ public class FooBench
public void Foo() => Thread.Sleep(10);
}
- public static TheoryData GetToolchains() =>
+ public static TheoryData GetToolchains() => new(
[
InProcessEmitToolchain.Default,
InProcessNoEmitToolchain.Default,
Job.Default.GetToolchain()
- ];
+ ]);
// https://github.com/dotnet/BenchmarkDotNet/issues/1120
[TheoryEnvSpecific(EnvRequirement.NonGitHubDraftPR)]
diff --git a/tests/BenchmarkDotNet.IntegrationTests/EventProcessorTests.cs b/tests/BenchmarkDotNet.IntegrationTests/EventProcessorTests.cs
index 00364868fc..d72c039530 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/EventProcessorTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/EventProcessorTests.cs
@@ -174,7 +174,7 @@ public void WhenUsingEventProcessorWithBuildFailures()
.AddAnalyser(DefaultConfig.Instance.GetAnalysers().ToArray());
if (validator != null)
config = config.AddValidator(validator);
- _ = BenchmarkRunner.Run(types, config);
+ _ = BenchmarkRunner.Run(types, config, cancellationToken: TestContext.Current.CancellationToken);
return eventProcessor.Events;
}
diff --git a/tests/BenchmarkDotNet.IntegrationTests/ExceptionDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ExceptionDiagnoserTests.cs
index 766a049ce5..b889b19179 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/ExceptionDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/ExceptionDiagnoserTests.cs
@@ -15,7 +15,7 @@ public void ExceptionCountIsAccurate()
{
var config = CreateConfig();
- var summary = BenchmarkRunner.Run(config);
+ var summary = BenchmarkRunner.Run(config, cancellationToken: TestContext.Current.CancellationToken);
AssertStats(summary, new Dictionary
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs b/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs
index 8d2558ebe3..ccd5f365fe 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs
@@ -1,7 +1,8 @@
-using System.Runtime;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
+using System.Runtime;
+
#if NETFRAMEWORK
using BenchmarkDotNet.Environments;
#endif
diff --git a/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs b/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs
index 269d3fc8aa..c86ec7ace3 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs
@@ -17,7 +17,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
-
namespace BenchmarkDotNet.IntegrationTests
{
public class InProcessTest : BenchmarkTestExecutor
@@ -83,7 +82,7 @@ public void BenchmarkDifferentPlatformReturnsValidationError()
.AddColumnProvider(DefaultColumnProviders.Instance);
var runInfo = BenchmarkConverter.TypeToBenchmarks(typeof(BenchmarkAllCases), otherPlatformConfig);
- var summary = BenchmarkRunner.Run(runInfo);
+ var summary = BenchmarkRunner.Run(runInfo, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotEmpty(summary.ValidationErrors);
}
diff --git a/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs b/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs
index 39374e9da6..efeca42de0 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs
@@ -27,7 +27,7 @@ public void BenchmarkCanAllocateMoreThan2Gb_Core()
config.AddColumnProvider(DefaultColumnProviders.Instance)
.AddLogger(new OutputLogger(output));
- var summary = BenchmarkRunner.Run(config);
+ var summary = BenchmarkRunner.Run(config, cancellationToken: TestContext.Current.CancellationToken);
Assert.True(summary.Reports
.All(report => report.ExecuteResults
@@ -56,7 +56,7 @@ public void BenchmarkCanAllocateMoreThan2Gb_Framework()
config.AddColumnProvider(DefaultColumnProviders.Instance)
.AddLogger(new OutputLogger(output));
- var summary = BenchmarkRunner.Run(config);
+ var summary = BenchmarkRunner.Run(config, cancellationToken: TestContext.Current.CancellationToken);
Assert.True(summary.Reports
.All(report => report.ExecuteResults
diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs
old mode 100755
new mode 100644
index d7ebecee71..33d64d84ee
--- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs
@@ -25,6 +25,7 @@
using BenchmarkDotNet.Validators;
using System.Reflection;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace BenchmarkDotNet.IntegrationTests
{
@@ -36,10 +37,7 @@ public class MemoryDiagnoserTests
public static IEnumerable GetToolchains()
{
- // xunit v2 allocates every 100ms on a background timer that makes the tests flaky on Mac/Linux (MSTestEnableParentProcessQuery).
- // TODO: remove the guard when the test framework is updated.
- if (OsDetector.IsWindows())
- yield return [InProcessEmitToolchain.Default];
+ yield return [InProcessEmitToolchain.Default];
if (ContinuousIntegration.IsGitHubDraftPR())
yield break;
@@ -55,7 +53,8 @@ public class AccurateAllocations
[Benchmark] public Task AllocateTask() => Task.FromResult(-12345);
}
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void MemoryDiagnoserIsAccurate(IToolchain toolchain)
{
@@ -152,7 +151,8 @@ private void AllocateUntilGcWakesUp()
}
}
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void MemoryDiagnoserDoesNotIncludeAllocationsFromSetupAndCleanup(IToolchain toolchain)
{
@@ -167,7 +167,8 @@ public class EmptyBenchmark
[Benchmark] public void EmptyMethod() { }
}
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void EngineShouldNotInterfereAllocationResults(IToolchain toolchain)
{
@@ -192,15 +193,45 @@ public ulong TimeConsuming()
}
// #1542
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void TieredJitShouldNotInterfereAllocationResults(IToolchain toolchain)
{
+ if (toolchain.IsInProcess)
+ ValidateMtpProgressDisabled();
+
+ if (toolchain.IsInProcess && OsDetector.IsWindows() && Portability.RuntimeInformation.IsNetCore)
+ {
+ // Randomly failed on Windows(x64/arm64)+.NET Framework.
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3203");
+ }
+
AssertAllocations(toolchain, typeof(TimeConsumingBenchmark), new Dictionary
{
{ nameof(TimeConsumingBenchmark.TimeConsuming), 0 }
},
iterationCount: 10); // 1 iteration is not enough to repro the problem
+
+ static void ValidateMtpProgressDisabled()
+ {
+ if (!OsDetector.IsWindows() || RuntimeInformation.OSArchitecture != Architecture.Arm64)
+ return;
+
+ // On Windows(arm64) environment following test failed with extra memory allocations (1 or 2 bytes)
+ // TieredJitShouldNotInterfereAllocationResults
+ var args = Environment.GetCommandLineArgs();
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i] == "--progress=off")
+ return;
+
+ if (i < args.Length - 1 && args[i] == "--progress" && args[i + 1] == "off")
+ return;
+ }
+
+ throw new NotSupportedException("Measure memory allocation requires setting `--progress off`");
+ }
}
public class NoBoxing
@@ -208,10 +239,17 @@ public class NoBoxing
[Benchmark] public ValueTuple ReturnsValueType() => new ValueTuple(0);
}
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void EngineShouldNotIntroduceBoxing(IToolchain toolchain)
{
+ if (toolchain.IsInProcess && OsDetector.IsWindows() && !Portability.RuntimeInformation.IsNetCore)
+ {
+ // Randomly failed on Windows(x64)+.NET Framework.
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/pull/3065#issuecomment-5064984074");
+ }
+
AssertAllocations(toolchain, typeof(NoBoxing), new Dictionary
{
{ nameof(NoBoxing.ReturnsValueType), 0 }
@@ -229,10 +267,17 @@ public class NonAllocatingAsynchronousBenchmarks
[Benchmark] public ValueTask CompletedValueTaskOfT() => new ValueTask(default(int));
}
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void AwaitingTasksShouldNotInterfereAllocationResults(IToolchain toolchain)
{
+ if (toolchain.IsInProcess && OsDetector.IsWindows() && !Portability.RuntimeInformation.IsNetCore)
+ {
+ // Randomly failed on Windows(x64/arm64)+.NET Framework.
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3203");
+ }
+
AssertAllocations(toolchain, typeof(NonAllocatingAsynchronousBenchmarks), new Dictionary
{
{ nameof(NonAllocatingAsynchronousBenchmarks.CompletedTask), 0 },
@@ -254,7 +299,8 @@ public void WithOperationsPerInvoke()
private void DoNotInline(object left, object right) { }
}
- [Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
+ [Theory(SkipTestWithoutData = true)]
+ [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void AllocatedMemoryShouldBeScaledForOperationsPerInvoke(IToolchain toolchain)
{
@@ -280,14 +326,13 @@ public byte[] SixtyFourBytesArray()
}
}
- [TheoryEnvSpecific("Full Framework cannot measure precisely enough for low invocation counts.", EnvRequirement.DotNetCoreOnly)]
+ [TheoryEnvSpecific("Full Framework cannot measure precisely enough for low invocation counts.", EnvRequirement.DotNetCoreOnly, SkipTestWithoutData = true)]
[MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain)
{
- // TODO: Skip test on macos. Temporary workaround for https://github.com/dotnet/BenchmarkDotNet/issues/2779
- if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX))
- return;
+ if (OsDetector.IsWindows() && toolchain.IsInProcess)
+ Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/2779");
long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word
long arraySizeOverhead = IntPtr.Size; // array length
@@ -350,7 +395,7 @@ public void Allocate()
}
}
- [TheoryEnvSpecific("Full Framework cannot measure precisely enough", EnvRequirement.DotNetCoreOnly)]
+ [TheoryEnvSpecific("Full Framework cannot measure precisely enough", EnvRequirement.DotNetCoreOnly, SkipTestWithoutData = true)]
[MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void MemoryDiagnoserIsAccurateForMultiThreadedBenchmarks(IToolchain toolchain)
@@ -370,7 +415,7 @@ private void AssertAllocations(IToolchain toolchain, Type benchmarkType, Diction
var config = CreateConfig(toolchain, runtime, iterationCount);
var benchmarks = BenchmarkConverter.TypeToBenchmarks(benchmarkType, config);
- var summary = BenchmarkRunner.Run(benchmarks);
+ var summary = BenchmarkRunner.Run(benchmarks, cancellationToken: TestContext.Current.CancellationToken);
try
{
summary.CheckPlatformLinkerIssues();
diff --git a/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs
index b1e42e7c4c..e9f7b3c195 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs
@@ -1,5 +1,9 @@
using System.Runtime.InteropServices;
+using Xunit.Sdk;
+using Xunit.v3;
[assembly: Guid("74362bb1-9f64-4be5-b079-b4ac19dae5db")]
-[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)]
\ No newline at end of file
+[assembly: CaptureConsole]
+[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
+[assembly: Parallelization(Mode = ParallelMode.None)]
diff --git a/tests/BenchmarkDotNet.IntegrationTests/Properties/launchSettings.json b/tests/BenchmarkDotNet.IntegrationTests/Properties/launchSettings.json
new file mode 100644
index 0000000000..6f8f831200
--- /dev/null
+++ b/tests/BenchmarkDotNet.IntegrationTests/Properties/launchSettings.json
@@ -0,0 +1,24 @@
+{
+ "profiles": {
+ "Default": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "Run filtered tests": {
+ "commandName": "Project",
+ "commandLineArgs": "--filter AppConfigTests --output Detailed"
+ },
+ "--list-test json": {
+ "commandName": "Project",
+ "commandLineArgs": "--list-test json"
+ },
+ "--info": {
+ "commandName": "Project",
+ "commandLineArgs": "--info"
+ },
+ "--help": {
+ "commandName": "Project",
+ "commandLineArgs": "--help"
+ }
+ }
+}
diff --git a/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs
index 9daa2db80a..3adec4f6cb 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs
@@ -1,4 +1,3 @@
-
namespace BenchmarkDotNet.IntegrationTests
{
public class ReferencesTests : BenchmarkTestExecutor
diff --git a/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs b/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs
index 5a1405bb78..62a21b6707 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs
@@ -9,14 +9,14 @@ namespace BenchmarkDotNet.IntegrationTests;
public class RunAsyncTests(ITestOutputHelper output) : BenchmarkTestExecutor(output)
{
- public static TheoryData GetToolchains() =>
+ public static TheoryData GetToolchains() => new(
[
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }),
new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = true }),
new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = false }),
new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = true }),
Job.Default.GetToolchain()
- ];
+ ]);
[Theory]
[MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
diff --git a/tests/BenchmarkDotNet.IntegrationTests/RunningEmptyBenchmarkTests.cs b/tests/BenchmarkDotNet.IntegrationTests/RunningEmptyBenchmarkTests.cs
index b437ae35d5..02686df83a 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/RunningEmptyBenchmarkTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/RunningEmptyBenchmarkTests.cs
@@ -46,7 +46,7 @@ public void GenericTypeWithoutBenchmarkAttribute_ThrowsValidationError_WhenNoBen
{
GetConfigWithLogger(out var logger, out var config);
- var summary = BenchmarkRunner.Run(config, args);
+ var summary = BenchmarkRunner.Run(config, args, TestContext.Current.CancellationToken);
if (args == null)
{
@@ -71,7 +71,7 @@ public void GenericTypeWithBenchmarkAttribute_RunsSuccessfully(string[]? args)
{
GetConfigWithLogger(out var logger, out var config);
- var summary = BenchmarkRunner.Run(config, args);
+ var summary = BenchmarkRunner.Run(config, args, TestContext.Current.CancellationToken);
Assert.False(summary.HasCriticalValidationErrors);
Assert.DoesNotContain(summary.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(NotEmptyBenchmark)));
Assert.DoesNotContain(GetValidationErrorForType(typeof(NotEmptyBenchmark)), logger.GetLog());
@@ -90,7 +90,7 @@ public void TypeWithoutBenchmarkAttribute_ThrowsValidationError_WhenNoBenchmarkA
{
GetConfigWithLogger(out var logger, out var config);
- var summary = BenchmarkRunner.Run(typeof(EmptyBenchmark), config, args);
+ var summary = BenchmarkRunner.Run(typeof(EmptyBenchmark), config, args, TestContext.Current.CancellationToken);
if (args == null)
{
@@ -115,7 +115,7 @@ public void TypeWithBenchmarkAttribute_RunsSuccessfully(string[]? args)
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run(typeof(NotEmptyBenchmark), config, args);
+ var summaries = BenchmarkRunner.Run(typeof(NotEmptyBenchmark), config, args, TestContext.Current.CancellationToken);
Assert.False(summaries.HasCriticalValidationErrors);
Assert.DoesNotContain(summaries.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(NotEmptyBenchmark)));
Assert.DoesNotContain(GetValidationErrorForType(typeof(NotEmptyBenchmark)), logger.GetLog());
@@ -131,7 +131,7 @@ public void TypesWithoutBenchmarkAttribute_ThrowsValidationError_WhenNoBenchmark
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run([typeof(EmptyBenchmark), typeof(EmptyBenchmark2)], config, args);
+ var summaries = BenchmarkRunner.Run([typeof(EmptyBenchmark), typeof(EmptyBenchmark2)], config, args, TestContext.Current.CancellationToken);
if (args != null)
{
Assert.Contains(GetValidationErrorForType(typeof(EmptyBenchmark)), logger.GetLog());
@@ -157,7 +157,7 @@ public void TypesWithBenchmarkAttribute_RunsSuccessfully(string[]? args)
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run([typeof(NotEmptyBenchmark)], config, args);
+ var summaries = BenchmarkRunner.Run([typeof(NotEmptyBenchmark)], config, args, TestContext.Current.CancellationToken);
var summary = summaries[0];
Assert.False(summary.HasCriticalValidationErrors);
Assert.DoesNotContain(summary.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(NotEmptyBenchmark)));
@@ -173,7 +173,7 @@ public void BenchmarkRunInfoWithoutBenchmarkAttribute_ThrowsValidationError_When
{
GetConfigWithLogger(out var logger, out var config);
- var summary = BenchmarkRunner.Run(BenchmarkConverter.TypeToBenchmarks(typeof(EmptyBenchmark), config));
+ var summary = BenchmarkRunner.Run(BenchmarkConverter.TypeToBenchmarks(typeof(EmptyBenchmark), config), TestContext.Current.CancellationToken);
Assert.True(summary.HasCriticalValidationErrors);
Assert.Contains(summary.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(EmptyBenchmark)));
Assert.Contains(GetValidationErrorForType(typeof(EmptyBenchmark)), logger.GetLog());
@@ -184,7 +184,7 @@ public void BenchmarkRunInfoWithBenchmarkAttribute_RunsSuccessfully()
{
GetConfigWithLogger(out var logger, out var config);
- var summary = BenchmarkRunner.Run(BenchmarkConverter.TypeToBenchmarks(typeof(NotEmptyBenchmark), config));
+ var summary = BenchmarkRunner.Run(BenchmarkConverter.TypeToBenchmarks(typeof(NotEmptyBenchmark), config), TestContext.Current.CancellationToken);
Assert.False(summary.HasCriticalValidationErrors);
Assert.DoesNotContain(summary.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(EmptyBenchmark)));
Assert.DoesNotContain(GetValidationErrorForType(typeof(NotEmptyBenchmark)), logger.GetLog());
@@ -201,7 +201,7 @@ public void BenchmarkRunInfosWithoutBenchmarkAttribute_ThrowsValidationError_Whe
var summaries = BenchmarkRunner.Run([
BenchmarkConverter.TypeToBenchmarks(typeof(EmptyBenchmark), config),
BenchmarkConverter.TypeToBenchmarks(typeof(EmptyBenchmark2), config)
- ]);
+ ], TestContext.Current.CancellationToken);
var summary = summaries[0];
Assert.True(summary.HasCriticalValidationErrors);
Assert.Contains(summary.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(EmptyBenchmark)));
@@ -215,7 +215,7 @@ public void BenchmarkRunInfosWithBenchmarkAttribute_RunsSuccessfully()
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run([BenchmarkConverter.TypeToBenchmarks(typeof(NotEmptyBenchmark), config)]);
+ var summaries = BenchmarkRunner.Run([BenchmarkConverter.TypeToBenchmarks(typeof(NotEmptyBenchmark), config)], TestContext.Current.CancellationToken);
var summary = summaries[0];
Assert.False(summary.HasCriticalValidationErrors);
Assert.DoesNotContain(summary.ValidationErrors, validationError => validationError.Message == GetValidationErrorForType(typeof(NotEmptyBenchmark)));
@@ -231,7 +231,7 @@ public void MixedTypes_ThrowsValidationError_WhenNoBenchmarkAttribute(string[]?
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run([typeof(EmptyBenchmark), typeof(NotEmptyBenchmark)], config, args);
+ var summaries = BenchmarkRunner.Run([typeof(EmptyBenchmark), typeof(NotEmptyBenchmark)], config, args, TestContext.Current.CancellationToken);
if (args != null)
{
Assert.Contains(GetExpandedValidationErrorForType(typeof(EmptyBenchmark)), logger.GetLog());
@@ -266,12 +266,12 @@ public void AssemblyWithoutBenchmarks_ThrowsValidationError_WhenNoBenchmarksFoun
if (args != null)
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run(assemblyBuilder, config, args);
+ var summaries = BenchmarkRunner.Run(assemblyBuilder, config, args, TestContext.Current.CancellationToken);
Assert.Contains(GetAssemblylValidationError(assemblyBuilder), logger.GetLog());
}
else
{
- var summaries = BenchmarkRunner.Run(assemblyBuilder, null, args);
+ var summaries = BenchmarkRunner.Run(assemblyBuilder, null, args, TestContext.Current.CancellationToken);
var summary = summaries[0];
Assert.True(summary.HasCriticalValidationErrors);
Assert.Contains(summary.ValidationErrors, validationError => validationError.Message == GetGeneralValidationError());
@@ -312,12 +312,12 @@ public void AssemblyWithBenchmarks_RunsSuccessfully_WhenBenchmarkAttributePresen
if (args != null)
{
GetConfigWithLogger(out var logger, out var config);
- var summaries = BenchmarkRunner.Run(assemblyBuilder, config, args);
+ var summaries = BenchmarkRunner.Run(assemblyBuilder, config, args, cancellationToken: TestContext.Current.CancellationToken);
Assert.DoesNotContain(GetAssemblylValidationError(assemblyBuilder), logger.GetLog());
}
else
{
- var summaries = BenchmarkRunner.Run(assemblyBuilder);
+ var summaries = BenchmarkRunner.Run(assemblyBuilder, cancellationToken: TestContext.Current.CancellationToken);
var summary = summaries[0];
Assert.False(summary.HasCriticalValidationErrors);
Assert.DoesNotContain(summary.ValidationErrors, validationError => validationError.Message == GetGeneralValidationError());
@@ -352,7 +352,7 @@ public void AssemblyWithBenchmarks_RunsNothing_WhenAllBenchmarksFilteredOutFromO
config.AddFilter(new NameFilter(name => name != "Benchmark")); // Filter out only benchmark method on MockBenchmark
- var summaries = BenchmarkRunner.Run(assemblyBuilder, config);
+ var summaries = BenchmarkRunner.Run(assemblyBuilder, config, cancellationToken: TestContext.Current.CancellationToken);
Assert.DoesNotContain(GetValidationErrorForType(benchmarkTypeBuilder), logger.GetLog());
Assert.Contains(GetExporterNoBenchmarksError(), logger.GetLog());
}
diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs
index e3413c5e4a..63516ba74c 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs
@@ -1,11 +1,11 @@
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
-using BenchmarkDotNet.IntegrationTests.Xunit;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Tests.Loggers;
+using Xunit;
namespace BenchmarkDotNet.IntegrationTests
{
@@ -42,7 +42,7 @@ public Summary CanExecute(IConfig? config = null, bool fullValidatio
public Summary CanExecute(Type type, IConfig? config = null, bool fullValidation = true)
{
// Make sure we ALWAYS combine the Config (default or passed in) with any Config applied to the Type/Class
- var summary = BenchmarkRunner.Run(type, GetMinimalConfig(config));
+ var summary = BenchmarkRunner.Run(type, GetMinimalConfig(config), cancellationToken: TestContext.Current.CancellationToken);
if (fullValidation)
{
@@ -58,7 +58,7 @@ public ValueTask CanExecuteAsync(IConfig? config = null, bo
public async ValueTask CanExecuteAsync(Type type, IConfig? config = null, bool fullValidation = true)
{
// Make sure we ALWAYS combine the Config (default or passed in) with any Config applied to the Type/Class
- var summary = await BenchmarkRunner.RunAsync(type, GetMinimalConfig(config));
+ var summary = await BenchmarkRunner.RunAsync(type, GetMinimalConfig(config), cancellationToken: TestContext.Current.CancellationToken);
if (fullValidation)
{
@@ -76,8 +76,6 @@ private IConfig GetMinimalConfig(IConfig? config)
if (!config.GetLoggers().OfType().Any())
config = config.AddLogger(Output != null ? new OutputLogger(Output) : ConsoleLogger.Default);
- if (!config.GetLoggers().OfType().Any())
- config = config.AddLogger(ConsoleLogger.Default);
if (!config.GetColumnProviders().Any())
config = config.AddColumnProvider(DefaultColumnProviders.Instance);
diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs
index e6f27f54eb..bbee466722 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs
@@ -1,6 +1,6 @@
using BenchmarkDotNet.Reports;
-namespace BenchmarkDotNet.IntegrationTests.Xunit
+namespace BenchmarkDotNet.IntegrationTests
{
public static class Extensions
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs
index 8f5d236d9f..c397c9e339 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs
@@ -1,4 +1,4 @@
-namespace BenchmarkDotNet.IntegrationTests.Xunit
+namespace BenchmarkDotNet.IntegrationTests
{
public class MisconfiguredEnvironmentException : Exception
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs
index c224cbd47f..8d34d90724 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs
@@ -11,6 +11,7 @@
using BenchmarkDotNet.Tests.XUnit;
using System.Collections.Generic;
using System.Linq;
+using Xunit;
namespace BenchmarkDotNet.IntegrationTests
{
diff --git a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs
index 2febff5c9e..84e5644530 100644
--- a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs
+++ b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs
@@ -45,7 +45,7 @@ public void CompletedWorkItemCountIsAccurate(IToolchain toolchain)
{
var config = CreateConfig(toolchain);
- var summary = BenchmarkRunner.Run(config);
+ var summary = BenchmarkRunner.Run(config, cancellationToken: TestContext.Current.CancellationToken);
try
{
summary.CheckPlatformLinkerIssues();
@@ -87,7 +87,7 @@ public void LockContentionCountIsAccurate(IToolchain toolchain)
{
var config = CreateConfig(toolchain);
- var summary = BenchmarkRunner.Run(config);
+ var summary = BenchmarkRunner.Run(config, cancellationToken: TestContext.Current.CancellationToken);
try
{
summary.CheckPlatformLinkerIssues();
@@ -185,10 +185,6 @@ private void AssertStats(Summary summary, IToolchain toolchain, Dictionary
BenchmarkDotNet.Tests
- net10.0;net472
+ net8.0;net10.0;net472
+ Exe
BenchmarkDotNet.Tests
BenchmarkDotNet.Tests
true
@@ -11,7 +12,6 @@
-
@@ -19,14 +19,9 @@
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
+
@@ -35,9 +30,6 @@
-
-
-
diff --git a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/CpuInfoParserTests_Cim.cs b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/CpuInfoParserTests_Cim.cs
index 1b6a6ada95..1e6ed0d7bc 100644
--- a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/CpuInfoParserTests_Cim.cs
+++ b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/CpuInfoParserTests_Cim.cs
@@ -34,13 +34,13 @@ public void RealTwoProcessorEightCoresTest()
Name:Intel(R) Xeon(R) CPU E5-2630 v3
NumberOfCores:8
NumberOfLogicalProcessors:16
-
-
+
+
MaxClockSpeed:2400
Name:Intel(R) Xeon(R) CPU E5-2630 v3
NumberOfCores:8
NumberOfLogicalProcessors:16
-
+
""";
CpuInfo? actual = CpuInfoParser.ParseCimOutput(cpuInfo);
diff --git a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs
index 393bd2798b..e907ffa9aa 100644
--- a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs
+++ b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs
@@ -138,7 +138,7 @@ public void AmdRyzen9_7950X()
CPU max MHz: 5881.0000
CPU min MHz: 400.0000
BogoMIPS: 8983.23
- Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl
+ Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl
pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb
bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512
cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean
diff --git a/tests/BenchmarkDotNet.Tests/Exporters/CommonExporterVerifyTests.cs b/tests/BenchmarkDotNet.Tests/Exporters/CommonExporterVerifyTests.cs
index 2b2c446eb0..b102fa339d 100644
--- a/tests/BenchmarkDotNet.Tests/Exporters/CommonExporterVerifyTests.cs
+++ b/tests/BenchmarkDotNet.Tests/Exporters/CommonExporterVerifyTests.cs
@@ -58,9 +58,11 @@ [new Metric(new FakeMetricDescriptor("CacheMisses", "Hardware counter 'CacheMiss
logger, CancellationToken.None);
}
+ var result = logger.GetLog().Replace("\r\n", "\n");
+
var settings = VerifyHelper.Create();
settings.UseTextForParameters(GetName(cultureInfo));
- await Verifier.Verify(logger.GetLog(), settings);
+ await Verifier.Verify(result, settings);
}
private static void PrintTitle(AccumulationLogger logger, IExporter exporter)
diff --git a/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_Invariant.verified.txt b/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_Invariant.verified.txt
index 7b0a36970f..08a5fe76dc 100644
--- a/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_Invariant.verified.txt
+++ b/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_Invariant.verified.txt
@@ -27,10 +27,10 @@ HtmlExporter
MockSummary
diff --git a/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_en-US.verified.txt b/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_en-US.verified.txt
index 7b0a36970f..08a5fe76dc 100644
--- a/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_en-US.verified.txt
+++ b/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_en-US.verified.txt
@@ -27,10 +27,10 @@ HtmlExporter
MockSummary
diff --git a/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_ru-RU.verified.txt b/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_ru-RU.verified.txt
index 7b0a36970f..08a5fe76dc 100644
--- a/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_ru-RU.verified.txt
+++ b/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles/CommonExporterVerifyTests.Exporters_ru-RU.verified.txt
@@ -27,10 +27,10 @@ HtmlExporter
MockSummary
diff --git a/tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs b/tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs
index 81d35e488d..e8e6449f7b 100644
--- a/tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs
+++ b/tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs
@@ -24,7 +24,7 @@ public Task PerfonarTableTest(string key)
{
var table = TableDataMap[key];
string markdown = table.ToMarkdown(new PerfonarTableStyle());
- string json = LightJsonSerializer.Serialize(table.RootEntry, new LightJsonSettings { Indent = true });
+ string json = LightJsonSerializer.Serialize(table.RootEntry, new LightJsonSettings { Indent = true, NewLine = "\n" });
return VerifyString(key, markdown + "\n" + json);
}
diff --git a/tests/BenchmarkDotNet.Tests/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.Tests/Properties/AssemblyInfo.cs
index 6d531ab196..7f3f80e5ef 100644
--- a/tests/BenchmarkDotNet.Tests/Properties/AssemblyInfo.cs
+++ b/tests/BenchmarkDotNet.Tests/Properties/AssemblyInfo.cs
@@ -1,3 +1,5 @@
using System.Runtime.InteropServices;
[assembly: Guid("16c47abf-43e0-4db4-8151-36ca7a4082ae")]
+
+[assembly: CaptureConsole]
diff --git a/tests/BenchmarkDotNet.Tests/Properties/launchSettings.json b/tests/BenchmarkDotNet.Tests/Properties/launchSettings.json
new file mode 100644
index 0000000000..70ba352178
--- /dev/null
+++ b/tests/BenchmarkDotNet.Tests/Properties/launchSettings.json
@@ -0,0 +1,24 @@
+{
+ "profiles": {
+ "Default": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "Run filtered tests": {
+ "commandName": "Project",
+ "commandLineArgs": "--filter ConfigParserTests --output Detailed"
+ },
+ "--list-test json": {
+ "commandName": "Project",
+ "commandLineArgs": "--list-test json"
+ },
+ "--info": {
+ "commandName": "Project",
+ "commandLineArgs": "--info"
+ },
+ "--help": {
+ "commandName": "Project",
+ "commandLineArgs": "--help"
+ }
+ }
+}
diff --git a/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs b/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs
index 2a83781f14..e9020d6e24 100644
--- a/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs
+++ b/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs
@@ -1,5 +1,6 @@
using BenchmarkDotNet.Loggers;
using System.Runtime.CompilerServices;
+using Xunit;
namespace BenchmarkDotNet.Tests.Loggers
{
diff --git a/tests/BenchmarkDotNet.Tests/Shared/Mocks/MockRunner.cs b/tests/BenchmarkDotNet.Tests/Shared/Mocks/MockRunner.cs
index b5d9788ef2..a11c50eeac 100644
--- a/tests/BenchmarkDotNet.Tests/Shared/Mocks/MockRunner.cs
+++ b/tests/BenchmarkDotNet.Tests/Shared/Mocks/MockRunner.cs
@@ -33,7 +33,7 @@ public static Summary Run(ITestOutputHelper output, Func(config);
+ var summary = BenchmarkRunner.Run(config, cancellationToken: TestContext.Current.CancellationToken);
var exporter = MarkdownExporter.Mock;
((ExporterBase)exporter).ExportToLogAsync(summary, logger, CancellationToken.None).AsTask().GetAwaiter().GetResult();
diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/SmartAssert.cs b/tests/BenchmarkDotNet.Tests/Shared/SmartAssert.cs
similarity index 96%
rename from tests/BenchmarkDotNet.Tests/Shared/XUnit/SmartAssert.cs
rename to tests/BenchmarkDotNet.Tests/Shared/SmartAssert.cs
index 3cbe6b3f82..c1cad4e86a 100644
--- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/SmartAssert.cs
+++ b/tests/BenchmarkDotNet.Tests/Shared/SmartAssert.cs
@@ -1,6 +1,6 @@
using System.Text;
-namespace BenchmarkDotNet.Tests.XUnit
+namespace BenchmarkDotNet.Tests
{
public static class SmartAssert
{
diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs
index 6c57f08078..a0e02d4c07 100644
--- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs
+++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs
@@ -1,3 +1,5 @@
+using System.Runtime.CompilerServices;
+using Xunit;
namespace BenchmarkDotNet.Tests.XUnit;
@@ -14,4 +16,9 @@ public FactEnvSpecificAttribute(string reason, params EnvRequirement[] requireme
if (skip != null)
Skip = $"{skip} ({reason})";
}
+
+ public FactEnvSpecificAttribute([CallerFilePath] string? sourceFilePath = null, [CallerLineNumber] int sourceLineNumber = -1)
+ : base(sourceFilePath, sourceLineNumber)
+ {
+ }
}
\ No newline at end of file
diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs
index 65acf07295..8f9419f5c0 100644
--- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs
+++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs
@@ -1,24 +1,53 @@
using System.Reflection;
+using Xunit;
using Xunit.Sdk;
+using Xunit.v3;
namespace BenchmarkDotNet.Tests.XUnit;
-[DataDiscoverer("BenchmarkDotNet.Tests.XUnit.InlineDataEnvSpecificDiscoverer", "BenchmarkDotNet.IntegrationTests")]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class InlineDataEnvSpecific : DataAttribute
{
- readonly object[] data;
+ ///
+ /// Gets the data to be passed to the test.
+ ///
+ // If the user passes null to the constructor, we assume what they meant was a
+ // single null value to be passed to the test.
+ public object?[] Data { get; }
- public InlineDataEnvSpecific(object data, string reason, params EnvRequirement[] requirements)
+ public InlineDataEnvSpecific(object? data, string reason, params EnvRequirement[] requirements)
: this([data], reason, requirements) { }
- public InlineDataEnvSpecific(object[] data, string reason, params EnvRequirement[] requirements)
+ public InlineDataEnvSpecific(object?[] data, string reason, params EnvRequirement[] requirements)
{
- this.data = data;
+ // If the user passes null to the constructor, we assume what they meant was a
+ // single null value to be passed to the test.
+ Data = data ?? [null];
string? skip = EnvRequirementChecker.GetSkip(requirements);
if (skip != null)
Skip = $"{skip} ({reason})";
}
- public override IEnumerable GetData(MethodInfo testMethod) => [data];
+ public override ValueTask> GetData(
+ MethodInfo testMethod,
+ DisposalTracker disposalTracker)
+ {
+ var traits = new Dictionary>(StringComparer.OrdinalIgnoreCase);
+ TestIntrospectionHelper.MergeTraitsInto(traits, Traits);
+
+ return new([
+ new TheoryDataRow(Data)
+ {
+ Explicit = ExplicitAsNullable,
+ Label = Label,
+ Skip = Skip,
+ TestDisplayName = TestDisplayName,
+ Timeout = TimeoutAsNullable,
+ Traits = traits,
+ }
+ ]);
+ }
+
+ public override bool SupportsDiscoveryEnumeration()
+ => true;
}
diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs
deleted file mode 100644
index dba7caa4c2..0000000000
--- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using Xunit.Sdk;
-
-namespace BenchmarkDotNet.Tests.XUnit;
-
-public class InlineDataEnvSpecificDiscoverer : IDataDiscoverer
-{
- public IEnumerable GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod)
- {
- // InlineDataEnvSpecific has two constructors:
- // 1. InlineDataEnvSpecific(object data, string reason, params EnvRequirement[] requirements)
- // 2. InlineDataEnvSpecific(object[] data, string reason, params EnvRequirement[] requirements)
- // GetConstructorArguments returns arguments from the constructor that was actually called
-
- var args = dataAttribute.GetConstructorArguments().ToArray();
- if (args.Length == 0)
- yield break;
-
- // First argument is either a single object or object[] - wrap accordingly
- if (args[0] is object[] dataArray)
- {
- // Array constructor was used
- yield return dataArray;
- }
- else
- {
- // Single object constructor was used - wrap in array
- yield return new[] { args[0] };
- }
- }
-
- public bool SupportsDiscoveryEnumeration(IAttributeInfo dataAttribute, IMethodInfo testMethod) => true;
-}
diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs
index 3303797884..92f039f030 100644
--- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs
+++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs
@@ -1,3 +1,5 @@
+using System.Runtime.CompilerServices;
+using Xunit;
namespace BenchmarkDotNet.Tests.XUnit;
@@ -14,4 +16,9 @@ public TheoryEnvSpecificAttribute(string reason, params EnvRequirement[] require
if (skip != null)
Skip = $"{skip} ({reason})";
}
+
+ public TheoryEnvSpecificAttribute([CallerFilePath] string? sourceFilePath = null, [CallerLineNumber] int sourceLineNumber = -1)
+ : base(sourceFilePath, sourceLineNumber)
+ {
+ }
}
\ No newline at end of file
diff --git a/tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTestscs.cs b/tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTests.cs
similarity index 100%
rename from tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTestscs.cs
rename to tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTests.cs
diff --git a/tests/BenchmarkDotNet.Tests/testconfig.json b/tests/BenchmarkDotNet.Tests/testconfig.json
new file mode 100644
index 0000000000..9d8a9fd932
--- /dev/null
+++ b/tests/BenchmarkDotNet.Tests/testconfig.json
@@ -0,0 +1,15 @@
+{
+ "commandLineOptions": {
+ "report-xunit-html": true,
+ "report-xunit-trx": true
+ },
+ "platformOptions": {
+ },
+ "environmentVariables": {
+ "DOTNET_CLI_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true",
+ "TESTINGPLATFORM_UI_LANGUAGE": "en-us"
+ },
+ "xUnit": {
+ }
+}
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
index 5ae2fbba84..f884b70545 100644
--- a/tests/Directory.Build.props
+++ b/tests/Directory.Build.props
@@ -10,6 +10,10 @@
$([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory)))
+
+ true
+
+
diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets
index 100d75c087..035273019a 100644
--- a/tests/Directory.Build.targets
+++ b/tests/Directory.Build.targets
@@ -1,4 +1,25 @@
+
+
+ true
+
+
+
+
+ false
+ false
+
+
+
+
+
+
+
+
+