Skip to content

Commit 28447ce

Browse files
committed
Fix compiler toolset test
1 parent 265a139 commit 28447ce

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

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

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

@@ -130,21 +131,21 @@ private static void AddCompilersToolsetPackage(TestProject project)
130131
project.PackageReferences.Add(new TestPackageReference("Microsoft.Net.Compilers.Toolset", roslynVersion));
131132
}
132133

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

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

141142
return buildCommand;
142143
}
143144

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

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

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

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

0 commit comments

Comments
 (0)