Skip to content

Commit b987b99

Browse files
authored
Fixed some tests. (#2475)
1 parent 5557aee commit b987b99

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs

+21-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
using BenchmarkDotNet.Configs;
44
using BenchmarkDotNet.Extensions;
55
using BenchmarkDotNet.Jobs;
6+
using BenchmarkDotNet.Portability;
67
using Xunit;
78

89
namespace BenchmarkDotNet.IntegrationTests
910
{
11+
// Note: To properly test this locally, modify
12+
// BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj,
13+
// following the comments in that file.
1014
public class MultipleFrameworksTest : BenchmarkTestExecutor
1115
{
1216
private const string TfmEnvVarName = "TfmEnvVarName";
@@ -15,9 +19,23 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor
1519
[InlineData(RuntimeMoniker.Net461)]
1620
[InlineData(RuntimeMoniker.Net48)]
1721
[InlineData(RuntimeMoniker.NetCoreApp20)]
18-
[InlineData(RuntimeMoniker.Net70)]
22+
[InlineData(RuntimeMoniker.Net80)]
1923
public void EachFrameworkIsRebuilt(RuntimeMoniker runtime)
2024
{
25+
#if NET461
26+
// We cannot detect what target framework version the host was compiled for on full Framework,
27+
// which causes the RoslynToolchain to be used instead of CsProjClassicNetToolchain when the host is full Framework
28+
// (because full Framework always uses the version that's installed on the machine, unlike Core),
29+
// which means if the machine has net48 installed (not net481), the net461 host with net48 runtime moniker
30+
// will not be recompiled, causing the test to fail.
31+
32+
// If we ever change the default toolchain to CsProjClassicNetToolchain instead of RoslynToolchain, we can remove this check.
33+
if (runtime == RuntimeMoniker.Net48)
34+
{
35+
// XUnit doesn't provide Assert.Skip API yet.
36+
return;
37+
}
38+
#endif
2139
var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString()));
2240
CanExecute<ValuePerTfm>(config);
2341
}
@@ -31,8 +49,8 @@ public class ValuePerTfm
3149
RuntimeMoniker.Net48;
3250
#elif NETCOREAPP2_0
3351
RuntimeMoniker.NetCoreApp20;
34-
#elif NET7_0
35-
RuntimeMoniker.Net70;
52+
#elif NET8_0
53+
RuntimeMoniker.Net80;
3654
#else
3755
RuntimeMoniker.NotRecognized;
3856
#endif

tests/BenchmarkDotNet.Tests/ConfigParserTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void SpecifyingCoreRunWithFullFrameworkTargetsMostRecentTfm()
162162

163163
CoreRunToolchain coreRunToolchain = (CoreRunToolchain)coreRunJob.GetToolchain();
164164
DotNetCliGenerator generator = (DotNetCliGenerator)coreRunToolchain.Generator;
165-
Assert.Equal("net8.0", generator.TargetFrameworkMoniker);
165+
Assert.Equal("net9.0", generator.TargetFrameworkMoniker);
166166
}
167167

168168
[FactEnvSpecific("It's impossible to determine TFM for CoreRunToolchain if host process is not .NET (Core) process", EnvRequirement.DotNetCoreOnly)]

0 commit comments

Comments
 (0)