-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[testing] Enable a way to test on real devices #19492
Changes from all commits
abbd90b
10a4122
fb1e7bf
9ee60ce
97aec9e
059ba24
4ebf24b
b89de2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,9 @@ string DEVICE_OS = ""; | |
|
||
// other | ||
string PLATFORM = TEST_DEVICE.ToLower().Contains("simulator") ? "iPhoneSimulator" : "iPhone"; | ||
string DOTNET_PLATFORM = TEST_DEVICE.ToLower().Contains("simulator") ? "iossimulator-x64" : "ios-arm64"; | ||
string DOTNET_PLATFORM = TEST_DEVICE.ToLower().Contains("simulator") ? | ||
$"iossimulator-{System.Runtime.InteropServices.RuntimeInformation.OSArchitecture.ToString().ToLower()}" | ||
: $"ios-arm64"; | ||
string CONFIGURATION = Argument("configuration", "Debug"); | ||
bool DEVICE_CLEANUP = Argument("cleanup", true); | ||
string TEST_FRAMEWORK = "net472"; | ||
|
@@ -63,6 +65,9 @@ Setup(context => | |
|
||
Information($"DOTNET_TOOL_PATH {DOTNET_TOOL_PATH}"); | ||
|
||
Information("Host OS System Arch: {0}", System.Runtime.InteropServices.RuntimeInformation.OSArchitecture); | ||
Information("Host Processor System Arch: {0}", System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture); | ||
|
||
// only grab attached iOS devices if we are trying to test on device | ||
if (TEST_DEVICE.Contains("device")) | ||
{ | ||
|
@@ -93,7 +98,16 @@ void Cleanup() | |
Information("No simulators found to delete."); | ||
return; | ||
} | ||
var xharness = sims.Where(s => s.Name.Contains("XHarness")).ToArray(); | ||
var simulatorName = "XHarness"; | ||
if(iosVersion.Contains("17")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to open a bug on. xharness about this it seems it doesn't have the "Created by XHarness" if it's a iPhone 15. this leads to sometimes delete existing simulators. |
||
simulatorName = "iPhone 15"; | ||
Information("Looking for simulator: {0} iosversion {1}", simulatorName, iosVersion); | ||
var xharness = sims.Where(s => s.Name.Contains(simulatorName))?.ToArray(); | ||
if(xharness == null || xharness.Length == 0) | ||
{ | ||
Information("No XHarness simulators found to delete."); | ||
return; | ||
} | ||
foreach (var sim in xharness) { | ||
Information("Deleting XHarness simulator {0} ({1})...", sim.Name, sim.UDID); | ||
StartProcess("xcrun", "simctl shutdown " + sim.UDID); | ||
|
@@ -185,8 +199,8 @@ Task("Test") | |
TEST_APP = apps.First().FullPath; | ||
} | ||
else { | ||
Error("Error: Couldn't find .app file"); | ||
throw new Exception("Error: Couldn't find .app file"); | ||
Error($"Error: Couldn't find *.app file in {binDir}"); | ||
throw new Exception($"Error: Couldn't find *.app file in {binDir}"); | ||
} | ||
} | ||
if (string.IsNullOrEmpty(TEST_RESULTS)) { | ||
|
@@ -219,12 +233,25 @@ Task("Test") | |
var settings = new DotNetToolSettings { | ||
ToolPath = DOTNET_TOOL_PATH, | ||
DiagnosticOutput = true, | ||
ArgumentCustomization = args => args.Append("run xharness apple test " + | ||
$"--app=\"{TEST_APP}\" " + | ||
$"--targets=\"{TEST_DEVICE}\" " + | ||
$"--output-directory=\"{TEST_RESULTS}\" " + | ||
xcode_args + | ||
$"--verbosity=\"Debug\" ") | ||
ArgumentCustomization = args => | ||
{ | ||
args.Append("run xharness apple test " + | ||
$"--app=\"{TEST_APP}\" " + | ||
$"--targets=\"{TEST_DEVICE}\" " + | ||
$"--output-directory=\"{TEST_RESULTS}\" " + | ||
xcode_args + | ||
$"--verbosity=\"Debug\" "); | ||
|
||
if (TEST_DEVICE.Contains("device")) | ||
{ | ||
if(string.IsNullOrEmpty(DEVICE_UDID)) | ||
{ | ||
throw new Exception("No device was found to install the app on. See the Setup method for more details."); | ||
} | ||
args.Append($"--device=\"{DEVICE_UDID}\" "); | ||
} | ||
return args; | ||
} | ||
}; | ||
|
||
bool testsFailed = true; | ||
|
@@ -468,35 +495,45 @@ void GetDevices(string version) | |
}; | ||
} | ||
}); | ||
Information("List count: {0}", list.Count); | ||
//this removes the extra lines from output | ||
if(list.Count == 0) | ||
{ | ||
throw new Exception($"No devices found"); | ||
return; | ||
} | ||
list.Remove(list.Last()); | ||
list.Remove(list.Last()); | ||
foreach (var item in list) | ||
{ | ||
Information("Device: {0}", item.Trim()); | ||
var parts = item.Trim().Split(" ",StringSplitOptions.RemoveEmptyEntries); | ||
if(item.Contains("iPhone")) | ||
var stringToTest = $"Device: {item.Trim()}"; | ||
Information(stringToTest); | ||
var regex = new System.Text.RegularExpressions.Regex(@"Device:\s+((?:[^\s]+(?:\s+[^\s]+)*)?)\s+([0-9A-Fa-f-]+)\s+([\d.]+)\s+(iPhone|iPad)\s+iOS"); | ||
var match = regex.Match(stringToTest); | ||
if(match.Success) | ||
{ | ||
deviceOS = "iPhone"; | ||
} | ||
if(item.Contains("iPad iOS")) | ||
{ | ||
deviceOS = "iPad iOS"; | ||
deviceName = match.Groups[1].Value; | ||
deviceUdid = match.Groups[2].Value; | ||
deviceVersion = match.Groups[3].Value; | ||
deviceOS = match.Groups[4].Value; | ||
Information("DeviceName:{0} udid:{1} version:{2} os:{3}", deviceName, deviceUdid, deviceVersion, deviceOS); | ||
if(version.Contains(deviceVersion.Split(".")[0])) | ||
{ | ||
Information("We want this device: {0} {1} because it matches {2}", deviceName, deviceVersion, version); | ||
DEVICE_UDID = deviceUdid; | ||
DEVICE_VERSION = deviceVersion; | ||
DEVICE_NAME = deviceName; | ||
DEVICE_OS = deviceOS; | ||
break; | ||
} | ||
} | ||
|
||
deviceName = parts[0].Trim(); | ||
deviceUdid = parts[1].Trim(); | ||
deviceVersion = parts[2].Trim(); | ||
Information("DeviceName:{0} udid:{1} version:{2} os:{3}", deviceName, deviceUdid, deviceVersion, deviceOS); | ||
|
||
if(version.Contains(deviceVersion.Split(".")[0])) | ||
{ | ||
Information("We want this device: {0} {1} because it matches {2}", deviceName, deviceVersion, version); | ||
DEVICE_UDID = deviceUdid; | ||
DEVICE_VERSION = deviceVersion; | ||
DEVICE_NAME = deviceName; | ||
DEVICE_OS = deviceOS; | ||
break; | ||
else | ||
{ | ||
Information("No match found for {0}", stringToTest); | ||
} | ||
} | ||
if(string.IsNullOrEmpty(DEVICE_UDID)) | ||
{ | ||
throw new Exception($"No devices found for version {version}"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,13 +107,13 @@ stages: | |
agentPoolAccessToken: $(AgentPoolAccessToken) | ||
${{ if or(parameters.BuildEverything, and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'devdiv'))) }}: | ||
androidApiLevels: [ 33, 30, 29, 28, 27, 26, 25, 24, 23 ] | ||
iosVersions: [ '16.4', '15.5', '14.5'] | ||
iosVersions: [ 'simulator-16.4','simulator-15.5','simulator-14.5' ] | ||
catalystVersions: [ 'latest' ] | ||
windowsVersions: ['packaged', 'unpackaged'] | ||
provisionatorChannel: ${{ parameters.provisionatorChannel }} | ||
${{ if not(or(parameters.BuildEverything, and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'devdiv')))) }}: | ||
androidApiLevels: [ 30, 23 ] | ||
iosVersions: [ '16.4' ] | ||
iosVersions: [ 'simulator-16.4' ] | ||
catalystVersions: [ 'latest' ] | ||
windowsVersions: ['packaged', 'unpackaged'] | ||
provisionatorChannel: ${{ parameters.provisionatorChannel }} | ||
|
@@ -144,7 +144,7 @@ stages: | |
windows: $(System.DefaultWorkingDirectory)/src/Core/tests/DeviceTests/Core.DeviceTests.csproj | ||
- name: controls | ||
desc: Controls | ||
androidApiLevelsExclude: [25] # Ignore for now API25 since the runs's are not stable | ||
androidApiLevelsExclude: [27, 25] # Ignore for now API25 since the runs's are not stable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disable API27 since is not stable |
||
windowsPackageId: 'com.microsoft.maui.controls.devicetests' | ||
android: $(System.DefaultWorkingDirectory)/src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj | ||
ios: $(System.DefaultWorkingDirectory)/src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a device we always want arm64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I thought we had this architecture stuff in here already? Maybe I'm thinking of that ARM PR I still need to finish...