From c2eae691e789ee4a3a6764d7ca2faddcab030978 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:43:10 +0900 Subject: [PATCH 01/40] chore: update xunit related package version to v3 with mtp v2 --- .../Runners/UnitTestRunner.cs | 11 ++++++++++- .../BenchmarkDotNet.Analyzers.Tests.csproj | 17 +++++++---------- .../Fixtures/Serializable/ValueTupleDouble.cs | 2 -- .../Fixtures/Serializable/ValueTupleTriple.cs | 4 +--- ...chmarkDotNet.Exporters.Plotting.Tests.csproj | 9 ++------- .../ScottPlotExporterTests.cs | 3 +++ ...et.IntegrationTests.ConfigPerAssembly.csproj | 2 +- ...ntegrationTests.DisabledOptimizations.csproj | 4 ++-- ...IntegrationTests.EnabledOptimizations.csproj | 4 ++-- ...nchmarkDotNet.IntegrationTests.FSharp.fsproj | 2 +- ...ests.ManualRunning.MultipleFrameworks.csproj | 12 ++++-------- ...DotNet.IntegrationTests.ManualRunning.csproj | 10 ++-------- .../DotMemoryTests.cs | 1 + .../DotTraceTests.cs | 1 + .../MsBuildArgumentTests.cs | 1 + .../AsyncBenchmarksTests.cs | 4 ---- .../BenchmarkDotNet.IntegrationTests.csproj | 15 ++++++--------- .../CopyToOutputTests.cs | 1 + .../CustomBuildConfigurationTests.cs | 4 +--- .../GcModeTests.cs | 3 ++- .../InProcessTest.cs | 1 - .../MemoryDiagnoserTests.cs | 0 .../ReferencesTests.cs | 1 - .../Shared/BenchmarkTestExecutor.cs | 1 + .../TailCallDiagnoserTests.cs | 1 + .../WasmTests.cs | 2 +- .../BenchmarkDotNet.Tests.csproj | 16 ++++------------ .../Detectors/Cpu/CpuInfoParserTests_Cim.cs | 6 +++--- .../Detectors/Cpu/LinuxCpuInfoParserTests.cs | 2 +- .../Shared/Loggers/OutputLogger.cs | 1 + .../Shared/XUnit/InlineDataEnvSpecific.cs | 1 + .../XUnit/InlineDataEnvSpecificDiscoverer.cs | 1 + tests/Directory.Build.props | 4 ++++ 33 files changed, 66 insertions(+), 81 deletions(-) mode change 100755 => 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj mode change 100755 => 100644 tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs mode change 100755 => 100644 tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index ab3833d129..f06f9b3132 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -44,7 +44,16 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf EnvironmentVariables = { ["Platform"] = "" // force the tool to not look for the .dll in platform-specific directory - } + }, + PathType = DotNetTestPathType.Auto, + ArgumentCustomization = args + => args.Append("--report-xunit-trx") + .AppendSwitchQuoted("--report-xunit-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) + .Append("--no-ansi") + .AppendSwitch("--output", "Detailed") + .AppendSwitch("--show-stdout", "Failed") + .Append("--diagnostic") + .AppendSwitch("--diagnostic-verbosity", "Trace") }; return settings; } diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj b/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj index 86e2e79393..e4a5128855 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj +++ b/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj @@ -1,6 +1,7 @@  + Exe BenchmarkDotNet.Analyzers.Tests net472;net10.0 true @@ -11,7 +12,6 @@ - @@ -19,14 +19,11 @@ - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + @@ -35,4 +32,4 @@ - \ 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..4802092df4 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs @@ -1,5 +1,3 @@ -using Xunit.Abstractions; - namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleDouble : IXunitSerializable diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs index 0b19f5c211..7bc8fe044c 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs @@ -1,5 +1,3 @@ -using Xunit.Abstractions; - namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleTriple : IXunitSerializable @@ -29,4 +27,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.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj index 635f19b64c..2c1adf46f2 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 - @@ -18,12 +18,7 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + 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.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj index 9f545920c8..4b567136fd 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 db67eae508..9978b15e5b 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 34d29b0fd8..65f18511e8 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 7c3bb30545..f557b5a3e1 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 @@ -17,7 +18,6 @@ - @@ -37,12 +37,8 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + 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..db77746136 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj @@ -14,7 +14,6 @@ - @@ -24,7 +23,7 @@ $(DefineConstants);$(ExtraDefineConstants) - + @@ -43,12 +42,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/AsyncBenchmarksTests.cs b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs index 566c155c03..8cdc98e683 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs @@ -1,8 +1,4 @@ using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Toolchains; -using BenchmarkDotNet.Toolchains.InProcess.Emit; -using BenchmarkDotNet.Toolchains.InProcess.NoEmit; using System.Threading.Tasks.Sources; namespace BenchmarkDotNet.IntegrationTests diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index 187c1aa7f9..889bcbe092 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -5,6 +5,7 @@ net472;net8.0;net10.0 net8.0;net10.0 + Exe true BenchmarkDotNet.IntegrationTests BenchmarkDotNet.IntegrationTests @@ -21,7 +22,6 @@ - @@ -36,23 +36,20 @@ - - + - + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + 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/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..6cb8cfea15 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 diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs old mode 100755 new mode 100644 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/Shared/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs index e3413c5e4a..795127c130 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs @@ -6,6 +6,7 @@ using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; using BenchmarkDotNet.Tests.Loggers; +using Xunit; namespace BenchmarkDotNet.IntegrationTests { 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/WasmTests.cs b/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs index 940eeb55ea..c7ea008499 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs @@ -98,4 +98,4 @@ public void Check() } } } -} +} \ No newline at end of file diff --git a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj old mode 100755 new mode 100644 index 95662cab69..6aa911790f --- a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj +++ b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj @@ -2,7 +2,8 @@ BenchmarkDotNet.Tests - net10.0;net472 + net8.0;net10.0;net472 + Exe BenchmarkDotNet.Tests BenchmarkDotNet.Tests true @@ -11,7 +12,6 @@ - @@ -20,13 +20,8 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + @@ -41,9 +36,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/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/XUnit/InlineDataEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs index 65acf07295..79a720b6b1 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs @@ -1,5 +1,6 @@ using System.Reflection; using Xunit.Sdk; +using Xunit.v3; namespace BenchmarkDotNet.Tests.XUnit; diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs index dba7caa4c2..a9a73f20a3 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs @@ -1,3 +1,4 @@ +using Xunit; using Xunit.Sdk; namespace BenchmarkDotNet.Tests.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 + + From 942cd3629c190bf40031fb1e35d422828b48c3b8 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:58:34 +0900 Subject: [PATCH 02/40] chore: add using Xunit.Sdk statement for XunitSerializable --- .../Fixtures/Serializable/ValueTupleDouble.cs | 2 ++ .../Fixtures/Serializable/ValueTupleTriple.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs index 4802092df4..56819e9cf2 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs @@ -1,3 +1,5 @@ +using Xunit.Sdk; + namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleDouble : IXunitSerializable diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs index 7bc8fe044c..82b871d3a3 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs @@ -1,3 +1,5 @@ +using Xunit.Sdk; + namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleTriple : IXunitSerializable From 6911467a9e8d2d5d372fa138aa361007a208ac54 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:59:12 +0900 Subject: [PATCH 03/40] chore: fix xUnit3003 analyzer errors --- .../BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs | 7 +++++++ .../Shared/XUnit/TheoryEnvSpecific.cs | 7 +++++++ 2 files changed, 14 insertions(+) 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/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 From 00491de82e2857d809255e85a8d4f645517fda44 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 17:50:12 +0900 Subject: [PATCH 04/40] chore: modify theorydata related incompatible codes --- .../ArgumentsAttributeAnalyzerTests.cs | 4 +- ...GeneralParameterAttributesAnalyzerTests.cs | 42 +++++++++---------- .../ParamsAllValuesAttributeAnalyzerTests.cs | 12 ++---- .../ParamsAttributeAnalyzerTests.cs | 38 +++++++---------- .../BenchmarkRunner/RunAnalyzerTests.cs | 4 +- .../Extensions/TheoryDataExtensions.cs | 2 +- .../AsyncBenchmarksTests.cs | 4 ++ .../AsyncEnumerableBenchmarksTests.cs | 8 ++-- .../CallerThreadTests.cs | 4 +- .../EngineTests.cs | 4 +- .../RunAsyncTests.cs | 4 +- 11 files changed, 56 insertions(+), 70 deletions(-) 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 DuplicateAttributeUsageCountsAndNonPublicCla => CombinationsGenerator.CombineArguments(DuplicateParameterAttributeUsageCounts, NonPublicClassMemberAccessModifiers); public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static IEnumerable<(string AttributeName, string AttributeUsage)> UniqueParameterAttributes - => UniqueParameterAttributesTheoryData.Select(tdr => ((tdr[0] as string)!, (tdr[1] as string)!)); + => UniqueParameterAttributesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2)); public static IEnumerable NonPublicClassMemberAccessModifiers -#pragma warning disable IDE0028 // Simplify collection initialization - => new NonPublicClassMemberAccessModifiersTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new NonPublicClassMemberAccessModifiersTheoryData().Select(x => x.Data); public static IEnumerable<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> DuplicateSameParameterAttributeUsages - => DuplicateSameAttributeUsagesTheoryData.Select(tdr => ((tdr[0] as string)!, (int)tdr[1], (tdr[2] as int[])!)); + => DuplicateSameAttributeUsagesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2, tdr.Data.Item3)); public static IEnumerable DuplicateParameterAttributeUsageCounts - => DuplicateAttributeUsageCountsTheoryData; + => DuplicateAttributeUsageCountsTheoryData.Select(x => x.Data); } public class PropertyMustBePublic : AnalyzerTestFixture @@ -649,18 +647,16 @@ public static IEnumerable DuplicateAttributeUsageCountsAndNonPublicCla => CombinationsGenerator.CombineArguments(DuplicateParameterAttributeUsageCounts, NonPublicClassMemberAccessModifiers); public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static IEnumerable<(string AttributeName, string AttributeUsage)> UniqueParameterAttributes - => UniqueParameterAttributesTheoryData.Select(tdr => ((tdr[0] as string)!, (tdr[1] as string)!)); + => UniqueParameterAttributesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2)); public static IEnumerable NonPublicClassMemberAccessModifiers -#pragma warning disable IDE0028 // Simplify collection initialization - => new NonPublicClassMemberAccessModifiersTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new NonPublicClassMemberAccessModifiersTheoryData().Select(x => x.Data); public static IEnumerable<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> DuplicateSameParameterAttributeUsages - => DuplicateSameAttributeUsagesTheoryData.Select(tdr => ((tdr[0] as string)!, (int)tdr[1], (tdr[2] as int[])!)); + => DuplicateSameAttributeUsagesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2, tdr.Data.Item3)); public static TheoryData DuplicateParameterAttributeUsageCounts => DuplicateAttributeUsageCountsTheoryData; @@ -814,7 +810,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData UniqueParameterAttributes => UniqueParameterAttributesTheoryData; @@ -952,7 +948,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData UniqueParameterAttributes => UniqueParameterAttributesTheoryData; @@ -1114,7 +1110,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData UniqueParameterAttributes => UniqueParameterAttributesTheoryData; @@ -1279,20 +1275,20 @@ public static IEnumerable DuplicateAttributeUsageCountsAndNonPublicPro => CombinationsGenerator.CombineArguments(DuplicateParameterAttributeUsageCounts, NonPublicPropertySetters()); public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static IEnumerable<(string AttributeName, string AttributeUsage)> UniqueParameterAttributes - => UniqueParameterAttributesTheoryData.Select(tdr => ((tdr[0] as string)!, (tdr[1] as string)!)); + => UniqueParameterAttributesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2)); public static IEnumerable<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> DuplicateSameParameterAttributeUsages - => DuplicateSameAttributeUsagesTheoryData.Select(tdr => ((tdr[0] as string)!, (int)tdr[1], (tdr[2] as int[])!)); + => DuplicateSameAttributeUsagesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2, tdr.Data.Item3)); public static TheoryData DuplicateParameterAttributeUsageCounts => DuplicateAttributeUsageCountsTheoryData; public static IEnumerable NonPublicPropertySetters() => new NonPublicPropertySetterAccessModifiersTheoryData() - .Select(m => $"{{ get; {m} set; }}") + .Select(m => $"{{ get; {m.Data} set; }}") .Concat(["{ get; }", "=> 0;"]); public static TheoryData NonPublicPropertySettersTheoryData() @@ -1487,7 +1483,7 @@ private static IEnumerable GenerateDuplicateAttributeUsageCombinations(Th private static ReadOnlyCollection<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> GenerateDuplicateSameAttributeUsageCombinations(TheoryData uniqueAttributeUsages) { var uniqueAttributeUsagesList = uniqueAttributeUsages - .Select(tdr => (tdr[1] as string)!) + .Select(tdr => tdr.Data.Item2) .ToList() .AsReadOnly(); diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs index ce92329620..68fcfcefa4 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs @@ -32,9 +32,7 @@ public class BenchmarkClass } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable InvalidTypes => [ @@ -149,9 +147,7 @@ public class BenchmarkClass } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable NonEnumStructs => [ @@ -249,9 +245,7 @@ public class BenchmarkClass } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable NonEnumOrBoolStructs => [ diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs index 5b2bb6cc86..043972a922 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs @@ -32,9 +32,7 @@ public string {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); } public class MustHaveValues : AnalyzerTestFixture @@ -113,12 +111,10 @@ public string {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static IEnumerable ScalarValuesListLength => Enumerable.Range(1, ScalarValues.Count); @@ -130,7 +126,7 @@ private static ReadOnlyCollection ScalarValues .AsReadOnly(); public static IEnumerable ScalarValuesContainerAttributeArgument - => ScalarValuesContainerAttributeArgumentTheoryData(); + => ScalarValuesContainerAttributeArgumentTheoryData().Select(x => x.Data); public static IEnumerable EmptyParamsAttributeUsagesWithLocationMarker() { @@ -252,7 +248,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 @@ -333,7 +329,7 @@ public async Task Providing_expected_enum_value_type_array_using_not_fully_quali { var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -391,7 +387,7 @@ public async Task Providing_expected_type_using_not_fully_qualified_name_located using BenchmarkDotNet.Attributes; namespace DifferentNamespace; - + public class BenchmarkClass { [{{dummyAttributeUsage}}Params({{string.Format(scalarValuesContainerAttributeArgument, valueAndType.Value1)}})] @@ -415,7 +411,7 @@ public async Task Providing_expected_type_using_not_fully_qualified_name_located { var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -769,7 +765,7 @@ public async Task Providing_an_unexpected_array_value_type_to_params_attribute_s var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -838,12 +834,10 @@ public object[] {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static IEnumerable> IntegerValuesAndTypesWithinTargetTypeRange => [ @@ -967,7 +961,7 @@ public static IEnumerable EmptyValuesAttributeArgument() } public static IEnumerable ScalarValuesContainerAttributeArgumentEnumerable - => ScalarValuesContainerAttributeArgumentTheoryData(); + => ScalarValuesContainerAttributeArgumentTheoryData().Select(x => x.Data); public static IEnumerable ArrayValuesContainerAttributeArgumentEnumerableLocal() { @@ -1208,12 +1202,10 @@ public string {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static IEnumerable ScalarValuesListLength => Enumerable.Range(2, ScalarValues.Count); @@ -1224,7 +1216,7 @@ private static ReadOnlyCollection ScalarValues .ToList() .AsReadOnly(); public static IEnumerable ScalarValuesContainerAttributeArgument - => ScalarValuesContainerAttributeArgumentTheoryData(); + => ScalarValuesContainerAttributeArgumentTheoryData().Select(x => x.Data); public static IEnumerable ScalarValuesContainerAttributeArgumentWithLocationMarker() { diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs index 458e8bd326..f50cbeaf8b 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs @@ -61,7 +61,7 @@ public async Task Invoking_with_type_argument_class_having_at_least_one_public_m var testCode = /* lang=c#-test */ $$""" using BenchmarkDotNet.Running; - + public class Program { public static void Main(string[] args) { @@ -548,7 +548,7 @@ public void BenchmarkMethod() } public static IEnumerable NonPublicClassAccessModifiersExceptFile - => new NonPublicClassAccessModifiersTheoryData().Where(m => m != "file "); + => new NonPublicClassAccessModifiersTheoryData().Where(m => m.Data != "file ").Select(x => x.Data); } public class TypeArgumentClassMustBeUnsealed : AnalyzerTestFixture 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.IntegrationTests/AsyncBenchmarksTests.cs b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs index 8cdc98e683..566c155c03 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs @@ -1,4 +1,8 @@ using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Toolchains; +using BenchmarkDotNet.Toolchains.InProcess.Emit; +using BenchmarkDotNet.Toolchains.InProcess.NoEmit; using System.Threading.Tasks.Sources; 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/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/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/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)] From e1a18c242898a5df0f347fd45f67abc0f0373c19 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Mar 2026 03:52:23 +0900 Subject: [PATCH 05/40] chore: add global.json to use Microsoft.Testing.Platform by dotnet test --- global.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 global.json 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" + } +} From 1147c2ec8cd2f6ca6f9d7a5bda32c3827e3de562 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Mar 2026 11:39:03 +0900 Subject: [PATCH 06/40] chore: add tests/.editorconfig --- BenchmarkDotNet.slnx | 1 + tests/.editorconfig | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 tests/.editorconfig diff --git a/BenchmarkDotNet.slnx b/BenchmarkDotNet.slnx index df9599c179..dcc69f5580 100644 --- a/BenchmarkDotNet.slnx +++ b/BenchmarkDotNet.slnx @@ -28,6 +28,7 @@ + diff --git a/tests/.editorconfig b/tests/.editorconfig new file mode 100644 index 0000000000..64a64c01c8 --- /dev/null +++ b/tests/.editorconfig @@ -0,0 +1,7 @@ +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 + From 1edee5f80e50b2976d66241d05e59bedb37823b4 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Mar 2026 19:51:06 +0900 Subject: [PATCH 07/40] chore: fix custom inlinedata attribute --- .../Shared/XUnit/InlineDataEnvSpecific.cs | 40 ++++++++++++++++--- .../XUnit/InlineDataEnvSpecificDiscoverer.cs | 33 --------------- 2 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs index 79a720b6b1..8f9419f5c0 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs @@ -1,25 +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 a9a73f20a3..0000000000 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Xunit; -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; -} From d4b513b05dd4c7a83de58f74795cec292d1ca298 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:40:06 +0900 Subject: [PATCH 08/40] chore: fix wasm related tests chore: fix wasm related tests --- tests/Directory.Build.targets | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 100d75c087..c08869ed02 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -1,4 +1,14 @@ + + + + + + + From 7760b3b163d158005040b6a104b2684cc9e3f48f Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 14:04:09 +0900 Subject: [PATCH 09/40] chore: suppress MSB3277 warnings --- .../BenchmarkDotNet.IntegrationTests.ManualRunning.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj index db77746136..7641efa817 100644 --- 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 From 20aa49c9baad96a0e5e877487422dc817341fe54 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:35:29 +0900 Subject: [PATCH 10/40] chore: migrate multipleframeworks tests to tunit --- ...ts.ManualRunning.MultipleFrameworks.csproj | 10 +- .../MultipleFrameworksTest.cs | 15 ++- .../Properties/AssemblyInfo.cs | 5 + .../ModuleInitializerAttribute.cs | 11 +++ .../Shared/TUnit/BenchmarkTestExecutor.cs | 93 +++++++++++++++++++ .../Shared/TUnit/OutputLogger.cs | 39 ++++++++ ...tNet.IntegrationTests.ManualRunning.csproj | 8 +- .../AllSetupAndCleanupTest.cs | 2 +- .../Shared/BenchmarkTestExecutor.cs | 1 - .../Shared/Extensions.cs | 2 +- .../MisconfiguredEnvironmentException.cs | 2 +- .../Shared/{XUnit => }/SmartAssert.cs | 2 +- 12 files changed, 167 insertions(+), 23 deletions(-) create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs rename tests/BenchmarkDotNet.Tests/Shared/{XUnit => }/SmartAssert.cs (96%) 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 f557b5a3e1..28f43dd0c2 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj @@ -17,12 +17,10 @@ true - - - - - - + + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs index 9cc9ffeae0..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.Net461)] - [InlineData(RuntimeMoniker.Net48)] - [InlineData(RuntimeMoniker.NetCoreApp20)] - [InlineData(RuntimeMoniker.Net80)] + [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/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/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj index 7641efa817..eea825a7d2 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj @@ -28,9 +28,11 @@ - - - + + + + + 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/Shared/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs index 795127c130..b608fdc1ec 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs @@ -1,6 +1,5 @@ using BenchmarkDotNet.Columns; using BenchmarkDotNet.Configs; -using BenchmarkDotNet.IntegrationTests.Xunit; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Reports; 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.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 { From 79bf33b7bca8b6b3a3d8e507655740e7c8c8a1c4 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 14:27:35 +0900 Subject: [PATCH 11/40] chore: update build project to support mtp --- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index f06f9b3132..2e6e2bbbd5 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -2,7 +2,9 @@ using Cake.Common.Diagnostics; using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNet.Test; +using Cake.Core; using Cake.Core.IO; +using System.Linq; using System.Runtime.InteropServices; namespace BenchmarkDotNet.Build.Runners; @@ -40,7 +42,6 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf 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 From 8cc49ca4d0e0aa26b6a804775ecb753454301055 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 19:54:40 +0900 Subject: [PATCH 12/40] chore: suppress auto-entrypoint generation of benchmark project templates --- src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt | 2 +- src/BenchmarkDotNet/Templates/WasmCsProj.txt | 4 +++- src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt b/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt index 248d17329a..c17290d7cf 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 8542f55eb9..9d2c29aa6c 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')) @@ -26,6 +26,8 @@ $CORECLR_OVERRIDES$ true BenchmarkDotNet.Autogenerated.UniqueProgramName + + false diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs index 9280c553ef..125a28cb1a 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 true false + false true {ilcOptimizationPreference} {ilcOptimizationPreference} From aa02e74329178f28db397557195b52f8120df3ce Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:03:05 +0900 Subject: [PATCH 13/40] chore: fix run-tests-selected workflow --- .github/workflows/run-tests-selected.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests-selected.yaml b/.github/workflows/run-tests-selected.yaml index 0e2f436810..688df34ea4 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 Write-Output '##[endgroup]' } From 42f11f66b3b540f7a0fd7448eeff48482a86cc3a Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Fri, 3 Apr 2026 15:02:10 +0900 Subject: [PATCH 14/40] chore: add PreferNativeArm64 setting to Directory.Build.targets --- tests/Directory.Build.targets | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index c08869ed02..f4df154447 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -1,4 +1,9 @@ + + + true + + Date: Mon, 6 Apr 2026 09:58:19 +0900 Subject: [PATCH 15/40] chore: cleanup compile item references and file name --- ...ionParsingTestscs.cs => TargetFrameworkVersionParsingTests.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/BenchmarkDotNet.Tests/{TargetFrameworkVersionParsingTestscs.cs => TargetFrameworkVersionParsingTests.cs} (100%) 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 From 98cda7854a00a8152c82a1eb482a049e34db8725 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:14:17 +0900 Subject: [PATCH 16/40] chore: add diagnostic logs and collect as artifacts --- .github/workflows/run-tests.yaml | 16 ++++++++++++---- .../Runners/UnitTestRunner.cs | 12 ++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) 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/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index 2e6e2bbbd5..c7c5caa1d8 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -49,12 +49,12 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf PathType = DotNetTestPathType.Auto, ArgumentCustomization = args => args.Append("--report-xunit-trx") - .AppendSwitchQuoted("--report-xunit-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) - .Append("--no-ansi") - .AppendSwitch("--output", "Detailed") - .AppendSwitch("--show-stdout", "Failed") - .Append("--diagnostic") - .AppendSwitch("--diagnostic-verbosity", "Trace") + .AppendSwitchQuoted("--report-xunit-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) + .Append("--no-ansi") + .AppendSwitch("--output", "Detailed") + .AppendSwitch("--show-stdout", "Failed") + .Append("--diagnostic") + .AppendSwitch("--diagnostic-verbosity", "Trace") }; return settings; } From 6a87b3197337fe50c92e99e6d607c0eac7ecf0b4 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:41:00 +0900 Subject: [PATCH 17/40] chore: update generate-coverage-report.yaml --- .../workflows/generate-coverage-report.yaml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/generate-coverage-report.yaml b/.github/workflows/generate-coverage-report.yaml index 9656efd86e..c689cb4ce3 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" + dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net10.0" - 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" - 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" + dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net472" - - 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 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)/(!*WasmIsSupported)&(!*WasmSupportsInProcessDiagnosers)"' - name: Shutdown dotnet-coverage server. run: dotnet coverage shutdown bdn_coverage --timeout 60000 From 2868d0172cbe55ce81a50cf334461f2a9a60bea2 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:37:56 +0900 Subject: [PATCH 18/40] chore: temporary skip disassemble tests for macos --- .../DisassemblyDiagnoserTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs index 26720c6c41..89f6e7acbc 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()) + 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)); From 0dea2c684cc6d64523da8f9ebbc094e521d58838 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 9 Apr 2026 09:49:54 +0900 Subject: [PATCH 19/40] chore: add isinprocess condition to skip tests --- .../DisassemblyDiagnoserTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs index 89f6e7acbc..7be2907fed 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs @@ -91,7 +91,7 @@ public void Recursive() [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, IToolchain toolchain) { - if (OsDetector.IsMacOS()) + if (OsDetector.IsMacOS() && toolchain.IsInProcess) Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076"); var disassemblyDiagnoser = new DisassemblyDiagnoser( From ec591b9b2e60a5e8b980562f57d0cf6563ffce9a Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 1 Jun 2026 18:50:15 +0900 Subject: [PATCH 20/40] chore: add consolecapture setting and parallel setting --- .../Properties/AssemblyInfo.cs | 5 +++++ .../Properties/AssemblyInfo.cs | 5 +++++ .../Properties/AssemblyInfo.cs | 6 ++++++ .../Properties/AssemblyInfo.cs | 3 ++- tests/BenchmarkDotNet.Tests/Properties/AssemblyInfo.cs | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/BenchmarkDotNet.Analyzers.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/AssemblyInfo.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs 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.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.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8c41d34c8b --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +using System.Runtime.InteropServices; + +[assembly: Guid("4d7c0994-2750-45dc-bbe8-750b158ea826")] + +[assembly: CaptureConsole] +[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)] diff --git a/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs index b1e42e7c4c..32cfe6b1c7 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs @@ -2,4 +2,5 @@ [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, DisableTestParallelization = true)] 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] From 217365872ccde5a89be0a34d83922f33094f1284 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Wed, 3 Jun 2026 03:53:06 +0900 Subject: [PATCH 21/40] chore: modify test to use dotnet run for simple output --- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index c7c5caa1d8..ada4459bbe 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -1,7 +1,7 @@ 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; @@ -34,9 +34,9 @@ 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 + var settings = new DotNetRunSettings { Configuration = context.BuildConfiguration, Framework = tfm, @@ -46,7 +46,6 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf { ["Platform"] = "" // force the tool to not look for the .dll in platform-specific directory }, - PathType = DotNetTestPathType.Auto, ArgumentCustomization = args => args.Append("--report-xunit-trx") .AppendSwitchQuoted("--report-xunit-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) @@ -68,7 +67,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) From 011e071a3e096f58afecb4fcbe54aec41da8070d Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Wed, 3 Jun 2026 09:20:45 +0900 Subject: [PATCH 22/40] chore: set default diag log level to warning and add --no-launchprofile option --- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index ada4459bbe..ce19395da7 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -36,6 +36,12 @@ public class UnitTestRunner(BuildContext context) private DotNetRunSettings GetTestSettingsParameters(FilePath logFile, string tfm) { + // 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.EnvironmentVariable("ACTIONS_STEP_DEBUG") == "true" + ? "Trace" + : "Warning"; // Logging Warning/Error/Critical level logs by default. + var settings = new DotNetRunSettings { Configuration = context.BuildConfiguration, @@ -53,7 +59,8 @@ private DotNetRunSettings GetTestSettingsParameters(FilePath logFile, string tfm .AppendSwitch("--output", "Detailed") .AppendSwitch("--show-stdout", "Failed") .Append("--diagnostic") - .AppendSwitch("--diagnostic-verbosity", "Trace") + .AppendSwitch("--diagnostic-verbosity", diagnosticVerbosity) + .Append("--no-launch-profile"), }; return settings; } From 73e327636f13368dee27ddfedfcebf1fd94307d4 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:25:53 +0900 Subject: [PATCH 23/40] chore: update parallel settings that introduced on xunit v3 4.0.0-pre.154 --- .../Properties/AssemblyInfo.cs | 5 ++++- .../Properties/AssemblyInfo.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs index 8c41d34c8b..bf52573154 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/AssemblyInfo.cs @@ -1,6 +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, DisableTestParallelization = true)] +[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)] +[assembly: Parallelization(Mode = ParallelMode.None)] diff --git a/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs index 32cfe6b1c7..e9f7b3c195 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Properties/AssemblyInfo.cs @@ -1,6 +1,9 @@ using System.Runtime.InteropServices; +using Xunit.Sdk; +using Xunit.v3; [assembly: Guid("74362bb1-9f64-4be5-b079-b4ac19dae5db")] [assembly: CaptureConsole] -[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)] +[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)] +[assembly: Parallelization(Mode = ParallelMode.None)] From 0141d13377e00b1413a7427aad9460a86e4eeb04 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 19 Jul 2026 18:36:23 +0900 Subject: [PATCH 24/40] chore: fix build error on build project --- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index ce19395da7..0aca17fca1 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -38,7 +38,7 @@ private DotNetRunSettings GetTestSettingsParameters(FilePath logFile, string tfm { // 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.EnvironmentVariable("ACTIONS_STEP_DEBUG") == "true" + var diagnosticVerbosity = context.Environment.GetEnvironmentVariable("ACTIONS_STEP_DEBUG") == "true" ? "Trace" : "Warning"; // Logging Warning/Error/Critical level logs by default. From 08337d4483f4da409bb6b7f4e35ec3607bcb7af4 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 19 Jul 2026 21:41:48 +0900 Subject: [PATCH 25/40] chore: remove ConsoleLogger to avoid dupicated log lines if [assembly:CaptureOutput] is enabled --- .../Shared/BenchmarkTestExecutor.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs index b608fdc1ec..e562516c90 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs @@ -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); From 4e4a740c7a0ae8afbd8e41ad6fd057f38719797b Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:26:21 +0900 Subject: [PATCH 26/40] chore: add launchsettings.json per test projects --- .../Properties/launchSettings.json | 20 ++++++++++++++++ .../Properties/launchSettings.json | 24 +++++++++++++++++++ .../Properties/launchSettings.json | 12 ++++++++++ .../Properties/launchSettings.json | 24 +++++++++++++++++++ .../Properties/launchSettings.json | 24 +++++++++++++++++++ .../Properties/launchSettings.json | 24 +++++++++++++++++++ 6 files changed, 128 insertions(+) create mode 100644 tests/BenchmarkDotNet.Analyzers.Tests/Properties/launchSettings.json create mode 100644 tests/BenchmarkDotNet.Exporters.Plotting.Tests/Properties/launchSettings.json create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/launchSettings.json create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning/Properties/launchSettings.json create mode 100644 tests/BenchmarkDotNet.IntegrationTests/Properties/launchSettings.json create mode 100644 tests/BenchmarkDotNet.Tests/Properties/launchSettings.json 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.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.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/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/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.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" + } + } +} From 5c99fe655d0f32ea63622dc78266bb2190e07baf Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 19 Jul 2026 23:59:44 +0900 Subject: [PATCH 27/40] chore: fix ci error with line ending differences --- .gitattributes | 4 ++++ src/BenchmarkDotNet/Exporters/HtmlExporter.cs | 8 ++++---- tests/.editorconfig | 4 ++++ .../Exporters/CommonExporterVerifyTests.cs | 4 +++- ...onExporterVerifyTests.Exporters_Invariant.verified.txt | 8 ++++---- ...CommonExporterVerifyTests.Exporters_en-US.verified.txt | 8 ++++---- ...CommonExporterVerifyTests.Exporters_ru-RU.verified.txt | 8 ++++---- tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs | 2 +- 8 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 .gitattributes 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/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 index 64a64c01c8..a0bc3cface 100644 --- a/tests/.editorconfig +++ b/tests/.editorconfig @@ -5,3 +5,7 @@ root = false # 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.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..f3a8304450 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 }).Replace("\r\n","\n"); return VerifyString(key, markdown + "\n" + json); } From 6c290687ea4b9451996ffa2e330a56244c7833dd Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 20 Jul 2026 01:34:53 +0900 Subject: [PATCH 28/40] chore: add setting to skip test when no test data --- .../MemoryDiagnoserTests.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index d9e1ea4650..0ac9dae10f 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -55,7 +55,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) { @@ -140,7 +141,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) { @@ -155,7 +157,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) { @@ -180,7 +183,8 @@ 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) { @@ -196,7 +200,8 @@ 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) { @@ -217,7 +222,8 @@ 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) { @@ -242,7 +248,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) { @@ -268,7 +275,7 @@ 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) @@ -338,7 +345,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) From 7a248e2dfa163443cefda6b14e8d0764bb3896d5 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 20 Jul 2026 04:00:16 +0900 Subject: [PATCH 29/40] chore: disable mtp and xunit entrypoint generation on benchmark project --- src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs | 1 - tests/Directory.Build.targets | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs index 125a28cb1a..9280c553ef 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs @@ -151,7 +151,6 @@ private string GenerateProjectForNuGetBuild(string projectFilePath, BuildPartiti false true false - false true {ilcOptimizationPreference} {ilcOptimizationPreference} diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index f4df154447..e282f8c222 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -3,7 +3,13 @@ true - + + + + false + false + + Date: Mon, 20 Jul 2026 21:35:32 +0900 Subject: [PATCH 30/40] chore: add testconfig.json --- tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json | 10 ++++++++++ .../testconfig.json | 10 ++++++++++ .../testconfig.json | 10 ++++++++++ .../testconfig.json | 10 ++++++++++ .../MemoryDiagnoserTests.cs | 1 + tests/BenchmarkDotNet.IntegrationTests/testconfig.json | 10 ++++++++++ tests/BenchmarkDotNet.Tests/testconfig.json | 10 ++++++++++ 7 files changed, 61 insertions(+) create mode 100644 tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json create mode 100644 tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json create mode 100644 tests/BenchmarkDotNet.IntegrationTests/testconfig.json create mode 100644 tests/BenchmarkDotNet.Tests/testconfig.json diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json b/tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json new file mode 100644 index 0000000000..ca4d9057fa --- /dev/null +++ b/tests/BenchmarkDotNet.Analyzers.Tests/testconfig.json @@ -0,0 +1,10 @@ +{ + "platformOptions": { + }, + "environmentVariables": { + "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", + "TESTINGPLATFORM_UI_LANGUAGE": "en-us" + }, + "xUnit": { + } +} diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json new file mode 100644 index 0000000000..ca4d9057fa --- /dev/null +++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json @@ -0,0 +1,10 @@ +{ + "platformOptions": { + }, + "environmentVariables": { + "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", + "TESTINGPLATFORM_UI_LANGUAGE": "en-us" + }, + "xUnit": { + } +} diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json new file mode 100644 index 0000000000..ca4d9057fa --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json @@ -0,0 +1,10 @@ +{ + "platformOptions": { + }, + "environmentVariables": { + "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", + "TESTINGPLATFORM_UI_LANGUAGE": "en-us" + }, + "xUnit": { + } +} diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json new file mode 100644 index 0000000000..ca4d9057fa --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json @@ -0,0 +1,10 @@ +{ + "platformOptions": { + }, + "environmentVariables": { + "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", + "TESTINGPLATFORM_UI_LANGUAGE": "en-us" + }, + "xUnit": { + } +} diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index 0ac9dae10f..dc5e4838db 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -11,6 +11,7 @@ using BenchmarkDotNet.IntegrationTests.Xunit; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Loggers; +using BenchmarkDotNet.Portability; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; using BenchmarkDotNet.Tests.Loggers; diff --git a/tests/BenchmarkDotNet.IntegrationTests/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests/testconfig.json new file mode 100644 index 0000000000..ca4d9057fa --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests/testconfig.json @@ -0,0 +1,10 @@ +{ + "platformOptions": { + }, + "environmentVariables": { + "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", + "TESTINGPLATFORM_UI_LANGUAGE": "en-us" + }, + "xUnit": { + } +} diff --git a/tests/BenchmarkDotNet.Tests/testconfig.json b/tests/BenchmarkDotNet.Tests/testconfig.json new file mode 100644 index 0000000000..ca4d9057fa --- /dev/null +++ b/tests/BenchmarkDotNet.Tests/testconfig.json @@ -0,0 +1,10 @@ +{ + "platformOptions": { + }, + "environmentVariables": { + "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", + "TESTINGPLATFORM_UI_LANGUAGE": "en-us" + }, + "xUnit": { + } +} From 9b8afbac583e5efb2b560a97a5c35c9ddca10ffc Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 23 Jul 2026 00:50:30 +0900 Subject: [PATCH 31/40] chore: add telemetry/progress disable verification for some tests --- .../MemoryDiagnoserTests.cs | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index dc5e4838db..36dda906a2 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -11,7 +11,6 @@ using BenchmarkDotNet.IntegrationTests.Xunit; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Loggers; -using BenchmarkDotNet.Portability; using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; using BenchmarkDotNet.Tests.Loggers; @@ -26,6 +25,7 @@ using BenchmarkDotNet.Validators; using System.Reflection; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace BenchmarkDotNet.IntegrationTests { @@ -189,11 +189,34 @@ public ulong TimeConsuming() [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void TieredJitShouldNotInterfereAllocationResults(IToolchain toolchain) { + if (toolchain.IsInProcess) + ValidateMtpProgressDisabled(); + 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 @@ -285,12 +308,32 @@ public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain) if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) return; + if (toolchain.IsInProcess) + ValidateTelemetryOptOut(); + long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word long arraySizeOverhead = IntPtr.Size; // array length AssertAllocations(toolchain, typeof(TimeConsuming), new Dictionary { { nameof(TimeConsuming.SixtyFourBytesArray), 64 + objectAllocationOverhead + arraySizeOverhead } }); + + static void ValidateTelemetryOptOut() + { + if (!OsDetector.IsWindows()) + return; + + // When MTP telemetry feature is enabled, extra allocation (792 bytes) occurred randomly on Windows. + var optout = Environment.GetEnvironmentVariable("TESTINGPLATFORM_TELEMETRY_OPTOUT"); + switch (optout) + { + case "1": + case "true": + break; + default: + throw new NotSupportedException("Measure memory allocation requires setting `TESTINGPLATFORM_TELEMETRY_OPTOUT=true`"); + } + } } public class MultiThreadedAllocation From 56194953c7706cb8f01f36ce72ae156f830e1816 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 23 Jul 2026 00:51:59 +0900 Subject: [PATCH 32/40] chore: disable progress on CI execution to avoid extra memory allocations --- .github/workflows/run-tests-selected.yaml | 2 +- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests-selected.yaml b/.github/workflows/run-tests-selected.yaml index 688df34ea4..fac15e347c 100644 --- a/.github/workflows/run-tests-selected.yaml +++ b/.github/workflows/run-tests-selected.yaml @@ -95,7 +95,7 @@ jobs: foreach($i in 1..$iterationCount) { Write-Output ('##[group]Executing Iteration: {0}/${{ inputs.iteration_count }}' -f $i) - dotnet test -c Release --framework ${{ inputs.framework }} --no-build --filter "${{ inputs.filter }}" --no-ansi + dotnet test -c Release --framework ${{ inputs.framework }} --no-build --filter "${{ inputs.filter }}" --no-ansi --progress off --output Detailed Write-Output '##[endgroup]' } diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index 0aca17fca1..07aff4737a 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -56,6 +56,7 @@ private DotNetRunSettings GetTestSettingsParameters(FilePath logFile, string tfm => 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") From 92c2e4ed31e75f959f4c3720f4e73e8ba561dab5 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 23 Jul 2026 03:41:40 +0900 Subject: [PATCH 33/40] chore: remove unused test filter and add parameters --- .github/workflows/generate-coverage-report.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-coverage-report.yaml b/.github/workflows/generate-coverage-report.yaml index c689cb4ce3..3a64f5d8ae 100644 --- a/.github/workflows/generate-coverage-report.yaml +++ b/.github/workflows/generate-coverage-report.yaml @@ -49,13 +49,13 @@ jobs: - name: Collect Code Coverage run: | - dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Tests -c Release --no-build --framework net10.0" - dotnet coverage connect bdn_coverage "dotnet test --project 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 --project 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 @@ -89,13 +89,13 @@ jobs: - name: Collect Code Coverage run: | - dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Tests -c Release --no-build --framework net472" - dotnet coverage connect bdn_coverage "dotnet test --project 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'}} run: | - dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)/(!*WasmIsSupported)&(!*WasmSupportsInProcessDiagnosers)"' + 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 From 373ec9577f37a49b7be024aee1e0147662444001 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Fri, 24 Jul 2026 04:24:25 +0900 Subject: [PATCH 34/40] chore: add setting to suppress dotnet cli telemetry --- tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json | 1 + .../testconfig.json | 1 + .../testconfig.json | 1 + tests/BenchmarkDotNet.IntegrationTests/testconfig.json | 1 + tests/BenchmarkDotNet.Tests/testconfig.json | 1 + 5 files changed, 5 insertions(+) diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json index ca4d9057fa..38f5be2e55 100644 --- a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json +++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/testconfig.json @@ -2,6 +2,7 @@ "platformOptions": { }, "environmentVariables": { + "DOTNET_CLI_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_UI_LANGUAGE": "en-us" }, diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json index ca4d9057fa..38f5be2e55 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/testconfig.json @@ -2,6 +2,7 @@ "platformOptions": { }, "environmentVariables": { + "DOTNET_CLI_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_UI_LANGUAGE": "en-us" }, diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json index ca4d9057fa..38f5be2e55 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/testconfig.json @@ -2,6 +2,7 @@ "platformOptions": { }, "environmentVariables": { + "DOTNET_CLI_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_UI_LANGUAGE": "en-us" }, diff --git a/tests/BenchmarkDotNet.IntegrationTests/testconfig.json b/tests/BenchmarkDotNet.IntegrationTests/testconfig.json index ca4d9057fa..38f5be2e55 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/testconfig.json +++ b/tests/BenchmarkDotNet.IntegrationTests/testconfig.json @@ -2,6 +2,7 @@ "platformOptions": { }, "environmentVariables": { + "DOTNET_CLI_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_UI_LANGUAGE": "en-us" }, diff --git a/tests/BenchmarkDotNet.Tests/testconfig.json b/tests/BenchmarkDotNet.Tests/testconfig.json index ca4d9057fa..38f5be2e55 100644 --- a/tests/BenchmarkDotNet.Tests/testconfig.json +++ b/tests/BenchmarkDotNet.Tests/testconfig.json @@ -2,6 +2,7 @@ "platformOptions": { }, "environmentVariables": { + "DOTNET_CLI_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_TELEMETRY_OPTOUT": "true", "TESTINGPLATFORM_UI_LANGUAGE": "en-us" }, From 1bb582a2ff3677ab7b8f769cacb55d4451b18a15 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Fri, 24 Jul 2026 07:54:11 +0900 Subject: [PATCH 35/40] chore: add skip setting for flaky test --- .../MemoryDiagnoserTests.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index 36dda906a2..5c2713f782 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -305,12 +305,18 @@ public byte[] SixtyFourBytesArray() 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.IsMacOS()) + Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/2779"); - if (toolchain.IsInProcess) + if (OsDetector.IsWindows() && toolchain.IsInProcess) + { ValidateTelemetryOptOut(); + // Skip test on `windows(arm64)`. + if (RuntimeInformation.OSArchitecture == Architecture.Arm64 && Portability.RuntimeInformation.IsNetCore) + 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 AssertAllocations(toolchain, typeof(TimeConsuming), new Dictionary @@ -320,9 +326,6 @@ public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain) static void ValidateTelemetryOptOut() { - if (!OsDetector.IsWindows()) - return; - // When MTP telemetry feature is enabled, extra allocation (792 bytes) occurred randomly on Windows. var optout = Environment.GetEnvironmentVariable("TESTINGPLATFORM_TELEMETRY_OPTOUT"); switch (optout) From 01cd99a99d03f5c1598db4a5941c5b5718dc1c93 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Fri, 24 Jul 2026 09:46:12 +0900 Subject: [PATCH 36/40] chore: temporary disable longRunningTest detection background worker --- tests/BenchmarkDotNet.IntegrationTests/xunit.runner.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/xunit.runner.json b/tests/BenchmarkDotNet.IntegrationTests/xunit.runner.json index 53b385245e..8ff7a75dc8 100755 --- a/tests/BenchmarkDotNet.IntegrationTests/xunit.runner.json +++ b/tests/BenchmarkDotNet.IntegrationTests/xunit.runner.json @@ -1,8 +1,8 @@ -{ +{ "shadowCopy": false, "methodDisplay": "method", "diagnosticMessages": true, - "longRunningTestSeconds": 60, + "longRunningTestSeconds": 0, "parallelizeAssembly": false, "parallelizeTestCollections": false } \ No newline at end of file From fe1b73201632d4777ef48b0e95755670d1306284 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 25 Jul 2026 08:33:07 +0900 Subject: [PATCH 37/40] chore: modify test condition for flaky tests --- .../MemoryDiagnoserTests.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index 5c2713f782..c216d06b8f 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -37,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; @@ -229,6 +226,12 @@ public class NoBoxing [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 } @@ -251,6 +254,12 @@ public class NonAllocatingAsynchronousBenchmarks [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 }, @@ -304,15 +313,11 @@ public byte[] SixtyFourBytesArray() [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 (OsDetector.IsMacOS()) - Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/2779"); - if (OsDetector.IsWindows() && toolchain.IsInProcess) { ValidateTelemetryOptOut(); - // Skip test on `windows(arm64)`. + // Skip test on `windows(arm64)` because extra memory allocation still occurred. if (RuntimeInformation.OSArchitecture == Architecture.Arm64 && Portability.RuntimeInformation.IsNetCore) Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/2779"); } From 808f312fd4ed3e789c4b07c6454aee5d14ba7a02 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 25 Jul 2026 08:46:08 +0900 Subject: [PATCH 38/40] chore: remove temporary workaround setting for macos from ThreadingDiagnoserTests --- .../ThreadingDiagnoserTests.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs index 58bfde5480..935da53515 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs @@ -185,10 +185,6 @@ private void AssertStats(Summary summary, IToolchain toolchain, Dictionary Date: Sat, 25 Jul 2026 10:41:41 +0900 Subject: [PATCH 39/40] chore: remove validation logics because flaky test is reproduced on windows(x64) also --- .../MemoryDiagnoserTests.cs | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index c216d06b8f..23b02f07b6 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -314,13 +314,7 @@ public byte[] SixtyFourBytesArray() public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain) { if (OsDetector.IsWindows() && toolchain.IsInProcess) - { - ValidateTelemetryOptOut(); - - // Skip test on `windows(arm64)` because extra memory allocation still occurred. - if (RuntimeInformation.OSArchitecture == Architecture.Arm64 && Portability.RuntimeInformation.IsNetCore) - Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/2779"); - } + 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 @@ -328,20 +322,6 @@ public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain) { { nameof(TimeConsuming.SixtyFourBytesArray), 64 + objectAllocationOverhead + arraySizeOverhead } }); - - static void ValidateTelemetryOptOut() - { - // When MTP telemetry feature is enabled, extra allocation (792 bytes) occurred randomly on Windows. - var optout = Environment.GetEnvironmentVariable("TESTINGPLATFORM_TELEMETRY_OPTOUT"); - switch (optout) - { - case "1": - case "true": - break; - default: - throw new NotSupportedException("Measure memory allocation requires setting `TESTINGPLATFORM_TELEMETRY_OPTOUT=true`"); - } - } } public class MultiThreadedAllocation From 9c3b2dd7048c8e385c20d494d5a0b845939b825e Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Wed, 29 Jul 2026 01:32:06 +0900 Subject: [PATCH 40/40] chore: update PerfonarTest based on latest update --- tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs b/tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs index f3a8304450..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 }).Replace("\r\n","\n"); + string json = LightJsonSerializer.Serialize(table.RootEntry, new LightJsonSettings { Indent = true, NewLine = "\n" }); return VerifyString(key, markdown + "\n" + json); }