Skip to content

Commit

Permalink
Make it easier to test CPU architectures in multiple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Feb 1, 2022
1 parent 94b7833 commit 04837f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 28 additions & 1 deletion test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ public GeneratorTests(ITestOutputHelper logger)
new object[] { "net5.0" },
};

public static Platform[] SpecificCpuArchitectures =>
new Platform[]
{
Platform.X86,
Platform.X64,
Platform.Arm64,
};

public static Platform[] AnyCpuArchitectures =>
new Platform[]
{
Platform.AnyCpu,
Platform.X86,
Platform.X64,
Platform.Arm64,
};

public async Task InitializeAsync()
{
this.starterCompilations.Add("net35", await this.CreateCompilationAsync(MyReferenceAssemblies.NetFramework.Net35));
Expand Down Expand Up @@ -1215,7 +1232,17 @@ public void RenamedMethodsClass()
}

[Theory, PairwiseData]
public void FullGeneration(bool allowMarshaling, [CombinatorialValues(Platform.AnyCpu, Platform.X86, Platform.X64, Platform.Arm64)] Platform platform)
public void TBButton([CombinatorialMemberData(nameof(AnyCpuArchitectures))] Platform platform)
{
this.compilation = this.compilation.WithOptions(this.compilation.Options.WithPlatform(platform));
this.generator = this.CreateGenerator();
Assert.True(this.generator.TryGenerate("TBBUTTON", CancellationToken.None));
this.CollectGeneratedCode(this.generator);
this.AssertNoDiagnostics();
}

[Theory, PairwiseData]
public void FullGeneration(bool allowMarshaling, [CombinatorialMemberData(nameof(AnyCpuArchitectures))] Platform platform)
{
var generatorOptions = new GeneratorOptions { AllowMarshaling = allowMarshaling };
this.compilation = this.compilation.WithOptions(this.compilation.Options.WithPlatform(platform));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PackageReference Include="System.Reflection.Metadata" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Xunit.Combinatorial" Version="1.4.1" />
<PackageReference Include="Xunit.Combinatorial" Version="1.5.7-beta" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>

Expand Down

0 comments on commit 04837f4

Please sign in to comment.