[macOS] Implement new directories hierarchy (#8741)

This commit is contained in:
Shamil Mubarakshin
2023-11-15 12:12:28 +01:00
committed by GitHub
parent 5d40b1e213
commit 8d6a01b370
133 changed files with 1713 additions and 1677 deletions

View File

@@ -0,0 +1,15 @@
Describe "ActionArchiveCache" {
Context "Action archive cache directory not empty" {
It "$HOME/actionarchivecache not empty" {
(Get-ChildItem -Path "$env:HOME/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
}
}
Context "Action tarball not empty" {
$testCases = Get-ChildItem -Path "$env:HOME/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } }
It "<ActionTarball>" -TestCases $testCases {
param ([string] $ActionTarball)
(Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0
}
}
}

View File

@@ -0,0 +1,82 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/../software-report/SoftwareReport.Android.psm1" -DisableNameChecking
$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"
$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
$platformsInstalled = $platformVersionsList | Where-Object { [int]($_.Split("-")[0]) -ge $platformMinVersion } | ForEach-Object { "platforms/android-${_}" }
$buildToolsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("build-tools;") }) -replace 'build-tools;', ''
$buildTools = $buildToolsList | Where-Object { $_ -match "\d+(\.\d+){2,}$" } | Where-Object { [version]$_ -ge $buildToolsMinVersion } | Sort-Object -Unique |
ForEach-Object { "build-tools/${_}" }
$androidPackages = @(
"tools",
"platform-tools",
"cmake",
$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")
) | ForEach-Object { $_ }
# Remove empty strings from array to avoid possible issues
$androidPackages = $androidPackages | Where-Object { $_ }
BeforeAll {
$ANDROID_SDK_DIR = Join-Path $env:HOME "Library" "Android" "sdk"
function Validate-AndroidPackage {
param (
[Parameter(Mandatory = $true)]
[string]$PackageName
)
# Convert 'm2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1' ->
# 'm2repository/com/android/support/constraint/constraint-layout-solver/1.0.0-beta1'
$PackageName = $PackageName.Replace(";", "/")
$targetPath = Join-Path $ANDROID_SDK_DIR $PackageName
$targetPath | Should -Exist
}
}
Context "SDKManagers" {
$testCases = @(
@{
PackageName = "Command-line tools"
Sdkmanager = "$env:ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
}
)
if ($os.IsBigSur -or $os.IsMonterey) {
$testCases += @(
@{
PackageName = "SDK tools"
Sdkmanager = "$env:ANDROID_HOME/tools/bin/sdkmanager"
}
)
}
It "Sdkmanager from <PackageName> is available" -TestCases $testCases {
"$Sdkmanager --version" | Should -ReturnZeroExitCode
}
}
Context "Packages" {
$testCases = $androidPackages | ForEach-Object { @{ PackageName = $_ } }
It "<PackageName>" -TestCases $testCases {
param ([string] $PackageName)
Validate-AndroidPackage $PackageName
}
}
}

View File

@@ -0,0 +1,197 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Azure CLI" {
It "Azure CLI" {
"az -v" | Should -ReturnZeroExitCode
}
}
Describe "Azure DevOps CLI" {
It "az devops" {
"az devops -h" | Should -ReturnZeroExitCode
}
}
Describe "Carthage" {
It "Carthage" {
"carthage version" | Should -ReturnZeroExitCode
}
}
Describe "cmake" {
It "cmake" {
"cmake --version" | Should -ReturnZeroExitCode
}
}
Describe "Subversion" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Subversion" {
"svn --version" | Should -ReturnZeroExitCode
}
}
Describe "SwiftFormat" {
It "SwiftFormat" {
"swiftformat --version" | Should -ReturnZeroExitCode
}
}
Describe "GnuPG" {
It "GnuPG" {
"gpg --version" | Should -ReturnZeroExitCode
}
}
Describe "zstd" {
It "zstd" {
"zstd --version" | Should -ReturnZeroExitCode
}
}
Describe "Packer" {
It "Packer" {
"packer --version" | Should -ReturnZeroExitCode
}
}
Describe "Perl" {
It "Perl" {
"perl -e 'print substr($^V,1)'" | Should -ReturnZeroExitCode
}
}
Describe "Helm" -Skip:($os.IsMonterey -or $os.IsVentura -or $os.IsSonoma) {
It "Helm" {
"helm version --short" | Should -ReturnZeroExitCode
}
}
Describe "Tcl/Tk" {
It "libtcl" {
"file /usr/local/lib/libtcl8.6.dylib" | Should -ReturnZeroExitCode
"file /usr/local/lib/libtk8.6.dylib" | Should -ReturnZeroExitCode
}
}
Describe "bazelisk" {
It "bazelisk" {
"bazelisk version" | Should -ReturnZeroExitCode
}
}
Describe "Github CLI" {
It "GitHub CLI" {
"gh --version" | Should -ReturnZeroExitCode
}
}
Describe "7-Zip" {
It "7-Zip" {
"7z i" | Should -ReturnZeroExitCode
}
}
Describe "Apache Ant" {
It "Apache Ant" {
"ant -version" | Should -ReturnZeroExitCode
}
}
Describe "Aria2" {
It "Aria2" {
"aria2c --version" | Should -ReturnZeroExitCode
}
}
Describe "GNU Tar" {
It "GNU Tar" {
"gtar --version" | Should -ReturnZeroExitCode
}
}
Describe "bazel" {
It "bazel" {
"bazel --version" | Should -ReturnZeroExitCode
}
}
Describe "Aliyun CLI" -Skip:($os.IsMonterey -or $os.IsVentura -or $os.IsSonoma) {
It "Aliyun CLI" {
"aliyun --version" | Should -ReturnZeroExitCode
}
}
Describe "Julia" {
It "Julia" {
"julia --version" | Should -ReturnZeroExitCode
}
}
Describe "jq" {
It "jq" {
"jq --version" | Should -ReturnZeroExitCode
}
}
Describe "curl" {
It "curl" {
"curl --version" | Should -ReturnZeroExitCode
}
}
Describe "wget" {
It "wget" {
"wget --version" | Should -ReturnZeroExitCode
}
}
Describe "vagrant" -Skip:($os.IsBigSur -or $os.IsVentura -or $os.IsSonoma) {
It "vagrant" {
"vagrant --version" | Should -ReturnZeroExitCode
}
}
Describe "virtualbox" -Skip:($os.IsBigSur -or $os.IsVentura -or $os.IsSonoma) {
It "virtualbox" {
"vboxmanage -v" | Should -ReturnZeroExitCode
}
}
Describe "R" {
It "R" {
"R --version" | Should -ReturnZeroExitCode
}
}
Describe "Homebrew" {
It "Homebrew" {
"brew --version" | Should -ReturnZeroExitCode
}
}
Describe "Kotlin" {
$kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlinc-jvm", "kotlin-dce-js")
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
"$toolName -version" | Should -ReturnZeroExitCode
}
}
Describe "sbt" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "sbt" {
"sbt -version" | Should -ReturnZeroExitCode
}
}
Describe "yq" {
It "yq" {
"yq --version" | Should -ReturnZeroExitCode
}
}
Describe "imagemagick" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "imagemagick" {
"magick -version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,75 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Chrome" {
BeforeAll {
$chromeLocation = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
$chromeForTestingLocation = "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
}
It "Chrome" {
$chromeLocation | Should -Exist
"'$chromeLocation' --version" | Should -ReturnZeroExitCode
}
It "Chrome for Testing" {
$chromeForTestingLocation | Should -Exist
"'$chromeForTestingLocation' --version" | Should -ReturnZeroExitCode
}
It "Chrome Driver" {
"chromedriver --version" | Should -ReturnZeroExitCode
}
It "Chrome for Testing and Chrome Driver major versions are the same" {
$chromeMajor = (& $chromeForTestingLocation --version).Trim("Google Chrome for Testing ").Split(".")[0]
$chromeDriverMajor = (chromedriver --version).Trim("ChromeDriver ").Split(".")[0]
$chromeMajor | Should -BeExactly $chromeDriverMajor
}
}
Describe "Selenium server" {
It "Selenium server" {
$os = Get-OSVersion
if ($os.IsArm64) {
$cellarPath = "/opt/homebrew/Cellar"
} else {
$cellarPath = "/usr/local/Cellar"
}
(Get-ChildItem -Path "$cellarPath/selenium-server*/*").Name | Should -BeLike "4.*"
}
}
Describe "Edge" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "Microsoft Edge" {
$edgeLocation = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
$edgeLocation | Should -Exist
"'$edgeLocation' --version" | Should -ReturnZeroExitCode
}
It "Microsoft Edge Driver" {
"msedgedriver --version" | Should -ReturnZeroExitCode
}
}
Describe "Firefox" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "Firefox" {
$firefoxLocation = "/Applications/Firefox.app/Contents/MacOS/firefox"
$firefoxLocation | Should -Exist
"'$firefoxLocation' --version" | Should -ReturnZeroExitCode
}
It "Geckodriver" {
"geckodriver --version" | Should -ReturnZeroExitCode
}
}
Describe "Safari" {
It "'Allow Remote Automation' option is activated" {
$plistPath = "$env:HOME/Library/WebDriver/com.apple.Safari.plist"
$command = "/usr/libexec/PlistBuddy -c 'print AllowRemoteAutomation' $plistPath"
$plistPath | Should -Exist
$commandResult = Get-CommandResult $command
$commandResult.ExitCode | Should -Be 0
$commandResult.Output | Should -Be "true"
}
}

View File

@@ -0,0 +1,148 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
Describe ".NET" {
It ".NET" {
"dotnet --version" | Should -ReturnZeroExitCode
}
}
Describe "GCC" {
$testCases = Get-ToolsetValue -KeyPath gcc.versions | ForEach-Object { @{Version = $_ } }
It "GCC <Version>" -TestCases $testCases {
param (
[string] $Version
)
"gcc-$Version --version" | Should -ReturnZeroExitCode
}
It "Gfortran <Version>" -TestCases $testCases {
param (
[string] $Version
)
"gfortran-$Version --version" | Should -ReturnZeroExitCode
}
It "Gfortran is not found in the default path" {
"$(which gfortran)" | Should -BeNullOrEmpty
}
}
Describe "vcpkg" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "vcpkg" {
"vcpkg version" | Should -ReturnZeroExitCode
}
}
Describe "AWS" {
It "AWS CLI" {
"aws --version" | Should -ReturnZeroExitCode
}
It "AWS SAM CLI" {
"sam --version" | Should -ReturnZeroExitCode
}
It "AWS Session Manager CLI" {
"session-manager-plugin --version" | Should -ReturnZeroExitCode
}
}
Describe "AzCopy" {
It "AzCopy" {
"azcopy --version" | Should -ReturnZeroExitCode
}
}
Describe "Miniconda" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Conda" {
Get-EnvironmentVariable "CONDA" | Should -Not -BeNullOrEmpty
$condaBinPath = Join-Path $env:CONDA "bin" "conda"
"$condaBinPath --version" | Should -ReturnZeroExitCode
}
}
Describe "Stack" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Stack" {
"stack --version" | Should -ReturnZeroExitCode
}
}
Describe "CocoaPods" {
It "CocoaPods" {
"pod --version" | Should -ReturnZeroExitCode
}
}
Describe "VSMac" -Skip:($os.IsVentura -or $os.IsSonoma) {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
$testCases = $vsMacVersions | ForEach-Object {
$vsPath = "/Applications/Visual Studio $_.app"
if ($_ -eq $defaultVSMacVersion) {
$vsPath = "/Applications/Visual Studio.app"
}
@{ vsversion = $_ ; vspath = $vsPath }
}
It "Visual Studio <vsversion> for Mac is installed" -TestCases $testCases {
$vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool"
$vsPath | Should -Exist
$vstoolPath | Should -Exist
}
It "Visual Studio $defaultVSMacVersion for Mac is default" {
$vsPath = "/Applications/Visual Studio.app"
$vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool"
$vsPath | Should -Exist
$vstoolPath | Should -Exist
}
}
Describe "Swig" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Swig" {
"swig -version" | Should -ReturnZeroExitCode
}
}
Describe "Bicep" {
It "Bicep" {
"bicep --version" | Should -ReturnZeroExitCode
}
}
Describe "Go" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Go" {
"go version" | Should -ReturnZeroExitCode
}
}
Describe "VirtualBox" -Skip:($os.IsBigSur -or $os.IsVentura -or $os.IsSonoma) {
It "Check kext kernel modules" {
kextstat | Out-String | Should -Match "org.virtualbox.kext"
}
}
Describe "CodeQL Bundle" {
It "Is installed" {
$CodeQLVersionWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionWildcard | Select-Object -First 1 -Expand FullName
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql"
"$CodeQLPath version --quiet" | Should -ReturnZeroExitCode
$CodeQLPacksPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "qlpacks"
$CodeQLPacksPath | Should -Exist
}
}
Describe "Colima" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Colima" {
"colima version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,23 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "MongoDB" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "<ToolName>" -TestCases @(
@{ ToolName = "mongo" }
@{ ToolName = "mongod" }
) {
$toolsetVersion = Get-ToolsetValue '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'
# Client version
(psql --version).split()[-2] | Should -BeLike "$toolsetVersion*"
# Server version
(pg_config --version).split()[-2] | Should -BeLike "$toolsetVersion*"
}
}

View File

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

View File

@@ -0,0 +1,29 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Haskell" -Skip:($os.IsVentura -or $os.IsSonoma) {
Context "GHCup" {
It "GHCup" {
"ghcup --version" | Should -ReturnZeroExitCode
}
}
Context "GHC" {
It "GHC" {
"ghc --version" | Should -ReturnZeroExitCode
}
}
Context "Cabal" {
It "Cabal" {
"cabal --version" | Should -ReturnZeroExitCode
}
}
Context "Stack" {
It "Stack" {
"stack --version" | Should -ReturnZeroExitCode
}
It "Stack hook is not installed" {
"$HOME/.stack/hooks/ghc-install.sh" | Should -Not -Exist
}
}
}

View File

@@ -0,0 +1,83 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
$arch = Get-Architecture
function Get-NativeVersionFormat {
param($Version)
if ($Version -in "8") {
return "1.${Version}"
}
return $Version
}
Describe "Java" {
BeforeAll {
function Validate-JavaVersion {
param($JavaCommand, $ExpectedVersion)
$commandResult = Get-CommandResult $JavaCommand
$commandResult.ExitCode | Should -Be 0
$matchResult = $commandResult.Output | Select-String '^openjdk version \"([\d\._]+)\"'
$matchResult.Matches.Success | Should -BeTrue
$version = $matchResult.Matches.Groups[1].Value
$version | Should -BeLike "${ExpectedVersion}*"
}
}
$toolsetJava = Get-ToolsetValue "java"
$defaultVersion = $toolsetJava.$arch.default
$jdkVersions = $toolsetJava.$arch.versions
if ($os.IsArm64) {
$testCases = $jdkVersions | ForEach-Object { @{ Title = $_; Version = (Get-NativeVersionFormat $_); EnvVariable = "JAVA_HOME_${_}_arm64" } }
} else {
$testCases = $jdkVersions | ForEach-Object { @{ Title = $_; Version = (Get-NativeVersionFormat $_); EnvVariable = "JAVA_HOME_${_}_X64" } }
}
$testCases += @{ Title = "Default"; Version = (Get-NativeVersionFormat $defaultVersion); EnvVariable = "JAVA_HOME" }
$testCases | ForEach-Object {
Context $_.Title {
It "Version is found by 'java_home'" -TestCases $_ {
"/usr/libexec/java_home -v${Version}" | Should -ReturnZeroExitCode
}
It "Java <Version>" -TestCases $_ {
$envVariablePath = Get-EnvironmentVariable $EnvVariable
$javaBinPath = Join-Path $envVariablePath "/bin/java"
Validate-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version
}
if ($_.Title -eq "Default") {
It "Version is default" -TestCases $_ {
Validate-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version
}
}
}
}
Context "Maven" {
Describe "Maven" {
It "Maven" {
"mvn --version" | Should -ReturnZeroExitCode
}
}
}
Context "Gradle" {
Describe "Gradle" {
It "Gradle is installed" {
"gradle --version" | Should -ReturnZeroExitCode
}
It "Gradle is installed to /usr/local/bin" -Skip:($os.IsArm64) {
(Get-Command "gradle").Path | Should -BeExactly "/usr/local/bin/gradle"
}
It "Gradle is installed to /opt/homebrew/bin/gradle" -Skip:(-not $os.IsArm64) {
(Get-Command "gradle").Path | Should -BeExactly "/opt/homebrew/bin/gradle"
}
}
}
}

View File

@@ -0,0 +1,10 @@
Describe "Clang/LLVM" {
BeforeAll {
$toolsetVersion = Get-ToolsetValue 'llvm.version'
}
It "Clang/LLVM <toolsetVersion> is installed and version is correct" {
$clangVersion = & "$(brew --prefix llvm@$toolsetVersion)/bin/clang" --version
$clangVersion[0] | Should -BeLike "*${toolsetVersion}*"
}
}

View File

@@ -0,0 +1,9 @@
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
Describe "SwiftLint" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "SwiftLint" {
"swiftlint version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,56 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
Describe "Node.js" {
It "Node.js is installed" {
"node --version" | Should -ReturnZeroExitCode
}
It "Node.js version should correspond to the version in the toolset" {
node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*"
}
It "NPM is installed" {
"npm --version" | Should -ReturnZeroExitCode
}
It "Yarn is installed" {
"yarn --version" | Should -ReturnZeroExitCode
}
}
Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) {
BeforeAll {
$nvmPath = Join-Path $env:HOME ".nvm" "nvm.sh"
$nvmInitCommand = ". $nvmPath > /dev/null 2>&1 || true"
}
It "nvm is installed" {
$nvmPath | Should -Exist
"$nvmInitCommand && nvm --version" | Should -ReturnZeroExitCode
}
Context "nvm versions" {
[array]$nvmVersions = Get-ToolsetValue 'node.nvm_versions'
$testCases = $nvmVersions | ForEach-Object { @{NvmVersion = $_} }
It "<NvmVersion>" -TestCases $testCases {
param (
[string] $NvmVersion
)
"$nvmInitCommand && nvm ls $($NvmVersion)" | Should -ReturnZeroExitCode
}
}
}
Describe "Global NPM Packages" {
$globalNpmPackages = Get-ToolsetValue "npm.global_packages"
$globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } }
It "<Name>" -TestCases $globalNpmPackagesWithTests {
$Test | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,23 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Describe "OpenSSL" {
Context "OpenSSL Version" {
It "OpenSSL is available" {
"openssl version" | Should -ReturnZeroExitCode
}
}
Context "OpenSSL 1.1 Path Check" {
It "OpenSSL 1.1 path exists" {
$openSSLpath = brew --prefix openssl@1.1
$openSSLpath | Should -Exist
}
}
Context "OpenSSL 1.1 is default" {
It "Default OpenSSL version is 1.1" {
$commandResult = Get-CommandResult "openssl version"
$commandResult.Output | Should -Match "OpenSSL 1.1"
}
}
}

View File

@@ -0,0 +1,21 @@
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*"
}
It "PHP version" {
$phpVersionToolset = Get-ToolsetValue 'php.version'
$phpInstalledVersion = php --version | Out-String | Select-String "${phpVersionToolset}"
$phpInstalledVersion | Should -BeLike "PHP ${phpVersionToolset}*"
}
}
Context "Composer" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "Composer" {
"composer --version" | Should -ReturnZeroExitCode
}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
Describe "Powershell" {
Context "Powershell is installed" {
It "Powershell is installed" {
"pwsh -v" | Should -ReturnZeroExitCode
}
}
Context "Powershell Modules" {
$modules = Get-ToolsetValue powershellModules
$withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object {
@{moduleName = $_.name}
}
$withVersionsModules = $modules | Where-Object {$_.versions} | ForEach-Object {
$moduleName = $_.name
$_.versions | ForEach-Object {
@{moduleName = $moduleName; expectedVersion = $_}
}
}
It "<moduleName> is installed" -TestCases $withoutVersionsModules {
param (
[string] $moduleName
)
Get-Module -Name $moduleName -ListAvailable | Should -BeTrue
}
if ($withVersionsModules) {
It "<moduleName> with <expectedVersion> is installed" -TestCases $withVersionsModules {
param (
[string] $moduleName,
[string] $expectedVersion
)
(Get-Module -Name $moduleName -ListAvailable).Version -contains $expectedVersion | Should -BeTrue
}
}
}
}

View File

@@ -0,0 +1,44 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
Describe "Python3" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "Python 3 is available" {
"python3 --version" | Should -ReturnZeroExitCode
}
It "Python 3 is installed under /usr/local/bin" {
Get-WhichTool "python3" | Should -BeLike "/usr/local/bin*"
}
It "Pip 3 is available" {
"pip3 --version" | Should -ReturnZeroExitCode
}
It "Pipx is available" {
"pipx --version" | Should -ReturnZeroExitCode
}
It "Pip 3 and Python 3 came from the same brew formula" {
$pip3Path = Split-Path (readlink (which pip3))
$python3Path = Split-Path (readlink (which python3))
$pip3Path | Should -BeExactly $python3Path
}
}
Describe "Python2" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Python 2 is available" {
"/Library/Frameworks/Python.framework/Versions/2.7/bin/python --version" | Should -ReturnZeroExitCode
}
It "Pip 2 is available" {
"/Library/Frameworks/Python.framework/Versions/2.7/bin/pip --version" | Should -ReturnZeroExitCode
}
It "2to3 symlink does not point to Python 2" {
$2to3path = (Get-ChildItem (Get-Command 2to3).Path).Target
$2to3path | Should -Not -BeLike '/Frameworks/Python.framework/Versions/2.*'
}
}

View File

@@ -0,0 +1,26 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
Describe "Ruby" -Skip:(-not $os.IsArm64) {
It "Ruby is available" {
"ruby --version" | Should -ReturnZeroExitCode
}
It "Ruby is installed via HomeBrew" {
Get-WhichTool "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)*"
}
It "Ruby gems permissions are valid" {
"gem install bundle" | Should -ReturnZeroExitCode
"gem uninstall bundle" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,26 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
Describe "Ruby" -Skip:($os.IsArm64) {
It "Ruby is available" {
"ruby --version" | Should -ReturnZeroExitCode
}
It "Ruby is installed via HomeBrew" {
Get-WhichTool "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)*"
}
It "Ruby gems permissions are valid" {
"gem install bundle" | Should -ReturnZeroExitCode
"gem uninstall bundle" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,45 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "RubyGems" {
$gemTestCases = Get-ToolsetValue -KeyPath "ruby.rubygems" | ForEach-Object {
@{gemName = $_}
}
if ($gemTestCases)
{
It "Gem <gemName> is installed" -TestCases $gemTestCases {
"gem list -i '^$gemName$'" | Should -MatchCommandOutput "true"
}
}
}
Describe "Bundler" {
It "Bundler" {
"bundler --version" | Should -ReturnZeroExitCode
}
}
Describe "Nomad shenzhen CLI" -Skip:($os.IsMonterey -or $os.IsVentura -or $os.IsSonoma) {
It "Nomad shenzhen CLI" {
"ipa --version" | Should -ReturnZeroExitCode
}
}
Describe "Fastlane" {
It "Fastlane" {
"fastlane --version" | Should -ReturnZeroExitCode
}
}
Describe "xcpretty" {
It "xcpretty" {
"xcpretty --version" | Should -ReturnZeroExitCode
}
}
Describe "jazzy" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "jazzy" {
"jazzy --version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,3 @@
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
Invoke-PesterTests "*"

View File

@@ -0,0 +1,37 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Rust" {
Context "Rust" {
It "Rustup is installed" {
"rustup --version" | Should -ReturnZeroExitCode
}
It "Rustc is installed" {
"rustc --version" | Should -ReturnZeroExitCode
}
}
Context "Cargo" {
It "Cargo is installed" {
"cargo --version" | Should -ReturnZeroExitCode
}
}
Context "Cargo dependencies" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "bindgen" {
"bindgen --version" | Should -ReturnZeroExitCode
}
It "cbindgen" {
"cbindgen --version" | Should -ReturnZeroExitCode
}
It "Cargo audit" {
"cargo audit --version" | Should -ReturnZeroExitCode
}
It "Cargo outdated" {
"cargo outdated --version" | Should -ReturnZeroExitCode
}
}
}

View File

@@ -0,0 +1,61 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Disk free space" {
It "Image has more than 10GB free space" {
# we should have at least 10 GB of free space on macOS images
# https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops#capabilities-and-limitations
$freeSpace = (Get-PSDrive "/").Free
$freeSpace | Should -BeGreaterOrEqual 10GB
}
}
Describe "Certificate" {
It "Apple Worldwide Developer Relations Certification Authority[expired: 2030-02] is installed" {
$sha1Hash = "06EC06599F4ED0027CC58956B4D3AC1255114F35"
$certs = security find-certificate -a -c Worldwide -p -Z | Out-String
$certs | Should -Match $sha1Hash
}
It "Developer ID Certification Authority[expired: 2031-09] is installed" {
$sha1Hash = "5B45F61068B29FCC8FFFF1A7E99B78DA9E9C4635"
$certs = security find-certificate -a -c "Developer ID" -p -Z | Out-String
$certs | Should -Match $sha1Hash
}
}
Describe "Audio device" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Sox is installed" {
"sox --version" | Should -ReturnZeroExitCode
}
It "SwitchAudioSource is installed" {
"SwitchAudioSource -c" | Should -ReturnZeroExitCode
}
It "Audio channel BlackHole 2ch" {
SwitchAudioSource -c | Should -BeLikeExactly "BlackHole 2ch"
}
}
Describe "Screen Resolution" -Skip:(isVeertu) {
It "Screen Resolution" {
system_profiler SPDisplaysDataType | Select-String "Resolution" | Should -Match "1176 x 885|1920 x 1080"
}
}
Describe "Open windows" -Skip:(isVeertu) {
It "Opened windows not found" {
'tell application id "com.apple.systemevents" to get every window of (every process whose class of windows contains window)' | Tee-Object /tmp/windows.osascript
$cmd = "osascript /tmp/windows.osascript"
$openWindows = bash -c $cmd
$openWindows.Split(",").Trim() | Where-Object { $_ -notmatch "NotificationCenter" } | Should -BeNullOrEmpty
}
}
Describe "AutomationModeTool" {
It "Does not require user authentication" -Skip:($os.IsBigSur) {
automationmodetool | Out-String | Should -Match "DOES NOT REQUIRE"
}
}

View File

@@ -0,0 +1,232 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$arch = Get-Architecture
$os = Get-OSVersion
Describe "Toolcache" {
$toolcacheDirectory = Join-Path $env:HOME "hostedtoolcache"
[array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object {
return [PSCustomObject] @{
ToolName = ($_.name).ToLower()
Arch = $arch
Versions = $_.arch.$arch | Where-Object{ $_ } | ForEach-Object { $_.versions.Replace(".*", "") }
}
}
Context "Python" {
$pythonDirectory = Join-Path $toolcacheDirectory "Python"
$pythonPackage = $packages | Where-Object { $_.ToolName -eq "python" } | Select-Object -First 1
$testCase = @{ PythonDirectory = $pythonDirectory }
It "Toolcache directory exists" -TestCases $testCase {
param ( [string] $PythonDirectory )
$PythonDirectory | Should -Exist
}
It "Toolcache directory contains at least one version of Python" -TestCases $testCase {
param ( [string] $PythonDirectory )
(Get-ChildItem -Path $PythonDirectory -Directory).Count | Should -BeGreaterThan 0
}
$pythonPackage.Versions | Where-Object { $_ } | ForEach-Object {
Context "$_" {
$versionDirectory = Get-ChildItem -Path $pythonDirectory -Directory -Filter "$_*" | Select-Object -First 1
$pythonBinPath = Join-Path $versionDirectory.FullName $pythonPackage.Arch "python"
$testCase = @{ PythonVersion = $_; PythonBinPath = $pythonBinPath }
It "Version" -TestCases $testCase {
param (
[string] $PythonVersion,
[string] $PythonBinPath
)
$result = Get-CommandResult "$PythonBinPath --version"
$result.Output | Should -BeLike "*$PythonVersion*"
$result.ExitCode | Should -Be 0
}
It "Run test script" -TestCases $testCase {
param ( [string] $PythonBinPath )
"$PythonBinPath -c 'import sys;print(sys.version)'" | Should -ReturnZeroExitCode
}
}
}
}
Context "Ruby" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
$rubyDirectory = Join-Path $toolcacheDirectory "Ruby"
$rubyPackage = $packages | Where-Object { $_.ToolName -eq "Ruby" } | Select-Object -First 1
$testCase = @{ RubyDirectory = $rubyDirectory }
It "Toolcache directory exists" -TestCases $testCase {
param ( [string] $RubyDirectory )
$RubyDirectory | Should -Exist
}
It "Toolcache directory contains at least one version of Ruby" -TestCases $testCase {
param ( [string] $RubyDirectory )
(Get-ChildItem -Path $RubyDirectory -Directory).Count | Should -BeGreaterThan 0
}
$rubyPackage.Versions | Where-Object { $_ } | ForEach-Object {
Context "$_" {
$versionDirectory = Get-ChildItem -Path $rubyDirectory -Directory -Filter "$_*" | Select-Object -First 1
$rubyBinPath = Join-Path $versionDirectory.FullName $rubyPackage.Arch "bin" "ruby"
$testCase = @{ RubyVersion = $_; RubyBinPath = $rubyBinPath }
It "Version" -TestCases $testCase {
param (
[string] $RubyVersion,
[string] $RubyBinPath
)
$result = Get-CommandResult "$RubyBinPath --version"
$result.Output | Should -BeLike "*$RubyVersion*"
$result.ExitCode | Should -Be 0
}
It "Run test script" -TestCases $testCase {
param ( [string] $RubyBinPath )
"$RubyBinPath -e 'puts RUBY_VERSION'" | Should -ReturnZeroExitCode
}
}
}
}
Context "PyPy" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
$pypyDirectory = Join-Path $toolcacheDirectory "PyPy"
$pypyPackage = $packages | Where-Object { $_.ToolName -eq "pypy" } | Select-Object -First 1
$testCase = @{ PypyDirectory = $pypyDirectory }
It "Toolcache directory exists" -TestCases $testCase {
param ( [string] $PypyDirectory )
$PypyDirectory | Should -Exist
}
It "Toolcache directory contains at least one version of PyPy" -TestCases $testCase {
param ( [string] $PypyDirectory )
(Get-ChildItem -Path $PypyDirectory -Directory).Count | Should -BeGreaterThan 0
}
$pypyPackage.Versions | Where-Object { $_ } | ForEach-Object {
Context "$_" {
$versionDirectory = Get-ChildItem -Path $pypyDirectory -Directory -Filter "$_*" | Select-Object -First 1
$binFilename = If ($_.StartsWith("3")) { "pypy3" } else { "pypy" }
$pypyBinPath = Join-Path $versionDirectory.FullName $pypyPackage.Arch "bin" $binFilename
$testCase = @{ PypyVersion = $_; PypyBinPath = $pypyBinPath }
It "Version" -TestCases $testCase {
param (
[string] $PypyVersion,
[string] $PypyBinPath
)
$result = Get-CommandResult "$PypyBinPath --version"
$result.Output | Should -BeLike "*$PypyVersion*"
$result.ExitCode | Should -Be 0
}
It "Run test script" -TestCases $testCase {
param ( [string] $PypyBinPath )
"$PypyBinPath -c 'import sys;print(sys.version)'" | Should -ReturnZeroExitCode
}
}
}
}
Context "Node" {
$nodeDirectory = Join-Path $toolcacheDirectory "node"
$nodePackage = $packages | Where-Object { $_.ToolName -eq "node" } | Select-Object -First 1
$testCase = @{ NodeDirectory = $nodeDirectory }
It "Toolcache directory exists" -TestCases $testCase {
param ( [string] $NodeDirectory )
$NodeDirectory | Should -Exist
}
It "Toolcache directory contains at least one version of Node" -TestCases $testCase {
param ( [string] $NodeDirectory )
(Get-ChildItem -Path $NodeDirectory -Directory).Count | Should -BeGreaterThan 0
}
$nodePackage.Versions | Where-Object { $_ } | ForEach-Object {
Context "$_" {
$versionDirectory = Get-ChildItem -Path $nodeDirectory -Directory -Filter "$_*" | Select-Object -First 1
$nodeBinPath = Join-Path $versionDirectory.FullName $nodePackage.Arch "bin" "node"
$npmBinPath = Join-Path $versionDirectory.FullName $nodePackage.Arch "bin" "npm"
$testCase = @{ NodeVersion = $_; NodeBinPath = $nodeBinPath; NpmBinPath = $npmBinPath }
It "Version Node" -TestCases $testCase {
param (
[string] $NodeVersion,
[string] $NodeBinPath
)
$result = Get-CommandResult "$NodeBinPath --version"
$result.Output | Should -BeLike "*$NodeVersion*"
$result.ExitCode | Should -Be 0
}
It "Version Npm" -TestCases $testCase {
param ( [string] $NpmBinPath )
"$NpmBinPath --version" | Should -ReturnZeroExitCode
}
It "Run test script" -TestCases $testCase {
param ( [string] $NodeBinPath )
"$NodeBinPath -e 'console.log(process.version)'" | Should -ReturnZeroExitCode
}
}
}
}
Context "Go" {
$goDirectory = Join-Path $toolcacheDirectory "go"
$goPackage = $packages | Where-Object { $_.ToolName -eq "go" } | Select-Object -First 1
$testCase = @{ GoDirectory = $goDirectory }
It "Toolcache directory exists" -TestCases $testCase {
param ( [string] $GoDirectory )
$GoDirectory | Should -Exist
}
It "Toolcache directory contains at least one version of Go" -TestCases $testCase {
param ( [string] $GoDirectory )
(Get-ChildItem -Path $GoDirectory -Directory).Count | Should -BeGreaterThan 0
}
$goPackage.Versions | Where-Object { $_ } | ForEach-Object {
Context "$_" {
$versionDirectory = Get-ChildItem -Path $goDirectory -Directory -Filter "$_*" | Select-Object -First 1
$goBinPath = Join-Path $versionDirectory.FullName $goPackage.Arch "bin" "go"
$testCase = @{ GoVersion = $_; GoBinPath = $goBinPath }
It "Version Go" -TestCases $testCase {
param (
[string] $GoVersion,
[string] $GoBinPath
)
$result = Get-CommandResult "$GoBinPath version"
$result.Output | Should -BeLike "*$GoVersion*"
$result.ExitCode | Should -Be 0
}
}
}
}
}

View File

@@ -0,0 +1,144 @@
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1"
$toolsets = Get-ChildItem -Path $PSScriptRoot -Filter "toolset-*.json"
function Get-ShortVersion([System.Version] $Version) {
return [System.Version]::Parse($Version).ToString(2)
}
function Invoke-BashUtilsFunction([string] $FunctionName, [string]$parameter) {
$xamarinUtilsPath = "$PSScriptRoot/../provision/utils/xamarin-utils.sh"
return Invoke-Expression "bash -c `"source $xamarinUtilsPath && $FunctionName $parameter`""
}
Describe "Toolset JSON validation" {
$toolsets | ForEach-Object {
It "$($_.Name) is valid" {
$jsonContent = Get-Content -Raw $_.Fullname
$jsonContent | Test-Json | Should -BeTrue
}
}
}
$toolsets | ForEach-Object {
Describe "$($_.Name)" {
$toolset = Get-Content -Raw $_.Fullname | ConvertFrom-Json
Context "Xcode" {
It "Default Xcode should be defined" {
$toolset.xcode.default | Should -BeTrue
}
It "Default Xcode is listed in Xcode list" {
$toolset.xcode.versions | Should -Contain $toolset.xcode.default
}
}
Context "VSMac" {
$vsmacVersion = $toolset.xamarin.vsmac
It "Version '$vsmacVersion' is available and can be downloaded" {
$vsmacUrl = Invoke-BashUtilsFunction("buildVSMacDownloadUrl", $vsmacVersion)
Validate-Url $vsmacUrl
}
}
Context "Mono" {
$sdkVersions = $toolset.xamarin."mono-versions"
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildMonoDownloadUrl", $_)
Validate-Url $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"
}
}
Context "Xamarin.iOS" {
$sdkVersions = $toolset.xamarin."ios-versions"
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamariniIOSDownloadUrl", $_)
Validate-Url $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"
}
}
Context "Xamarin.Mac" {
$sdkVersions = $toolset.xamarin."mac-versions"
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamarinMacDownloadUrl", $_)
Validate-Url $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"
}
}
Context "Xamarin.Android" {
$sdkVersions = $toolset.xamarin."android-versions"
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamarinAndroidDownloadUrl", $_)
Validate-Url $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"
}
}
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 $_ }
# 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("-", ".") }
$bundles = $toolset.xamarin.bundles
$bundles | ForEach-Object {
It "'$($_.symlink)' is valid" {
$monoVersions | Should -Contain $_.mono
$iOSVersions | Should -Contain $_.ios
$macVersions | Should -Contain $_.mac
$androidVersions | Should -Contain $_.android
}
}
It "Each bundle has unique symlink" {
$symlinks = $bundles | ForEach-Object { $_.symlink }
Validate-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique"
}
It "Current bundle is valid" {
$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

@@ -0,0 +1,23 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Apache" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "Apache CLI" {
"httpd -v" | Should -ReturnZeroExitCode
}
It "Apache Service" {
brew services list | Out-String | Should -Match "httpd\s+(stopped|none)"
}
}
Describe "Nginx" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Nginx CLI" {
"nginx -v" | Should -ReturnZeroExitCode
}
It "Nginx Service" {
brew services list | Out-String | Should -Match "nginx\s+(stopped|none)"
}
}

View File

@@ -0,0 +1,309 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
if ($os.IsVentura -or $os.IsSonoma) {
$MONO_VERSIONS = @(Get-ToolsetValue "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"
}
BeforeAll {
function Get-ShortSymlink {
param (
[string] $Version
)
$versionParts = $Version.Split(".")
return [String]::Join(".", $versionParts[0..1])
}
}
Describe "Mono" {
$MONO_VERSIONS | ForEach-Object {
Context "$_" {
$MONO_VERSIONS_PATH = "/Library/Frameworks/Mono.framework/Versions"
$versionFolderPath = Join-Path $MONO_VERSIONS_PATH ([System.Version]::Parse($_).ToString(3))
$testCase = @{ MonoVersion = $_; VersionFolderPath = $versionFolderPath; MonoVersionsPath = $MONO_VERSIONS_PATH }
It "is installed" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$monoBinPath = Join-Path $VersionFolderPath "bin" "mono"
$VersionFolderPath | Should -Exist
$monoBinPath | Should -Exist
}
It "is available via short link" -TestCases $testCase {
param (
[string] $MonoVersion,
[string] $MonoVersionsPath,
[string] $VersionFolderPath
)
$shortSymlink = Get-ShortSymlink $MonoVersion # only 'major.minor'
$shortSymlinkFolderPath = Join-Path $MonoVersionsPath $shortSymlink
if ($shortSymlink -eq "4.8") { return } # Skip this test for Mono 4.8 because it doesn't contain VERSION file
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
It "NUnit console is installed" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$nunitPath = Join-Path $VersionFolderPath "Commands" "nunit3-console"
$nunitPath | Should -Exist
}
It "Nuget is installed" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$nugetBinaryPath = Join-Path $VersionFolderPath "lib" "mono" "nuget" "nuget.exe"
$nugetBinaryWrapperPath = Join-Path $VersionFolderPath "bin" "nuget"
$nugetCommandPath = Join-Path $VersionFolderPath "Commands" "nuget"
$nugetBinaryPath | Should -Exist
$nugetCommandPath | Should -Exist
$nugetBinaryWrapperPath | Should -Exist
}
It "Nuget is valid" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$nugetBinaryWrapperPath = Join-Path $VersionFolderPath "bin" "nuget"
"$nugetBinaryWrapperPath" | Should -ReturnZeroExitCode
}
}
}
It "MSBuild is available" {
"msbuild -version" | Should -ReturnZeroExitCode
}
}
Describe "Xamarin.iOS" -Skip:($os.IsVentura -or $os.IsSonoma) {
$XAMARIN_IOS_VERSIONS | ForEach-Object {
Context "$_" {
$XAMARIN_IOS_VERSIONS_PATH = "/Library/Frameworks/Xamarin.iOS.framework/Versions"
$versionFolderPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $_
$testCase = @{ XamarinIosVersion = $_; VersionFolderPath = $versionFolderPath; IosVersionsPath = $XAMARIN_IOS_VERSIONS_PATH }
It "is installed" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$xamarinBinPath = Join-Path $VersionFolderPath "bin"
$VersionFolderPath | Should -Exist
$xamarinBinPath | Should -Exist
}
It "is available via short link" -TestCases $testCase {
param (
[string] $XamarinIosVersion,
[string] $IosVersionsPath,
[string] $VersionFolderPath
)
$shortSymlink = Get-ShortSymlink $XamarinIosVersion # only 'major.minor'
$shortSymlinkFolderPath = Join-Path $IosVersionsPath $shortSymlink
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
}
}
}
Describe "Xamarin.Mac" -Skip:($os.IsVentura -or $os.IsSonoma) {
$XAMARIN_MAC_VERSIONS | ForEach-Object {
Context "$_" {
$XAMARIN_MAC_VERSIONS_PATH = "/Library/Frameworks/Xamarin.Mac.framework/Versions"
$versionFolderPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $_
$testCase = @{ XamarinMacVersion = $_; VersionFolderPath = $versionFolderPath; MacVersionsPath = $XAMARIN_MAC_VERSIONS_PATH }
It "is installed" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$xamarinBinPath = Join-Path $VersionFolderPath "bin"
$VersionFolderPath | Should -Exist
$xamarinBinPath | Should -Exist
}
It "is available via short link" -TestCases $testCase {
param (
[string] $XamarinMacVersion,
[string] $MacVersionsPath,
[string] $VersionFolderPath
)
$shortSymlink = Get-ShortSymlink $XamarinMacVersion # only 'major.minor'
$shortSymlinkFolderPath = Join-Path $MacVersionsPath $shortSymlink
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
}
}
}
Describe "Xamarin.Android" -Skip:($os.IsVentura -or $os.IsSonoma) {
$XAMARIN_ANDROID_VERSIONS | ForEach-Object {
Context "$_" {
$XAMARIN_ANDROID_VERSIONS_PATH = "/Library/Frameworks/Xamarin.Android.framework/Versions"
$versionFolderPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $_
$testCase = @{ XamarinAndroidVersion = $_; VersionFolderPath = $versionFolderPath; AndroidVersionsPath = $XAMARIN_ANDROID_VERSIONS_PATH }
It "is installed" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$xamarinLibPath = Join-Path $VersionFolderPath "lib"
$xamarinLibPath | Should -Exist
}
It "is available via short link" -TestCases $testCase {
param (
[string] $XamarinAndroidVersion,
[string] $AndroidVersionsPath,
[string] $VersionFolderPath
)
$shortSymlink = Get-ShortSymlink $XamarinAndroidVersion # only 'major.minor'
$shortSymlinkFolderPath = Join-Path $AndroidVersionsPath $shortSymlink
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
It "has correct symlinks" -TestCases $testCase {
param ( [string] $VersionFolderPath )
$xamarinLibPath = Join-Path $VersionFolderPath "lib"
Join-Path $xamarinLibPath "xbuild" | Should -Exist
Join-Path $xamarinLibPath "xbuild-frameworks" | Should -Exist
}
}
}
}
Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
BeforeAll {
$MONO_VERSIONS_PATH = "/Library/Frameworks/Mono.framework/Versions"
$XAMARIN_IOS_VERSIONS_PATH = "/Library/Frameworks/Xamarin.iOS.framework/Versions"
$XAMARIN_MAC_VERSIONS_PATH = "/Library/Frameworks/Xamarin.Mac.framework/Versions"
$XAMARIN_ANDROID_VERSIONS_PATH = "/Library/Frameworks/Xamarin.Android.framework/Versions"
}
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"
If ($XAMARIN_DEFAULT_BUNDLE -eq "latest") { $XAMARIN_DEFAULT_BUNDLE = $XAMARIN_BUNDLES[0].symlink }
$currentBundle = [PSCustomObject] @{
symlink = "Current"
mono = $XAMARIN_DEFAULT_BUNDLE
ios = $XAMARIN_DEFAULT_BUNDLE
mac = $XAMARIN_DEFAULT_BUNDLE
android = $XAMARIN_DEFAULT_BUNDLE
}
$latestBundle = [PSCustomObject] @{
symlink = "Latest"
mono = $XAMARIN_BUNDLES[0].mono
ios = $XAMARIN_BUNDLES[0].ios
mac = $XAMARIN_BUNDLES[0].mac
android = $XAMARIN_BUNDLES[0].android
}
$bundles = $XAMARIN_BUNDLES + $currentBundle + $latestBundle
$allBundles = $bundles | ForEach-Object { @{BundleSymlink = $_.symlink; BundleMono = $_.mono; BundleIos = $_.ios; BundleMac = $_.mac; BundleAndroid = $_.android } }
It "Mono symlink <BundleSymlink> exists" -TestCases $allBundles {
param ( [string] $BundleSymlink )
(Join-Path $MONO_VERSIONS_PATH $BundleSymlink) | Should -Exist
}
It "Mono symlink <BundleSymlink> points to the correct version" -TestCases $allBundles {
param (
[string] $BundleSymlink,
[string] $BundleMono
)
if ($BundleMono -eq "4.8") { return } # Skip this test for Mono 4.8 because it doesn't contain VERSION file
$sourceVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleMono "VERSION"
$targetVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "iOS symlink <BundleSymlink> exists" -TestCases $allBundles {
param ( [string] $BundleSymlink )
(Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleSymlink) | Should -Exist
}
It "iOS symlink <BundleSymlink> points to the correct version" -TestCases $allBundles {
param (
[string] $BundleSymlink,
[string] $BundleIos
)
$sourceVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleIos "VERSION"
$targetVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "Mac symlink <BundleSymlink> exists" -TestCases $allBundles {
param ( [string] $BundleSymlink )
(Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleSymlink) | Should -Exist
}
It "Mac symlink <BundleSymlink> points to the correct version" -TestCases $allBundles {
param (
[string] $BundleSymlink,
[string] $BundleMac
)
$sourceVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleMac "VERSION"
$targetVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "Xamarin.Android symlink <BundleSymlink> exists" -TestCases $allBundles {
param ( [string] $BundleSymlink )
(Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleSymlink) | Should -Exist
}
It "Android symlink <BundleSymlink> points to the correct version" -TestCases $allBundles {
param (
[string] $BundleSymlink,
[string] $BundleAndroid
)
$sourceVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleAndroid "VERSION"
$targetVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
}
Describe "Nuget" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Nuget config contains nuget.org feed" {
Get-Content $env:HOME/.config/NuGet/NuGet.Config | Out-String | Should -Match "nuget.org"
}
}

View File

@@ -0,0 +1,136 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
$ARCH = Get-Architecture
$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions"
$defaultXcode = Get-ToolsetValue "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 } }
Context "Versions" {
It "<XcodeVersion>" -TestCases $testCases {
$xcodebuildPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "xcodebuild"
"$xcodebuildPath -version" | Should -ReturnZeroExitCode
}
}
Context "Default" {
$defaultXcodeTestCase = @{ DefaultXcode = $defaultXcode }
It "Default Xcode is <DefaultXcode>" -TestCases $defaultXcodeTestCase {
"xcodebuild -version" | Should -ReturnZeroExitCode
(Get-CommandResult "xcodebuild -version").Output | Should -BeLike "Xcode ${DefaultXcode}*"
}
It "Xcode.app points to default Xcode" -TestCases $defaultXcodeTestCase {
$xcodeApp = "/Applications/Xcode.app"
$expectedTarget = Get-XcodeRootPath -Version $DefaultXcode
$xcodeApp | Should -Exist
$expectedTarget | Should -Exist
(Get-Item $xcodeApp).Target | Should -Be $expectedTarget
}
}
Context "Additional tools" {
It "Xcode <XcodeVersion> tools are installed" -TestCases $testCases {
$TOOLS_NOT_INSTALLED_EXIT_CODE = 69
$xcodebuildPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "xcodebuild"
$result = Get-CommandResult "$xcodebuildPath -checkFirstLaunchStatus"
if ($XcodeVersion -ne $LatestXcodeVersion) {
$result.ExitCode | Should -Not -Be $TOOLS_NOT_INSTALLED_EXIT_CODE
} else {
$result.ExitCode | Should -BeIn (0, $TOOLS_NOT_INSTALLED_EXIT_CODE)
}
}
}
Context "Symlinks" {
It "Xcode <XcodeVersion> has correct symlinks" -TestCases $testCases {
$sourcePath = Get-XcodeRootPath -Version $XcodeVersion
$Symlinks | Where-Object { $_ } | ForEach-Object {
$targetPath = Get-XcodeRootPath -Version $_
$targetPath | Should -Exist
(Get-Item $targetPath).Target | Should -Be $sourcePath
}
}
}
It "/Applications/Xcode* symlinks are valid" {
$symlinks = Get-ChildItem "/Applications" -Filter "Xcode*" | Where-Object { $_.LinkType }
$symlinks.Target | ForEach-Object {
$_ | Should -Exist
}
}
}
Describe "XCODE_DEVELOPER_DIR variables" {
$exactVersionsList = $xcodeVersions.link | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object {
$xcodeRootPath = Get-XcodeRootPath -Version $_
$xcodeVersionInfo = Get-XcodeVersionInfo -XcodeRootPath $xcodeRootPath
return @{
RootPath = $xcodeRootPath
Version = [SemVer]::Parse($xcodeVersionInfo.Version)
}
} | Sort-Object -Property Version -Descending
$majorVersions = $exactVersionsList.Version.Major | Select-Object -Unique
$testCases = $majorVersions | ForEach-Object { @{ MajorVersion = $_; VersionsList = $exactVersionsList } }
It "XCODE_<MajorVersion>_DEVELOPER_DIR" -TestCases $testCases {
$variableName = "XCODE_${MajorVersion}_DEVELOPER_DIR"
$actualPath = Get-EnvironmentVariable $variableName
$expectedVersion = $VersionsList | Where-Object { $_.Version.Major -eq $MajorVersion } | Select-Object -First 1
$expectedPath = "$($expectedVersion.RootPath)/Contents/Developer"
$actualPath | Should -Exist
$actualPath | Should -Be $expectedPath
}
}
Describe "Xcode simulators" {
$xcodeVersions.link | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object {
Context "$_" {
$testCase = @{ XcodeVersion = $_ }
It "No duplicates in devices" -TestCases $testCase {
Switch-Xcode -Version $XcodeVersion
[array]$devicesList = @(Get-XcodeDevicesList | Where-Object { $_ })
Write-Host "Devices for $XcodeVersion"
Write-Host ($devicesList -join "`n")
Validate-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"
Switch-Xcode -Version $defaultXcode
}
}
Describe "Xcode Simulators Naming" -Skip:(-not $os.IsMonterey) {
$testCases = Get-BrokenXcodeSimulatorsList
It "Simulator '<SimulatorName> [<RuntimeId>]'" -TestCases $testCases {
$simctlPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "simctl"
[string]$rawDevicesInfo = Invoke-Expression "$simctlPath list devices --json"
$jsonDevicesInfo = ($rawDevicesInfo | ConvertFrom-Json).devices
$foundSimulators = $jsonDevicesInfo.$RuntimeId | Where-Object { $_.deviceTypeIdentifier -eq $DeviceId }
$foundSimulators | Should -HaveCount 1
$foundSimulators[0].name | Should -Be $SimulatorName
$foundSimulators = $jsonDevicesInfo.$RuntimeId | Where-Object { $_.name -eq $SimulatorName }
$foundSimulators | Should -HaveCount 1
$foundSimulators[0].deviceTypeIdentifier | Should -Be $DeviceId
}
}