diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs index 701b7d7ee1..2559034d2c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs @@ -3,10 +3,14 @@ using BenchmarkDotNet.Configs; using BenchmarkDotNet.Extensions; using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Portability; using Xunit; namespace BenchmarkDotNet.IntegrationTests { + // Note: To properly test this locally, modify + // BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj, + // following the comments in that file. public class MultipleFrameworksTest : BenchmarkTestExecutor { private const string TfmEnvVarName = "TfmEnvVarName"; @@ -15,9 +19,23 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor [InlineData(RuntimeMoniker.Net461)] [InlineData(RuntimeMoniker.Net48)] [InlineData(RuntimeMoniker.NetCoreApp20)] - [InlineData(RuntimeMoniker.Net70)] + [InlineData(RuntimeMoniker.Net80)] public void EachFrameworkIsRebuilt(RuntimeMoniker runtime) { +#if NET461 + // We cannot detect what target framework version the host was compiled for on full Framework, + // which causes the RoslynToolchain to be used instead of CsProjClassicNetToolchain when the host is full Framework + // (because full Framework always uses the version that's installed on the machine, unlike Core), + // which means if the machine has net48 installed (not net481), the net461 host with net48 runtime moniker + // will not be recompiled, causing the test to fail. + + // If we ever change the default toolchain to CsProjClassicNetToolchain instead of RoslynToolchain, we can remove this check. + if (runtime == RuntimeMoniker.Net48) + { + // XUnit doesn't provide Assert.Skip API yet. + return; + } +#endif var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString())); CanExecute(config); } @@ -31,8 +49,8 @@ public class ValuePerTfm RuntimeMoniker.Net48; #elif NETCOREAPP2_0 RuntimeMoniker.NetCoreApp20; -#elif NET7_0 - RuntimeMoniker.Net70; +#elif NET8_0 + RuntimeMoniker.Net80; #else RuntimeMoniker.NotRecognized; #endif diff --git a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs index bd0f992c80..896f93925b 100644 --- a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs +++ b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs @@ -162,7 +162,7 @@ public void SpecifyingCoreRunWithFullFrameworkTargetsMostRecentTfm() CoreRunToolchain coreRunToolchain = (CoreRunToolchain)coreRunJob.GetToolchain(); DotNetCliGenerator generator = (DotNetCliGenerator)coreRunToolchain.Generator; - Assert.Equal("net8.0", generator.TargetFrameworkMoniker); + Assert.Equal("net9.0", generator.TargetFrameworkMoniker); } [FactEnvSpecific("It's impossible to determine TFM for CoreRunToolchain if host process is not .NET (Core) process", EnvRequirement.DotNetCoreOnly)]