Fix iOS log exports (#23334)
* Fix ios Device Logging * - fix up device test logging a bit more * Update ui-tests-steps.yml * Update ui-tests-steps.yml * Update ios.cake * Update ui-tests-steps.yml * Update maui-templates.yml * Update maui-templates.yml
This commit is contained in:
Родитель
6a414ea85a
Коммит
9251b38bd5
|
@ -44,7 +44,7 @@ var dotnetToolPath = GetDotnetToolPath();
|
|||
Setup(context =>
|
||||
{
|
||||
LogSetupInfo(dotnetToolPath);
|
||||
PerformCleanupIfNeeded(deviceCleanupEnabled);
|
||||
PerformCleanupIfNeeded(deviceCleanupEnabled, false);
|
||||
|
||||
// Device or simulator setup
|
||||
if (testDevice.Contains("device"))
|
||||
|
@ -58,7 +58,7 @@ Setup(context =>
|
|||
}
|
||||
});
|
||||
|
||||
Teardown(context => PerformCleanupIfNeeded(deviceCleanupEnabled));
|
||||
Teardown(context => PerformCleanupIfNeeded(deviceCleanupEnabled, true));
|
||||
|
||||
Task("Cleanup");
|
||||
|
||||
|
@ -307,15 +307,59 @@ void ExecuteCGLegacyUITests(string project, string appProject, string device, st
|
|||
|
||||
// Helper methods
|
||||
|
||||
void PerformCleanupIfNeeded(bool cleanupEnabled)
|
||||
void PerformCleanupIfNeeded(bool cleanupEnabled, bool createDeviceLogs)
|
||||
{
|
||||
if (cleanupEnabled)
|
||||
{
|
||||
var logDirectory = GetLogDirectory();
|
||||
Information("Cleaning up...");
|
||||
Information("Deleting XHarness simulator if exists...");
|
||||
var sims = ListAppleSimulators().Where(s => s.Name.Contains("XHarness")).ToArray();
|
||||
foreach (var sim in sims)
|
||||
{
|
||||
if(createDeviceLogs)
|
||||
{
|
||||
try
|
||||
{
|
||||
var homeDirectory = Environment.GetEnvironmentVariable("HOME");
|
||||
Information("Diagnostics Reports");
|
||||
StartProcess("zip", new ProcessSettings {
|
||||
Arguments = new ProcessArgumentBuilder()
|
||||
.Append("-9r")
|
||||
.AppendQuoted($"{logDirectory}/DiagnosticReports_{sim.UDID}.zip")
|
||||
.AppendQuoted($"{homeDirectory}/Library/Logs/DiagnosticReports/"),
|
||||
RedirectStandardOutput = false
|
||||
});
|
||||
|
||||
Information("CoreSimulator");
|
||||
StartProcess("zip", new ProcessSettings {
|
||||
Arguments = new ProcessArgumentBuilder()
|
||||
.Append("-9r")
|
||||
.AppendQuoted($"{logDirectory}/CoreSimulator_{sim.UDID}.zip")
|
||||
.AppendQuoted($"{homeDirectory}/Library/Logs/CoreSimulator/{sim.UDID}"),
|
||||
RedirectStandardOutput = false
|
||||
});
|
||||
|
||||
StartProcess("xcrun", $"simctl spawn {sim.UDID} log collect --output {homeDirectory}/{sim.UDID}_log.logarchive");
|
||||
|
||||
StartProcess("zip", new ProcessSettings {
|
||||
Arguments = new ProcessArgumentBuilder()
|
||||
.Append("-9r")
|
||||
.AppendQuoted($"{logDirectory}/{sim.UDID}_log.logarchive.zip")
|
||||
.AppendQuoted($"{homeDirectory}/{sim.UDID}_log.logarchive"),
|
||||
RedirectStandardOutput = false
|
||||
});
|
||||
|
||||
var screenshotPath = $"{testResultsPath}/{sim.UDID}_screenshot.png";
|
||||
StartProcess("xcrun", $"simctl io {sim.UDID} screenshot {screenshotPath}");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Information($"Failed to collect logs for simulator {sim.Name} ({sim.UDID}): {ex.Message}");
|
||||
Information($"Command Executed: simctl spawn {sim.UDID} log collect --output {logDirectory}/{sim.UDID}_log.logarchive");
|
||||
}
|
||||
}
|
||||
|
||||
Information($"Deleting XHarness simulator {sim.Name} ({sim.UDID})...");
|
||||
StartProcess("xcrun", $"simctl shutdown {sim.UDID}");
|
||||
ExecuteWithRetries(() => StartProcess("xcrun", $"simctl delete {sim.UDID}"), 3);
|
||||
|
|
|
@ -79,14 +79,6 @@ steps:
|
|||
Write-Host "##vso[task.setvariable variable=Platform.Name]${platformName}"
|
||||
displayName: 'Set Platform.Name'
|
||||
|
||||
- ${{ if eq(parameters.platform, 'ios')}}:
|
||||
- bash: |
|
||||
if [ -f "$HOME/Library/Logs/CoreSimulator/*" ]; then rm -r $HOME/Library/Logs/CoreSimulator/*; fi
|
||||
if [ -f "$HOME/Library/Logs/DiagnosticReports/*" ]; then rm -r $HOME/Library/Logs/DiagnosticReports/*; fi
|
||||
displayName: Delete Old Simulator Logs
|
||||
condition: always()
|
||||
continueOnError: true
|
||||
|
||||
- ${{ if eq(parameters.platform, 'windows')}}:
|
||||
- pwsh: |
|
||||
$errorPath = "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"
|
||||
|
@ -113,10 +105,8 @@ steps:
|
|||
|
||||
- ${{ if eq(parameters.platform, 'ios')}}:
|
||||
- bash: |
|
||||
suffix=$(date +%Y%m%d%H%M%S)
|
||||
zip -9r "$(LogDirectory)/CoreSimulatorLog_${suffix}.zip" "$HOME/Library/Logs/CoreSimulator/"
|
||||
zip -9r "$(LogDirectory)/DiagnosticReports_${suffix}.zip" "$HOME/Library/Logs/DiagnosticReports/"
|
||||
displayName: Zip Simulator Logs
|
||||
pwsh ./build.ps1 --target=Cleanup -Script eng/devices/${{ parameters.platform }}.cake ---results="$(TestResultsDirectory)" ${{ parameters.cakeArgs }}
|
||||
displayName: Cleanup and Create Simulator Logs if Test Run Failed To
|
||||
condition: always()
|
||||
continueOnError: true
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ stages:
|
|||
clean: all
|
||||
displayName: "iOS tests"
|
||||
pool: ${{ parameters.iosPool }}
|
||||
timeoutInMinutes: 140
|
||||
timeoutInMinutes: 45
|
||||
strategy:
|
||||
matrix:
|
||||
# create all the variables used for the matrix
|
||||
|
|
|
@ -170,14 +170,6 @@ jobs:
|
|||
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
|
||||
PRIVATE_BUILD: $(PrivateBuild)
|
||||
|
||||
- ${{ if eq(RunPlatform.testName, 'RunOniOS') }}:
|
||||
- bash: |
|
||||
if [ -f "$HOME/Library/Logs/CoreSimulator/*" ]; then rm -r $HOME/Library/Logs/CoreSimulator/*; fi
|
||||
if [ -f "$HOME/Library/Logs/DiagnosticReports/*" ]; then rm -r $HOME/Library/Logs/DiagnosticReports/*; fi
|
||||
displayName: Delete Old Simulator Logs
|
||||
condition: always()
|
||||
continueOnError: true
|
||||
|
||||
# - script: dotnet tool update Microsoft.DotNet.XHarness.CLI --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json --version "9.0.0-prerelease*" -g
|
||||
# displayName: install xharness
|
||||
|
||||
|
@ -200,11 +192,8 @@ jobs:
|
|||
IOS_TEST_DEVICE: ios-simulator-64_17.2
|
||||
|
||||
- ${{ if eq(RunPlatform.testName, 'RunOniOS') }}:
|
||||
- bash: |
|
||||
suffix=$(date +%Y%m%d%H%M%S)
|
||||
zip -9r "$(LogDirectory)/CoreSimulatorLog_${suffix}.zip" "$HOME/Library/Logs/CoreSimulator/"
|
||||
zip -9r "$(LogDirectory)/DiagnosticReports_${suffix}.zip" "$HOME/Library/Logs/DiagnosticReports/"
|
||||
displayName: Zip Simulator Logs
|
||||
- pwsh: ./build.ps1 --target=Cleanup -Script eng/devices/ios.cake ---results="$(TestResultsDirectory)" ${{ parameters.cakeArgs }}
|
||||
displayName: Cleanup and Create Simulator Logs if Test Run Failed To
|
||||
condition: always()
|
||||
continueOnError: true
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ steps:
|
|||
$command += " --test-filter ""$testFilter"""
|
||||
}
|
||||
|
||||
Invoke-Expression $command
|
||||
Invoke-Expression $command
|
||||
displayName: $(Agent.JobName)
|
||||
${{ if ne(parameters.platform, 'android')}}:
|
||||
retryCountOnTaskFailure: 1
|
||||
|
@ -107,10 +107,8 @@ steps:
|
|||
APPIUM_HOME: $(APPIUM_HOME)
|
||||
|
||||
- bash: |
|
||||
suffix=$(date +%Y%m%d%H%M%S)
|
||||
zip -9r "$(LogDirectory)/CoreSimulatorLog_${suffix}.zip" "$HOME/Library/Logs/CoreSimulator/"
|
||||
zip -9r "$(LogDirectory)/DiagnosticReports_${suffix}.zip" "$HOME/Library/Logs/DiagnosticReports/"
|
||||
displayName: Zip Simulator Logs
|
||||
pwsh ./build.ps1 --target=Cleanup -Script eng/devices/${{ parameters.platform }}.cake ---results="$(TestResultsDirectory)" ${{ parameters.cakeArgs }}
|
||||
displayName: Cleanup and Create Simulator Logs if Test Run Failed To
|
||||
condition: ${{ eq(parameters.platform, 'ios') }}
|
||||
continueOnError: true
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче