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..40a43ea345 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 f9557849db..d1eb909584 100644
--- a/BenchmarkDotNet.slnx
+++ b/BenchmarkDotNet.slnx
@@ -29,6 +29,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/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 106cb36a78..aef5e9e09f 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs
@@ -633,7 +633,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
@@ -1188,7 +1188,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 fc7455faa8..fd544e0731 100644
--- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs
+++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs
@@ -1,4 +1,4 @@
-using BenchmarkDotNet.Analyzers;
+using BenchmarkDotNet.Analyzers;
using BenchmarkDotNet.Analyzers.Attributes;
using BenchmarkDotNet.Analyzers.Tests.Fixtures;
using Microsoft.CodeAnalysis;
@@ -191,7 +191,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;
@@ -353,7 +353,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;
@@ -512,21 +512,19 @@ public static IEnumerable