[macOS] Refactor Common.Helpers (#8924)

* [macOS] Refactor Common.Helpers

* Update readme file

* Remove unnecessary double quotes

---------

Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
This commit is contained in:
Alexey-Ayupov
2023-12-04 12:13:08 +01:00
committed by GitHub
parent ff1dc02cbc
commit 69db5c6c63
46 changed files with 292 additions and 359 deletions

View File

@@ -6,9 +6,9 @@ $os = Get-OSVersion
Describe "Android" {
$androidSdkManagerPackages = Get-AndroidPackages
[int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version"
[version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version"
[array]$ndkVersions = Get-ToolsetValue "android.ndk.versions"
[int]$platformMinVersion = (Get-ToolsetContent).android.platform_min_version
[version]$buildToolsMinVersion = (Get-ToolsetContent).android.build_tools_min_version
[array]$ndkVersions = (Get-ToolsetContent).android.ndk.versions
$ndkFullVersions = $ndkVersions | ForEach-Object { Get-ChildItem "$env:ANDROID_HOME/ndk/${_}.*" -Name | Select-Object -Last 1 } | ForEach-Object { "ndk/${_}" }
# Platforms starting with a letter are the preview versions, which is not installed on the image
$platformVersionsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("platforms;") }) -replace 'platforms;android-', '' | Where-Object { $_ -match "^\d" } | Sort-Object -Unique
@@ -25,9 +25,9 @@ Describe "Android" {
$platformsInstalled,
$buildTools,
$ndkFullVersions,
(Get-ToolsetValue "android.extra-list" | ForEach-Object { "extras/${_}" }),
(Get-ToolsetValue "android.addon-list" | ForEach-Object { "add-ons/${_}" }),
(Get-ToolsetValue "android.additional-tools")
((Get-ToolsetContent).android.extras | ForEach-Object { "extras/${_}" }),
((Get-ToolsetContent).android.addons | ForEach-Object { "add-ons/${_}" }),
((Get-ToolsetContent).android.additional_tools)
) | ForEach-Object { $_ }
# Remove empty strings from array to avoid possible issues
@@ -36,10 +36,10 @@ Describe "Android" {
BeforeAll {
$ANDROID_SDK_DIR = Join-Path $env:HOME "Library" "Android" "sdk"
function Validate-AndroidPackage {
function Confirm-AndroidPackage {
param (
[Parameter(Mandatory = $true)]
[string]$PackageName
[string] $PackageName
)
# Convert 'm2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1' ->
@@ -76,7 +76,7 @@ Describe "Android" {
It "<PackageName>" -TestCases $testCases {
param ([string] $PackageName)
Validate-AndroidPackage $PackageName
Confirm-AndroidPackage $PackageName
}
}
}

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Azure CLI" {
@@ -173,7 +174,7 @@ Describe "Homebrew" {
Describe "Kotlin" {
$kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlinc-jvm", "kotlin-dce-js")
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
"$toolName -version" | Should -ReturnZeroExitCode
}
}

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Chrome" {

View File

@@ -10,7 +10,7 @@ Describe ".NET" {
}
Describe "GCC" {
$testCases = Get-ToolsetValue -KeyPath gcc.versions | ForEach-Object { @{Version = $_ } }
$testCases = (Get-ToolsetContent).gcc.versions | ForEach-Object { @{Version = $_ } }
It "GCC <Version>" -TestCases $testCases {
param (
@@ -60,7 +60,7 @@ Describe "AzCopy" {
Describe "Miniconda" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Conda" {
Get-EnvironmentVariable "CONDA" | Should -Not -BeNullOrEmpty
[System.Environment]::GetEnvironmentVariable("CONDA") | Should -Not -BeNullOrEmpty
$condaBinPath = Join-Path $env:CONDA "bin" "conda"
"$condaBinPath --version" | Should -ReturnZeroExitCode
}
@@ -79,8 +79,8 @@ Describe "CocoaPods" {
}
Describe "VSMac" -Skip:($os.IsVentura -or $os.IsSonoma) {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
$vsMacVersions = (Get-ToolsetContent).xamarin.vsmac.versions
$defaultVSMacVersion = (Get-ToolsetContent).xamarin.vsmac.default
$testCases = $vsMacVersions | ForEach-Object {
$vsPath = "/Applications/Visual Studio $_.app"

View File

@@ -7,14 +7,14 @@ Describe "MongoDB" -Skip:($os.IsVentura -or $os.IsSonoma) {
@{ ToolName = "mongo" }
@{ ToolName = "mongod" }
) {
$toolsetVersion = Get-ToolsetValue 'mongodb.version'
$toolsetVersion = (Get-ToolsetContent).mongodb.version
(&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
}
}
Describe "PostgreSQL" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "PostgreSQL version should correspond to the version in the toolset" {
$toolsetVersion = Get-ToolsetValue 'postgresql.version'
$toolsetVersion = (Get-ToolsetContent).postgresql.version
# Client version
(psql --version).split()[-2] | Should -BeLike "$toolsetVersion*"
# Server version

View File

@@ -1,5 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Git" {
It "git is installed" {
"git --version" | Should -ReturnZeroExitCode

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Haskell" -Skip:($os.IsVentura -or $os.IsSonoma) {

View File

@@ -1,11 +1,6 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
# Validates that tool is installed and in PATH
function Validate-ToolExist($tool) {
Get-Command $tool -ErrorAction SilentlyContinue | Should -BeTrue
}
function Validate-ArrayWithoutDuplicates {
function Confirm-ArrayWithoutDuplicates {
param (
[AllowEmptyCollection()]
[Parameter(Mandatory = $true)]
@@ -19,7 +14,7 @@ function Validate-ArrayWithoutDuplicates {
}
}
function Validate-Url {
function Confirm-UrlAvailability {
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
@@ -37,7 +32,7 @@ function Validate-Url {
$result | Should -BeTrue -Because "'$Url' should be available, but it is not"
}
function Validate-IdenticalFileContent {
function Confirm-IdenticalFileContent {
param (
[Parameter(Mandatory)]
[string] $File1,
@@ -54,7 +49,7 @@ function Validate-IdenticalFileContent {
}
function ShouldReturnZeroExitCode {
Param(
Param (
[String] $ActualValue,
[switch] $Negate,
[string] $Because # This parameter is unused by we need it to match Pester asserts signature
@@ -65,8 +60,7 @@ function ShouldReturnZeroExitCode {
[bool]$succeeded = $result.ExitCode -eq 0
if ($Negate) { $succeeded = -not $succeeded }
if (-not $succeeded)
{
if (-not $succeeded) {
$commandOutputIndent = " " * 4
$commandOutput = ($result.Output | ForEach-Object { "${commandOutputIndent}${_}" }) -join "`n"
$failureMessage = "Command '${ActualValue}' has finished with exit code ${actualExitCode}`n${commandOutput}"
@@ -79,7 +73,7 @@ function ShouldReturnZeroExitCode {
}
function ShouldMatchCommandOutput {
Param(
Param (
[String] $ActualValue,
[String] $RegularExpression,
[switch] $Negate
@@ -115,7 +109,7 @@ If (Get-Command -Name Add-ShouldOperator -ErrorAction SilentlyContinue) {
}
function Invoke-PesterTests {
Param(
Param (
[Parameter(Mandatory)][string] $TestFile,
[string] $TestName
)

View File

@@ -14,7 +14,7 @@ function Get-NativeVersionFormat {
Describe "Java" {
BeforeAll {
function Validate-JavaVersion {
function Confirm-JavaVersion {
param($JavaCommand, $ExpectedVersion)
$commandResult = Get-CommandResult $JavaCommand
@@ -26,7 +26,7 @@ Describe "Java" {
}
}
$toolsetJava = Get-ToolsetValue "java"
$toolsetJava = (Get-ToolsetContent).java
$defaultVersion = $toolsetJava.$arch.default
$jdkVersions = $toolsetJava.$arch.versions
@@ -44,14 +44,14 @@ Describe "Java" {
}
It "Java <Version>" -TestCases $_ {
$envVariablePath = Get-EnvironmentVariable $EnvVariable
$envVariablePath = [System.Environment]::GetEnvironmentVariable($EnvVariable)
$javaBinPath = Join-Path $envVariablePath "/bin/java"
Validate-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version
Confirm-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version
}
if ($_.Title -eq "Default") {
It "Version is default" -TestCases $_ {
Validate-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version
Confirm-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version
}
}
}

View File

@@ -2,7 +2,7 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Describe "Clang/LLVM" {
BeforeAll {
$toolsetVersion = Get-ToolsetValue 'llvm.version'
$toolsetVersion = (Get-ToolsetContent).llvm.version
}
It "Clang/LLVM <toolsetVersion> is installed and version is correct" {

View File

@@ -9,7 +9,7 @@ Describe "Node.js" {
}
It "Node.js version should correspond to the version in the toolset" {
node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*"
node --version | Should -BeLike "v$((Get-ToolsetContent).node.default)*"
}
It "NPM is installed" {
@@ -33,7 +33,7 @@ Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) {
}
Context "nvm versions" {
[array]$nvmVersions = Get-ToolsetValue 'node.nvm_versions'
[array]$nvmVersions = (Get-ToolsetContent).node.nvm_versions
$testCases = $nvmVersions | ForEach-Object { @{NvmVersion = $_} }
It "<NvmVersion>" -TestCases $testCases {
@@ -47,7 +47,7 @@ Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) {
}
Describe "Global NPM Packages" {
$globalNpmPackages = Get-ToolsetValue "npm.global_packages"
$globalNpmPackages = (Get-ToolsetContent).npm.global_packages
$globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } }
It "<Name>" -TestCases $globalNpmPackagesWithTests {

View File

@@ -13,7 +13,7 @@ Describe "OpenSSL" {
$openSSLpath | Should -Exist
}
}
Context "OpenSSL 1.1 is default" {
It "Default OpenSSL version is 1.1" {
$commandResult = Get-CommandResult "openssl version"

View File

@@ -1,13 +1,14 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "PHP" {
Context "PHP" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "PHP Path" {
Get-WhichTool "php" | Should -Not -BeLike "/usr/bin/php*"
Get-ToolPath "php" | Should -Not -BeLike "/usr/bin/php*"
}
It "PHP version" {
$phpVersionToolset = Get-ToolsetValue 'php.version'
$phpVersionToolset = (Get-ToolsetContent).php.version
$phpInstalledVersion = php --version | Out-String | Select-String "${phpVersionToolset}"
$phpInstalledVersion | Should -BeLike "PHP ${phpVersionToolset}*"
}

View File

@@ -4,7 +4,7 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "PipxPackages" -Skip:($os.IsVentura -or $os.IsSonoma) {
$pipxToolset = Get-ToolsetValue "pipx"
$pipxToolset = (Get-ToolsetContent).pipx
$testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} }
It "<package>" -TestCases $testCases {
"$cmd" | Should -ReturnZeroExitCode

View File

@@ -9,7 +9,7 @@ Describe "Powershell" {
}
Context "Powershell Modules" {
$modules = Get-ToolsetValue powershellModules
$modules = (Get-ToolsetContent).powershellModules
$withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object {
@{moduleName = $_.name}
}
@@ -20,7 +20,7 @@ Describe "Powershell" {
@{moduleName = $moduleName; expectedVersion = $_}
}
}
It "<moduleName> is installed" -TestCases $withoutVersionsModules {
param (
[string] $moduleName
@@ -28,7 +28,7 @@ Describe "Powershell" {
Get-Module -Name $moduleName -ListAvailable | Should -BeTrue
}
if ($withVersionsModules) {
It "<moduleName> with <expectedVersion> is installed" -TestCases $withVersionsModules {
param (

View File

@@ -9,7 +9,7 @@ Describe "Python3" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
}
It "Python 3 is installed under /usr/local/bin" {
Get-WhichTool "python3" | Should -BeLike "/usr/local/bin*"
Get-ToolPath "python3" | Should -BeLike "/usr/local/bin*"
}
It "Pip 3 is available" {

View File

@@ -9,14 +9,14 @@ Describe "Ruby" -Skip:(-not $os.IsArm64) {
}
It "Ruby is installed via HomeBrew" {
Get-WhichTool "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
}
It "Ruby tools are consistent" {
$expectedPrefix = "/opt/homebrew"
Get-WhichTool "ruby" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "gem" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "bundler" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*"
}
It "Ruby gems permissions are valid" {

View File

@@ -9,14 +9,14 @@ Describe "Ruby" -Skip:($os.IsArm64) {
}
It "Ruby is installed via HomeBrew" {
Get-WhichTool "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
}
It "Ruby tools are consistent" {
$expectedPrefix = "/usr/local"
Get-WhichTool "ruby" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "gem" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "bundler" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*"
}
It "Ruby gems permissions are valid" {

View File

@@ -1,13 +1,13 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "RubyGems" {
$gemTestCases = Get-ToolsetValue -KeyPath "ruby.rubygems" | ForEach-Object {
$gemTestCases = (Get-ToolsetContent).ruby.rubygems | ForEach-Object {
@{gemName = $_}
}
if ($gemTestCases)
{
if ($gemTestCases) {
It "Gem <gemName> is installed" -TestCases $gemTestCases {
"gem list -i '^$gemName$'" | Should -MatchCommandOutput "true"
}

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Rust" {

View File

@@ -6,7 +6,7 @@ $os = Get-OSVersion
Describe "Toolcache" {
$toolcacheDirectory = Join-Path $env:HOME "hostedtoolcache"
[array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object {
[array]$packages += (Get-ToolsetContent).toolcache | ForEach-Object {
return [PSCustomObject] @{
ToolName = ($_.name).ToLower()
Arch = $arch

View File

@@ -39,83 +39,82 @@ $toolsets | ForEach-Object {
It "Version '$vsmacVersion' is available and can be downloaded" {
$vsmacUrl = Invoke-BashUtilsFunction("buildVSMacDownloadUrl", $vsmacVersion)
Validate-Url $vsmacUrl
Confirm-UrlAvailability $vsmacUrl
}
}
Context "Mono" {
$sdkVersions = $toolset.xamarin."mono-versions"
$sdkVersions = $toolset.xamarin.mono_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildMonoDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin.iOS" {
$sdkVersions = $toolset.xamarin."ios-versions"
$sdkVersions = $toolset.xamarin.ios_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamariniIOSDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin.Mac" {
$sdkVersions = $toolset.xamarin."mac-versions"
$sdkVersions = $toolset.xamarin.mac_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamarinMacDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin.Android" {
$sdkVersions = $toolset.xamarin."android-versions"
$sdkVersions = $toolset.xamarin.android_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamarinAndroidDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { $_.Replace("-", ".") } | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin bundles" {
$monoVersions = $toolset.xamarin."mono-versions" | ForEach-Object { Get-ShortVersion $_ }
$iOSVersions = $toolset.xamarin."ios-versions" | ForEach-Object { Get-ShortVersion $_ }
$macVersions = $toolset.xamarin."mac-versions" | ForEach-Object { Get-ShortVersion $_ }
$monoVersions = $toolset.xamarin.mono_versions | ForEach-Object { Get-ShortVersion $_ }
$iOSVersions = $toolset.xamarin.ios_versions | ForEach-Object { Get-ShortVersion $_ }
$macVersions = $toolset.xamarin.mac_versions | ForEach-Object { Get-ShortVersion $_ }
# Old Xamarin.Android version looks like "9.0.0-18" that doesn't support by System.Version
$androidVersions = $toolset.xamarin."android-versions" | ForEach-Object { Get-ShortVersion $_.Replace("-", ".") }
$androidVersions = $toolset.xamarin.android_versions | ForEach-Object { Get-ShortVersion $_.Replace("-", ".") }
$bundles = $toolset.xamarin.bundles
$bundles | ForEach-Object {
It "'$($_.symlink)' is valid" {
$monoVersions | Should -Contain $_.mono
@@ -127,18 +126,16 @@ $toolsets | ForEach-Object {
It "Each bundle has unique symlink" {
$symlinks = $bundles | ForEach-Object { $_.symlink }
Validate-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique"
Confirm-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique"
}
It "Current bundle is valid" {
$currentBundleSymlink = $toolset.xamarin."bundle-default"
$currentBundleSymlink = $toolset.xamarin.bundle_default
if ($currentBundleSymlink -ne "latest") {
$bundleSymlinks = $bundles | ForEach-Object { $_.symlink }
$bundleSymlinks | Should -Contain $currentBundleSymlink -Because "Current bundle should be installed"
}
}
}
}
}

View File

@@ -2,16 +2,17 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
if ($os.IsVentura -or $os.IsSonoma) {
$MONO_VERSIONS = @(Get-ToolsetValue "mono.framework.version")
$MONO_VERSIONS = @((Get-ToolsetContent).mono.framework.version)
$XAMARIN_IOS_VERSIONS = @()
$XAMARIN_MAC_VERSIONS = @()
$XAMARIN_ANDROID_VERSIONS = @()
} elseif ($os.IsBigSur -or $os.IsMonterey) {
$MONO_VERSIONS = Get-ToolsetValue "xamarin.mono-versions"
$XAMARIN_IOS_VERSIONS = Get-ToolsetValue "xamarin.ios-versions"
$XAMARIN_MAC_VERSIONS = Get-ToolsetValue "xamarin.mac-versions"
$XAMARIN_ANDROID_VERSIONS = Get-ToolsetValue "xamarin.android-versions"
$MONO_VERSIONS = (Get-ToolsetContent).xamarin.mono_versions
$XAMARIN_IOS_VERSIONS = (Get-ToolsetContent).xamarin.ios_versions
$XAMARIN_MAC_VERSIONS = (Get-ToolsetContent).xamarin.mac_versions
$XAMARIN_ANDROID_VERSIONS = (Get-ToolsetContent).xamarin.android_versions
}
BeforeAll {
@@ -53,7 +54,7 @@ Describe "Mono" {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
It "NUnit console is installed" -TestCases $testCase {
@@ -116,7 +117,7 @@ Describe "Xamarin.iOS" -Skip:($os.IsVentura -or $os.IsSonoma) {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
}
}
@@ -149,7 +150,7 @@ Describe "Xamarin.Mac" -Skip:($os.IsVentura -or $os.IsSonoma) {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
}
}
@@ -181,7 +182,7 @@ Describe "Xamarin.Android" -Skip:($os.IsVentura -or $os.IsSonoma) {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
It "has correct symlinks" -TestCases $testCase {
@@ -205,8 +206,8 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
If ($XAMARIN_BUNDLES.Count -eq 0) { return } # Skip this test if there are no bundles
[array]$XAMARIN_BUNDLES = Get-ToolsetValue "xamarin.bundles"
$XAMARIN_DEFAULT_BUNDLE = Get-ToolsetValue "xamarin.bundle-default"
[array]$XAMARIN_BUNDLES = (Get-ToolsetContent).xamarin.bundles
$XAMARIN_DEFAULT_BUNDLE = (Get-ToolsetContent).xamarin.bundle_default
If ($XAMARIN_DEFAULT_BUNDLE -eq "latest") { $XAMARIN_DEFAULT_BUNDLE = $XAMARIN_BUNDLES[0].symlink }
$currentBundle = [PSCustomObject] @{
@@ -244,7 +245,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleMono "VERSION"
$targetVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "iOS symlink <BundleSymlink> exists" -TestCases $allBundles {
@@ -262,7 +263,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleIos "VERSION"
$targetVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "Mac symlink <BundleSymlink> exists" -TestCases $allBundles {
@@ -280,7 +281,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleMac "VERSION"
$targetVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "Xamarin.Android symlink <BundleSymlink> exists" -TestCases $allBundles {
@@ -298,7 +299,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleAndroid "VERSION"
$targetVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
}

View File

@@ -2,14 +2,20 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
$ARCH = Get-Architecture
$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions"
$defaultXcode = Get-ToolsetValue "xcode.default"
$arch = Get-Architecture
$xcodeVersions = (Get-ToolsetContent).xcode.${arch}.versions
$defaultXcode = (Get-ToolsetContent).xcode.default
$latestXcodeVersion = $xcodeVersions | Select-Object -First 1
$os = Get-OSVersion
Describe "Xcode" {
$testCases = $xcodeVersions | ForEach-Object { @{ XcodeVersion = $_.link; LatestXcodeVersion = $xcodeVersions[0].link; Symlinks = $_.symlinks } }
$testCases = $xcodeVersions | ForEach-Object {
@{
XcodeVersion = $_.link;
LatestXcodeVersion = $xcodeVersions[0].link;
Symlinks = $_.symlinks
}
}
Context "Versions" {
It "<XcodeVersion>" -TestCases $testCases {
@@ -82,7 +88,7 @@ Describe "XCODE_DEVELOPER_DIR variables" {
It "XCODE_<MajorVersion>_DEVELOPER_DIR" -TestCases $testCases {
$variableName = "XCODE_${MajorVersion}_DEVELOPER_DIR"
$actualPath = Get-EnvironmentVariable $variableName
$actualPath = [System.Environment]::GetEnvironmentVariable($variableName)
$expectedVersion = $VersionsList | Where-Object { $_.Version.Major -eq $MajorVersion } | Select-Object -First 1
$expectedPath = "$($expectedVersion.RootPath)/Contents/Developer"
$actualPath | Should -Exist
@@ -99,21 +105,13 @@ Describe "Xcode simulators" {
[array]$devicesList = @(Get-XcodeDevicesList | Where-Object { $_ })
Write-Host "Devices for $XcodeVersion"
Write-Host ($devicesList -join "`n")
Validate-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators"
Confirm-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators"
}
# It "No duplicates in pairs" -TestCases $testCase {
# Switch-Xcode -Version $XcodeVersion
# [array]$pairsList = @(Get-XcodePairsList | Where-Object { $_ })
# Write-Host "Pairs for $XcodeVersion"
# Write-Host ($pairsList -join "`n")
# Validate-ArrayWithoutDuplicates $pairsList -Because "Found duplicate pairs simulators"
# }
}
}
AfterEach {
$defaultXcode = Get-ToolsetValue "xcode.default"
$defaultXcode = (Get-ToolsetContent).xcode.default
Switch-Xcode -Version $defaultXcode
}
}