fix tests

This commit is contained in:
Maxim Lobanov
2020-11-03 09:13:58 +03:00
parent 8f1f707032
commit 8c96dbb9bb
3 changed files with 56 additions and 43 deletions

View File

@@ -99,7 +99,7 @@ function Build-XcodeTable {
} }
} }
function Get-XcodeDevicesList { function Build-XcodeDevicesList {
param ( param (
[Parameter(Mandatory)][object] $XcodeInfo, [Parameter(Mandatory)][object] $XcodeInfo,
[Parameter(Mandatory)][object] $Runtime [Parameter(Mandatory)][object] $Runtime
@@ -188,7 +188,7 @@ function Build-XcodeSimulatorsTable {
$xcodeInfo.Values | ForEach-Object { $xcodeInfo.Values | ForEach-Object {
$runtimeFound = $_.SimulatorsInfo.runtimes | Where-Object { $_.identifier -eq $runtime.identifier } | Select-Object -First 1 $runtimeFound = $_.SimulatorsInfo.runtimes | Where-Object { $_.identifier -eq $runtime.identifier } | Select-Object -First 1
if ($runtimeFound) { if ($runtimeFound) {
$devicesToAdd = Get-XcodeDevicesList -XcodeInfo $_ -Runtime $runtimeFound $devicesToAdd = Build-XcodeDevicesList -XcodeInfo $_ -Runtime $runtimeFound
$runtimeDevices += $devicesToAdd | Select-Object -ExpandProperty name $runtimeDevices += $devicesToAdd | Select-Object -ExpandProperty name
$xcodeList += $_.VersionInfo.Version $xcodeList += $_.VersionInfo.Version
} }

View File

@@ -136,11 +136,15 @@
"scripts": [ "scripts": [
"./provision/core/xcode-clt.sh", "./provision/core/xcode-clt.sh",
"./provision/core/homebrew.sh", "./provision/core/homebrew.sh",
"./provision/core/dotnet.sh",
"./provision/core/python.sh",
"./provision/core/azcopy.sh", "./provision/core/azcopy.sh",
"./provision/core/openssl.sh", "./provision/core/openssl.sh",
"./provision/core/ruby.sh", "./provision/core/ruby.sh",
"./provision/core/rubygem.sh", "./provision/core/rubygem.sh",
"./provision/core/powershell.sh" "./provision/core/powershell.sh",
"./provision/core/git.sh",
"./provision/core/node.sh"
] ]
}, },
{ {

View File

@@ -8,6 +8,16 @@ $latestXcodeVersion = $xcodeVersions | Select-Object -First 1
$os = Get-OSVersion $os = Get-OSVersion
Describe "Xcode" { Describe "Xcode" {
$testCases = $xcodeVersions | ForEach-Object { @{ XcodeVersion = $_.link; LatestXcodeVersion = $xcodeVersions[0].link; Symlinks = $_.symlinks } }
Context "Versions" {
It "<XcodeVersion>" -TestCases $testCases {
$xcodebuildPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "xcodebuild"
"$xcodebuildPath -version" | Should -ReturnZeroExitCode
}
}
Context "Default" {
$defaultXcodeTestCase = @{ DefaultXcode = $defaultXcode } $defaultXcodeTestCase = @{ DefaultXcode = $defaultXcode }
It "Default Xcode is <DefaultXcode>" -TestCases $defaultXcodeTestCase { It "Default Xcode is <DefaultXcode>" -TestCases $defaultXcodeTestCase {
"xcodebuild -version" | Should -ReturnZeroExitCode "xcodebuild -version" | Should -ReturnZeroExitCode
@@ -21,14 +31,9 @@ Describe "Xcode" {
$expectedTarget | Should -Exist $expectedTarget | Should -Exist
(Get-Item $xcodeApp).Target | Should -Be $expectedTarget (Get-Item $xcodeApp).Target | Should -Be $expectedTarget
} }
$testCases = $xcodeVersions | ForEach-Object { @{ XcodeVersion = $_.link; LatestXcodeVersion = $xcodeVersions[0].link; Symlinks = $_.symlinks } }
It "<XcodeVersion>" -TestCases $testCases {
$xcodebuildPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "xcodebuild"
"$xcodebuildPath -version" | Should -ReturnZeroExitCode
} }
Context "Additional tools" {
It "Xcode <XcodeVersion> tools are installed" -TestCases $testCases -Skip:($os.IsHighSierra) { It "Xcode <XcodeVersion> tools are installed" -TestCases $testCases -Skip:($os.IsHighSierra) {
$TOOLS_NOT_INSTALLED_EXIT_CODE = 69 $TOOLS_NOT_INSTALLED_EXIT_CODE = 69
$xcodebuildPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "xcodebuild" $xcodebuildPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "xcodebuild"
@@ -40,15 +45,18 @@ Describe "Xcode" {
$result.ExitCode | Should -BeIn (0, $TOOLS_NOT_INSTALLED_EXIT_CODE) $result.ExitCode | Should -BeIn (0, $TOOLS_NOT_INSTALLED_EXIT_CODE)
} }
} }
}
It "Xcode <XcodeVersion> has correct beta symlink" -TestCases $testCases { Context "Symlinks" {
It "Xcode <XcodeVersion> has correct symlinks" -TestCases $testCases {
$sourcePath = Get-XcodeRootPath -Version $XcodeVersion $sourcePath = Get-XcodeRootPath -Version $XcodeVersion
$Symlinks | ForEach-Object { $Symlinks | Where-Object { $_ } | ForEach-Object {
$targetPath = Get-XcodeRootPath -Version $_ $targetPath = Get-XcodeRootPath -Version $_
$targetPath | Should -Exist $targetPath | Should -Exist
(Get-Item $targetPath).Target | Should -Be $sourcePath (Get-Item $targetPath).Target | Should -Be $sourcePath
} }
} }
}
It "/Applications/Xcode* symlinks are valid" { It "/Applications/Xcode* symlinks are valid" {
$symlinks = Get-ChildItem "/Applications" -Filter "Xcode*" | Where-Object { $_.LinkType } $symlinks = Get-ChildItem "/Applications" -Filter "Xcode*" | Where-Object { $_.LinkType }
@@ -82,23 +90,24 @@ Describe "XCODE_DEVELOPER_DIR variables" {
} }
Describe "Xcode simulators" { Describe "Xcode simulators" {
$xcodeVersions | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object { $xcodeVersions.link | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object {
Switch-Xcode -Version $_
Context "$_" { Context "$_" {
It "No duplicates in devices" { $testCase = @{ XcodeVersion = $_ }
It "No duplicates in devices" -TestCases $testCase {
Switch-Xcode -Version $XcodeVersion
[array]$devicesList = @(Get-XcodeDevicesList | Where-Object { $_ }) [array]$devicesList = @(Get-XcodeDevicesList | Where-Object { $_ })
Validate-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators" Validate-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators"
} }
It "No duplicates in pairs" { It "No duplicates in pairs" -TestCases $testCase {
Switch-Xcode -Version $XcodeVersion
[array]$pairsList = @(Get-XcodePairsList | Where-Object { $_ }) [array]$pairsList = @(Get-XcodePairsList | Where-Object { $_ })
Validate-ArrayWithoutDuplicates $pairsList -Because "Found duplicate pairs simulators" Validate-ArrayWithoutDuplicates $pairsList -Because "Found duplicate pairs simulators"
} }
} }
} }
AfterAll { AfterEach {
$defaultXcode = Get-ToolsetValue "xcode.default" $defaultXcode = Get-ToolsetValue "xcode.default"
Switch-Xcode -Version $defaultXcode Switch-Xcode -Version $defaultXcode
} }