[DevOps] As with jenkins, remove old simulators. (#9551)

This commit is contained in:
Manuel de la Pena 2020-08-31 13:19:34 -04:00 коммит произвёл GitHub
Родитель 819f5f95e0
Коммит 36ca984c12
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -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
@ -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
}
@ -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

Просмотреть файл

@ -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
@ -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
@ -197,6 +220,7 @@ function Clear-HD {
Write-Debug "Could not remove dir $dir - $_"
}
}
Get-PSDrive "/" | Format-Table -Wrap
}
@ -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