-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/7.0.2xx-xcode14.3] [dotnet] Add targets to compute mlaunch a…
…rguments for installing and launching mobile apps. Fixes #18359. (#18451) Add public targets to compute the mlaunch command lines for installing and launching mobile apps. These new targets are: * ComputeMlaunchInstallArguments * ComputeMlaunchRunArguments As part of this change, also create a few new public properties: * MlaunchPath * MlaunchRunArguments * MlaunchInstallArguments * MlaunchRunScript * MlaunchInstallScript If the *Script variables are set, the corresponding target will create a script file with the path to mlaunch + the corresponding arguments. Otherwise, it's also possible to get the arguments directly from the build log. Fixes #18359. Backport of #18446. --------- Co-authored-by: GitHub Actions Autoformatter <[email protected]>
- Loading branch information
1 parent
8606b32
commit c0f492f
Showing
4 changed files
with
178 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Diagnostics; | ||
using System.Text; | ||
|
||
using Mono.Cecil; | ||
|
||
using Xamarin.Tests; | ||
|
||
#nullable enable | ||
|
||
namespace Xamarin.Tests { | ||
[TestFixture] | ||
public class MlaunchTest : TestBaseClass { | ||
[Test] | ||
[TestCase (ApplePlatform.iOS, "ios-arm64")] | ||
[TestCase (ApplePlatform.TVOS, "tvos-arm64")] | ||
public void GetMlaunchInstallArguments (ApplePlatform platform, string runtimeIdentifiers) | ||
{ | ||
var project = "MySimpleApp"; | ||
Configuration.IgnoreIfIgnoredPlatform (platform); | ||
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); | ||
|
||
var outputPath = Path.Combine (Cache.CreateTemporaryDirectory (), "install.sh"); | ||
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); | ||
var properties = GetDefaultProperties (runtimeIdentifiers); | ||
properties ["EnableCodeSigning"] = "false"; // Skip code signing, since that would require making sure we have code signing configured on bots. | ||
|
||
// Create the app manifest first, since it's required to compute the mlaunch install arguments | ||
DotNet.Execute ("build", project_path, properties, target: "_DetectSdkLocations;_DetectAppManifest;_CompileAppManifest;_WriteAppManifest"); | ||
|
||
properties ["MlaunchInstallScript"] = outputPath; | ||
var rv = DotNet.Execute ("build", project_path, properties, target: "ComputeMlaunchInstallArguments"); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchInstallArguments", out var mlaunchInstallArguments)) | ||
Assert.Fail ("Could not find the property 'MlaunchInstallArguments' in the binlog."); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchPath", out var mlaunchPath)) | ||
Assert.Fail ("Could not find the property 'MlaunchPath' in the binlog."); | ||
Assert.That (mlaunchPath, Does.Exist, "mlaunch existence"); | ||
|
||
var expectedArguments = new StringBuilder (); | ||
expectedArguments.Append ("--installdev "); | ||
expectedArguments.Append (appPath.Substring (Path.GetDirectoryName (project_path)!.Length + 1)).Append ('/'); | ||
expectedArguments.Append ($" --wait-for-exit:false"); | ||
Assert.AreEqual (expectedArguments.ToString (), mlaunchInstallArguments); | ||
|
||
var scriptContents = File.ReadAllText (outputPath).Trim ('\n'); ; | ||
var expectedScriptContents = mlaunchPath + " " + expectedArguments.ToString (); | ||
Assert.AreEqual (expectedScriptContents, scriptContents, "Script contents"); | ||
} | ||
|
||
[Test] | ||
[TestCase (ApplePlatform.iOS, "iossimulator-x64;iossimulator-arm64", ":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-16-4,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro")] | ||
[TestCase (ApplePlatform.iOS, "ios-arm64", "")] | ||
[TestCase (ApplePlatform.TVOS, "tvossimulator-arm64", ":v2:runtime=com.apple.CoreSimulator.SimRuntime.tvOS-16-4,devicetype=com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-1080p")] | ||
public void GetMlaunchRunArguments (ApplePlatform platform, string runtimeIdentifiers, string device) | ||
{ | ||
var project = "MySimpleApp"; | ||
Configuration.IgnoreIfIgnoredPlatform (platform); | ||
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); | ||
|
||
var outputPath = Path.Combine (Cache.CreateTemporaryDirectory (), "launch.sh"); | ||
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); | ||
var properties = GetDefaultProperties (runtimeIdentifiers); | ||
properties ["EnableCodeSigning"] = "false"; // Skip code signing, since that would require making sure we have code signing configured on bots. | ||
|
||
// Create the app manifest first, since it's required to compute the mlaunch run arguments | ||
DotNet.Execute ("build", project_path, properties, target: "_DetectSdkLocations;_DetectAppManifest;_CompileAppManifest;_WriteAppManifest"); | ||
|
||
properties ["MlaunchRunScript"] = outputPath; | ||
var rv = DotNet.Execute ("build", project_path, properties, target: "ComputeMlaunchRunArguments"); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchRunArguments", out var mlaunchRunArguments)) | ||
Assert.Fail ("Could not find the property 'MlaunchRunArguments' in the binlog."); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchPath", out var mlaunchPath)) | ||
Assert.Fail ("Could not find the property 'MlaunchPath' in the binlog."); | ||
Assert.That (mlaunchPath, Does.Exist, "mlaunch existence"); | ||
|
||
var expectedArguments = new StringBuilder (); | ||
var isSim = runtimeIdentifiers.Contains ("simulator"); | ||
expectedArguments.Append (isSim ? "--launchsim " : "--launchdev "); | ||
expectedArguments.Append (appPath.Substring (Path.GetDirectoryName (project_path)!.Length + 1)).Append ('/'); | ||
if (isSim) { | ||
expectedArguments.Append (" --device \""); | ||
expectedArguments.Append (device); | ||
expectedArguments.Append ('"'); | ||
} | ||
expectedArguments.Append ($" --wait-for-exit:true"); | ||
Assert.AreEqual (expectedArguments.ToString (), mlaunchRunArguments); | ||
|
||
var scriptContents = File.ReadAllText (outputPath).Trim ('\n'); ; | ||
var expectedScriptContents = mlaunchPath + " " + expectedArguments.ToString (); | ||
Assert.AreEqual (expectedScriptContents, scriptContents, "Script contents"); | ||
} | ||
} | ||
} |
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.