Skip to content

Commit 231dfab

Browse files
committed
Fix compiler toolset test
1 parent 110618b commit 231dfab

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/Microsoft.NET.Build.Tests/RoslynBuildTaskTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ public void FullMSBuild_NonSdkStyle(bool useSharedCompilation, Language language
5454
}
5555

5656
[FullMSBuildOnlyTheory, CombinatorialData]
57-
public void FullMSBuild_SdkStyle_ToolsetPackage(bool useSharedCompilation, Language language)
57+
public void FullMSBuild_SdkStyle_ToolsetPackage(bool useSharedCompilation, Language language, bool useFrameworkCompiler)
5858
{
5959
var testAsset = CreateProject(useSharedCompilation, language, AddCompilersToolsetPackage);
60-
var buildCommand = BuildAndRunUsingMSBuild(testAsset);
61-
VerifyCompiler(buildCommand, FxCompilerFileName(language), useSharedCompilation, toolsetPackage: true);
60+
ReadOnlySpan<string> args = useFrameworkCompiler ? ["-p:RoslynCompilerType=Framework"] : [];
61+
var buildCommand = BuildAndRunUsingMSBuild(testAsset, args);
62+
VerifyCompiler(buildCommand, useFrameworkCompiler ? FxCompilerFileName(language) : CoreCompilerFileName(language), useSharedCompilation, toolsetPackage: true);
6263
}
6364

6465
[Theory, CombinatorialData]
@@ -129,21 +130,21 @@ private static void AddCompilersToolsetPackage(TestProject project)
129130
project.PackageReferences.Add(new TestPackageReference("Microsoft.Net.Compilers.Toolset", roslynVersion));
130131
}
131132

132-
private TestCommand BuildAndRunUsingMSBuild(TestAsset testAsset)
133+
private TestCommand BuildAndRunUsingMSBuild(TestAsset testAsset, params ReadOnlySpan<string> args)
133134
{
134135
var buildCommand = new MSBuildCommand(testAsset, "Build");
135136
buildCommand.WithWorkingDirectory(testAsset.Path)
136-
.Execute("-bl").Should().Pass();
137+
.Execute(["-bl", .. args]).Should().Pass();
137138

138139
Run(buildCommand.GetOutputDirectory().File(testAsset.TestProject!.GetOutputFileName()));
139140

140141
return buildCommand;
141142
}
142143

143-
private TestCommand BuildAndRunUsingDotNet(TestAsset testAsset)
144+
private TestCommand BuildAndRunUsingDotNet(TestAsset testAsset, params ReadOnlySpan<string> args)
144145
{
145146
var buildCommand = new DotnetBuildCommand(testAsset);
146-
buildCommand.Execute("-bl").Should().Pass();
147+
buildCommand.Execute(["-bl", .. args]).Should().Pass();
147148

148149
Run(buildCommand.GetOutputDirectory().File(testAsset.TestProject!.GetOutputFileName()));
149150

@@ -177,9 +178,9 @@ private static void VerifyCompiler(TestCommand buildCommand, string compilerFile
177178
}
178179

179180
// Verify compiler server message.
180-
var compilerServerMesssages = BinaryLog.ReadBuild(binaryLogPath).FindChildrenRecursive<Message>(
181+
var compilerServerMessages = BinaryLog.ReadBuild(binaryLogPath).FindChildrenRecursive<Message>(
181182
static message => message.Text.StartsWith("CompilerServer:", StringComparison.Ordinal));
182-
compilerServerMesssages.Should().ContainSingle().Which.Text.Should().StartWith(usedCompilerServer
183+
compilerServerMessages.Should().ContainSingle().Which.Text.Should().StartWith(usedCompilerServer
183184
? "CompilerServer: server - server processed compilation - "
184185
: "CompilerServer: tool - using command line tool by design");
185186
}

0 commit comments

Comments
 (0)