Skip to content

Commit

Permalink
Reuse RunOniOS test method for NativeAOT
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpovazan committed Jan 17, 2024
1 parent 86a6c50 commit ef8bbee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,33 @@ public void AppleTemplateFxtTearDown()
}

[Test]
[TestCase("maui", "Debug", DotNetPrevious)]
[TestCase("maui", "Release", DotNetPrevious)]
[TestCase("maui", "Debug", DotNetCurrent)]
[TestCase("maui", "Release", DotNetCurrent)]
[TestCase("maui-blazor", "Debug", DotNetPrevious)]
[TestCase("maui-blazor", "Release", DotNetPrevious)]
[TestCase("maui-blazor", "Debug", DotNetCurrent)]
[TestCase("maui-blazor", "Release", DotNetCurrent)]
public void RunOniOS(string id, string config, string framework)
[TestCase("maui", "Debug", DotNetPrevious, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui", "Release", DotNetPrevious, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui", "Debug", DotNetCurrent, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui", "Release", DotNetCurrent, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui-blazor", "Debug", DotNetPrevious, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui-blazor", "Release", DotNetPrevious, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui-blazor", "Debug", DotNetCurrent, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui-blazor", "Release", DotNetCurrent, "iossimulator-x64", RuntimeVariant.Mono)]
[TestCase("maui", "Release", DotNetCurrent, "iossimulator-x64", RuntimeVariant.NativeAOT)]
public void RunOniOS(string id, string config, string framework, string runtimeIdentifier, RuntimeVariant runtimeVariant)
{
var projectDir = TestDirectory;
var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj");

Assert.IsTrue(DotnetInternal.New(id, projectDir, framework),
$"Unable to create template {id}. Check test output for errors.");

Assert.IsTrue(DotnetInternal.Build(projectFile, config, framework: $"{framework}-ios", properties: BuildProps),
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");

var appFile = Path.Combine(projectDir, "bin", config, $"{framework}-ios", "iossimulator-x64", $"{Path.GetFileName(projectDir)}.app");

Assert.IsTrue(XHarness.RunAppleForTimeout(appFile, Path.Combine(projectDir, "xh-results"), TestSimulator.XHarnessID),
$"Project {Path.GetFileName(projectFile)} failed to run. Check test output/attachments for errors.");
}

[Test]
[TestCase("maui", "Release", DotNetCurrent, "iossimulator-x64")]
public void RunOniOSNativeAOT(string id, string config, string framework, string runtimeIdentifier)
{
var projectDir = TestDirectory;
var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj");

Assert.IsTrue(DotnetInternal.New(id, projectDir, framework),
$"Unable to create template {id}. Check test output for errors.");

var extendedBuildProps = BuildProps;
extendedBuildProps.Add("PublishAot=true");
extendedBuildProps.Add("PublishAotUsingRuntimePack=true"); // TODO: This parameter will become obsolete https://github.com/dotnet/runtime/issues/87060
extendedBuildProps.Add("_IsPublishing=true"); // using dotnet build with -p:_IsPublishing=true enables targeting simulators
extendedBuildProps.Add($"RuntimeIdentifier={runtimeIdentifier}");
var buildProps = BuildProps;
if (runtimeVariant == RuntimeVariant.NativeAOT)
{
buildProps.Add("PublishAot=true");
buildProps.Add("PublishAotUsingRuntimePack=true"); // TODO: This parameter will become obsolete https://github.com/dotnet/runtime/issues/87060
buildProps.Add("_IsPublishing=true"); // using dotnet build with -p:_IsPublishing=true enables targeting simulators
buildProps.Add($"RuntimeIdentifier={runtimeIdentifier}");
}

Assert.IsTrue(DotnetInternal.Build(projectFile, config, framework: $"{framework}-ios", properties: BuildProps),
Assert.IsTrue(DotnetInternal.Build(projectFile, config, framework: $"{framework}-ios", properties: buildProps),
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");

var appFile = Path.Combine(projectDir, "bin", config, $"{framework}-ios", runtimeIdentifier, $"{Path.GetFileName(projectDir)}.app");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

namespace Microsoft.Maui.IntegrationTests
{
public enum RuntimeVariant
{
Mono,
NativeAOT
}

public class BaseBuildTest
{
public const string DotNetCurrent = "net8.0";
Expand Down

0 comments on commit ef8bbee

Please sign in to comment.