Skip to content

Commit

Permalink
[DevOps] As with jenkins, remove old simulators. (#9552)
Browse files Browse the repository at this point in the history
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
  • Loading branch information
monojenkins and mandel-macaque authored Aug 31, 2020
1 parent e6edafe commit ab3839a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/devops/device-tests/scripts/System.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Describe 'Clear-HD' {
# call the method, and check that remove-item was correctly called with each of the files we want to remove

Mock Remove-Item
Mock Remove-InstalledSimulators
# mock test path to always return true, that is all dirs are present
Mock Test-Path {
return $True
Expand All @@ -38,6 +39,7 @@ Describe 'Clear-HD' {

Clear-HD

Assert-MockCalled -CommandName Remove-InstalledSimulators -Times 1
Assert-MockCalled -CommandName Remove-Item -Times $directories.Count -Scope It

}
Expand Down Expand Up @@ -77,9 +79,11 @@ Describe 'Clear-HD' {
Mock Test-Path {
return $Path -in $presentDirectories
}
Mock Remove-InstalledSimulators

Clear-HD

Assert-MockCalled -CommandName Remove-InstalledSimulators -Times 1
$debugCalls = $directories.Count - $presentDirectories.Count
Assert-MockCalled -CommandName Remove-Item -Times $presentDirectories.Count -Scope It
Assert-MockCalled -CommandName Write-Debug -Times $debugCalls -Scope It
Expand Down
25 changes: 25 additions & 0 deletions tools/devops/device-tests/scripts/System.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ function Get-MonoVersion {
return $rv
}

<#
.SYNOPSIS
Removes all the installed simulators in the system.
#>
function Remove-InstalledSimulators {
param()
# use the .Net libs to execute the process
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "/Applications/Xcode.app/Contents/Developer/usr/bin/simctl"
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = "delete all"

$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
}

<#
.SYNOPSIS
Returns the details of the system that is currently executing the
Expand Down Expand Up @@ -162,6 +181,10 @@ function Clear-XamarinProcesses {
Remove known paths and directories that are not needed for the tests.
#>
function Clear-HD {

# Delete all the simulator devices. Rolf: These can take up a lot of space over time (I've seen 100+GB on the bots)
Remove-InstalledSimulators

# print the current state of the HD
Get-PSDrive "/" | Format-Table -Wrap

Expand Down Expand Up @@ -197,6 +220,7 @@ function Clear-HD {
Write-Error "Could not remove dir $dir - $_"
}
}

Get-PSDrive "/" | Format-Table -Wrap
}

Expand Down Expand Up @@ -253,3 +277,4 @@ Export-ModuleMember -Function Clear-XamarinProcesses
Export-ModuleMember -Function Clear-HD
Export-ModuleMember -Function Test-HDFreeSpace
Export-ModuleMember -Function Clear-AfterTests
Export-ModuleMember -Function Remove-InstalledSimulators

1 comment on commit ab3839a

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Install Provisioning Profiles' 🔥 : hudson.AbortException: script returned exit code 104

Provisioning succeeded
Build succeeded
✅ Packages built successfully

View packages

Please sign in to comment.