Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added decoded_output.xml
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,14 @@ protected async Task<ProcessExecutionResult> RunSimulatorApp(

_mainLog.WriteLine("Launching the app");

// Create an application log to capture mlaunch output (including simctl launch --console output)
// This is needed for exit code detection, as the app exit code (e.g., DOTNET.APP_EXIT_CODE)
// is printed to stdout by the simulator and captured by mlaunch
var appOutputLog = _logs.Create(appInformation.BundleIdentifier + ".log", LogType.ApplicationLog.ToString(), timestamp: true);

if (waitForExit)
{
var result = await _processManager.ExecuteCommandAsync(mlaunchArguments, _mainLog, timeout, cancellationToken: cancellationToken);
var result = await _processManager.ExecuteCommandAsync(mlaunchArguments, _mainLog, appOutputLog, appOutputLog, timeout, cancellationToken: cancellationToken);
simulatorScanToken?.Cancel();
return result;
}
Expand All @@ -194,7 +199,7 @@ protected async Task<ProcessExecutionResult> RunSimulatorApp(

_mainLog.WriteLine("Waiting for the app to launch..");

var runTask = _processManager.ExecuteCommandAsync(mlaunchArguments, Log.CreateAggregatedLog(_mainLog, scanLog), timeout, cancellationToken: cancellationToken);
var runTask = _processManager.ExecuteCommandAsync(mlaunchArguments, Log.CreateAggregatedLog(_mainLog, scanLog), appOutputLog, appOutputLog, timeout, cancellationToken: cancellationToken);
await Task.WhenAny(runTask, appLaunched.Task);

if (!appLaunched.Task.IsCompleted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public virtual string GetDeviceType(TestTargetOs target, bool minVersion)
{
return target.Platform switch
{
TestTarget.Simulator_iOS64 => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : "iPhone-XS"),
TestTarget.Simulator_iOS64 => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : "iPhone-11-Pro"),
TestTarget.Simulator_tvOS => "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p",
TestTarget.Simulator_watchOS => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "Apple-Watch-38mm" : "Apple-Watch-Series-3-38mm"),
TestTarget.Simulator_watchOS => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "Apple-Watch-38mm" : "Apple-Watch-Series-5-40mm"),
TestTarget.Simulator_xrOS => "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro",
_ => throw new Exception(string.Format("Invalid simulator target: {0}", target))
};
Expand All @@ -49,7 +49,7 @@ public virtual void GetCompanionRuntimeAndDeviceType(TestTargetOs target, bool m
if (target.Platform == TestTarget.Simulator_watchOS)
{
companionRuntime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (minVersion ? SdkVersions.MinWatchOSCompanionSimulator : SdkVersions.MaxWatchOSCompanionSimulator).Replace('.', '-');
companionDeviceType = "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : "iPhone-XS");
companionDeviceType = "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : "iPhone-11-Pro");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public async Task RunOnSimulatorTest()
x => x.ExecuteCommandAsync(
It.Is<MlaunchArguments>(args => args.AsCommandLine() == expectedArgs),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<TimeSpan>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<int>(),
Expand Down Expand Up @@ -431,11 +433,13 @@ public async Task RunOnSimulatorNoWaitTest()
x => x.ExecuteCommandAsync(
It.Is<MlaunchArguments>(args => args.AsCommandLine() == expectedArgs),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<TimeSpan>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<int>(),
It.IsAny<CancellationToken>()))
.Callback((MlaunchArguments args, ILog log, TimeSpan timeout, Dictionary<string, string> env, int verbosity, CancellationToken? ct) =>
.Callback((MlaunchArguments args, ILog log, ILog stdoutLog, ILog stderrLog, TimeSpan timeout, Dictionary<string, string> env, int verbosity, CancellationToken? ct) =>
{
appLog = log;
appLaunchedTask.SetResult();
Expand Down Expand Up @@ -485,6 +489,8 @@ public async Task RunOnSimulatorNoWaitTest()
x => x.ExecuteCommandAsync(
It.Is<MlaunchArguments>(args => args.AsCommandLine() == expectedArgs),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<TimeSpan>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<int>(),
Expand Down Expand Up @@ -534,11 +540,13 @@ public async Task RunOnSimulatorNoWaitNoLaunchSignalTest()
x => x.ExecuteCommandAsync(
It.Is<MlaunchArguments>(args => args.AsCommandLine() == expectedArgs),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<TimeSpan>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<int>(),
It.IsAny<CancellationToken>()))
.Callback((MlaunchArguments args, ILog log, TimeSpan timeout, Dictionary<string, string> env, int verbosity, CancellationToken? ct) =>
.Callback((MlaunchArguments args, ILog log, ILog stdoutLog, ILog stderrLog, TimeSpan timeout, Dictionary<string, string> env, int verbosity, CancellationToken? ct) =>
{
appLaunchedTask.SetResult();
})
Expand Down Expand Up @@ -589,6 +597,8 @@ public async Task RunOnSimulatorNoWaitNoLaunchSignalTest()
x => x.ExecuteCommandAsync(
It.Is<MlaunchArguments>(args => args.AsCommandLine() == expectedArgs),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<TimeSpan>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<int>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public async Task TestOnSimulatorTest(bool useTunnel)
x => x.ExecuteCommandAsync(
It.Is<MlaunchArguments>(args => args.AsCommandLine() == expectedArgs),
_mainLog.Object,
It.IsAny<ILog>(),
It.IsAny<ILog>(),
It.IsAny<TimeSpan>(),
It.IsAny<Dictionary<string, string>>(),
It.IsAny<int>(),
Expand Down
4 changes: 2 additions & 2 deletions tests/integration-tests/Apple/Device.iOS.Tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

<!-- apple test / ios-device -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=ios-device;TestAppBundleName=System.Buffers.Tests.app</AdditionalProperties>
<AdditionalProperties>TestTarget=ios-device;TestArch=arm64;TestAppBundleName=System.Buffers.Tests.app</AdditionalProperties>
</XHarnessAppleProject>

<!-- apple run / ios-device -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=ios-device;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
<AdditionalProperties>TestTarget=ios-device;TestArch=arm64;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
</XHarnessAppleProject>
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions tests/integration-tests/Apple/Device.tvOS.Tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

<!-- apple test / tvos-device -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=tvos-device;TestAppBundleName=System.Buffers.Tests.app</AdditionalProperties>
<AdditionalProperties>TestTarget=tvos-device;TestArch=arm64;TestAppBundleName=System.Buffers.Tests.app</AdditionalProperties>
</XHarnessAppleProject>

<!-- apple run / tvos-device -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=tvos-device;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
<AdditionalProperties>TestTarget=tvos-device;TestArch=arm64;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
</XHarnessAppleProject>
</ItemGroup>

Expand Down
25 changes: 19 additions & 6 deletions tests/integration-tests/Apple/Simulator.Tests.proj
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
<Project Sdk="Microsoft.DotNet.Helix.Sdk">

<!-- Detect architecture from Helix target queue name -->
<PropertyGroup>
<IsArm64Queue>$(HelixTargetQueue.Contains('arm64'))</IsArm64Queue>
<IsAmd64Queue>$(HelixTargetQueue.Contains('amd64'))</IsAmd64Queue>
<TestArch Condition="'$(IsArm64Queue)' == 'true'">arm64</TestArch>
<TestArch Condition="'$(IsAmd64Queue)' == 'true'">x64</TestArch>
</PropertyGroup>

<Target Name="ValidateArchitecture" BeforeTargets="Build">
<Error Condition="'$(HelixTargetQueue)' != '' and '$(IsArm64Queue)' != 'true' and '$(IsAmd64Queue)' != 'true'"
Text="Unable to detect architecture from HelixTargetQueue '$(HelixTargetQueue)'. Queue name must contain 'arm64' or 'amd64'." />
</Target>

<ItemGroup>
<HelixTargetQueue Include="osx.15.amd64.open"/>
<HelixTargetQueue Include="osx.14.arm64.open"/>
<HelixTargetQueue Include="osx.26.arm64.open"/>

<!-- apple test / ios-simulator-64 -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=ios-simulator-64;TestAppBundleName=System.Numerics.Vectors.Tests.app</AdditionalProperties>
<AdditionalProperties>TestTarget=ios-simulator-64;TestArch=$(TestArch);TestAppBundleName=System.Numerics.Vectors.Tests.app</AdditionalProperties>
</XHarnessAppleProject>

<!-- apple run / ios-simlator-64 -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=ios-simulator-64;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
<AdditionalProperties>TestTarget=ios-simulator-64;TestArch=$(TestArch);TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
</XHarnessAppleProject>

<!-- apple test / maccatalyst -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=maccatalyst;TestAppBundleName=System.Collections.NonGeneric.Tests.app</AdditionalProperties>
<AdditionalProperties>TestTarget=maccatalyst;TestArch=$(TestArch);TestAppBundleName=System.Collections.NonGeneric.Tests.app</AdditionalProperties>
</XHarnessAppleProject>

<!-- apple run / maccatalyst -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=maccatalyst;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
<AdditionalProperties>TestTarget=maccatalyst;TestArch=$(TestArch);TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42</AdditionalProperties>
</XHarnessAppleProject>

<!-- apple test / tvos-simulator -->
<XHarnessAppleProject Include="TestAppBundle.proj">
<AdditionalProperties>TestTarget=tvos-simulator;TestAppBundleName=Microsoft.Extensions.Configuration.Ini.Tests.app</AdditionalProperties>
<AdditionalProperties>TestTarget=tvos-simulator;TestArch=$(TestArch);TestAppBundleName=Microsoft.Extensions.Configuration.Ini.Tests.app</AdditionalProperties>
</XHarnessAppleProject>
</ItemGroup>

Expand Down
8 changes: 6 additions & 2 deletions tests/integration-tests/Apple/TestAppBundle.proj
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
<Import Project="../Storage.props"/>

<PropertyGroup>
<AppStorageUrl>$(AssetsBaseUri)/ios/test-app-new/$(TestTarget)</AppStorageUrl>
<AppStorageUrl>$(AssetsBaseUri)/ios/test-app-new/$(TestTarget)/$(TestArch)</AppStorageUrl>
<XHarnessTestAppBundleUrl>$(AppStorageUrl)/$(TestAppBundleName).zip</XHarnessTestAppBundleUrl>
<TestAppDestinationDir>$(ArtifactsTmpDir)test-app-new\$(TestTarget)</TestAppDestinationDir>
<TestAppDestinationDir>$(ArtifactsTmpDir)test-app-new\$(TestTarget)\$(TestArch)</TestAppDestinationDir>
</PropertyGroup>

<Target Name="Build" Returns="@(XHarnessAppFoldersToTest)">
<DownloadFile SourceUrl="$(XHarnessTestAppBundleUrl)" DestinationFolder="$(TestAppDestinationDir)" SkipUnchangedFiles="True" Retries="5">
<Output TaskParameter="DownloadedFile" ItemName="ZippedAppBundle" />
</DownloadFile>

<!--
The test apps have .zip extension but are actually tar.gz files. When updating the apps, make sure to compress them using tar.
E.g.: COPYFILE_DISABLE=1 tar - -no-xattrs - -no-acls - -no-mac-metadata -czf <TestAppBundleName>.zip <TestAppBundleName> (remove spaces - -)
-->
<Message Text="Downloaded $(TestAppBundleName) from @(ZippedAppBundle). Extracting..." Importance="High" />
<Exec Command="tar -xzf @(ZippedAppBundle) -C $(TestAppDestinationDir)" />
<Message Text="Extracted to $(TestAppDestinationDir)" Importance="High" />
Expand Down
Loading