mirror of
https://github.com/actions/runner-images.git
synced 2025-12-24 10:28:00 +08:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
15
images/windows/scripts/tests/ActionArchiveCache.Tests.ps1
Normal file
15
images/windows/scripts/tests/ActionArchiveCache.Tests.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
Describe "ActionArchiveCache" {
|
||||
Context "Action archive cache directory not empty" {
|
||||
It "C:\actionarchivecache not empty" {
|
||||
(Get-ChildItem -Path "C:\actionarchivecache\*.zip" -Recurse).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "Action zipball not empty" {
|
||||
$testCases = Get-ChildItem -Path "C:\actionarchivecache\*.zip" -Recurse | ForEach-Object { @{ ActionZipball = $_.FullName } }
|
||||
It "<ActionZipball>" -TestCases $testCases {
|
||||
param ([string] $ActionZipball)
|
||||
(Get-Item "$ActionZipball").Length | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
}
|
||||
100
images/windows/scripts/tests/Android.Tests.ps1
Normal file
100
images/windows/scripts/tests/Android.Tests.ps1
Normal file
@@ -0,0 +1,100 @@
|
||||
Import-Module (Join-Path $PSScriptRoot "..\SoftwareReport\SoftwareReport.Android.psm1") -DisableNameChecking
|
||||
|
||||
Describe "Android SDK" {
|
||||
$androidToolset = (Get-ToolsetContent).android
|
||||
$androidPackages = Get-AndroidPackages -AndroidSDKManagerPath (Get-AndroidSDKManagerPath)
|
||||
$androidInstalledPackages = Get-AndroidInstalledPackages
|
||||
|
||||
$ndkDefaultMajorVersion = $androidToolset.ndk.default
|
||||
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultMajorVersion.*" -Name | Select-Object -Last 1
|
||||
$ndkVersions = $androidToolset.ndk.versions
|
||||
$ndkPackagesTestCases = $ndkVersions | ForEach-Object {
|
||||
@{ ndkPackage = $_; installedPackages = $androidInstalledPackages }
|
||||
}
|
||||
|
||||
$platformTestCases = @()
|
||||
[int]$platformMinVersion = $androidToolset.platform_min_version
|
||||
$platformList = Get-AndroidPackagesByVersion -AndroidPackages $androidPackages `
|
||||
-PrefixPackageName "platforms;" `
|
||||
-MinimumVersion $platformMinVersion `
|
||||
-Delimiter "-" `
|
||||
-Index 1
|
||||
|
||||
$platformList | ForEach-Object {
|
||||
$platformTestCases += @{ platformVersion = $_; installedPackages = $androidInstalledPackages }
|
||||
}
|
||||
|
||||
$buildToolsTestCases = @()
|
||||
[version]$buildToolsMinVersion = $androidToolset.build_tools_min_version
|
||||
$buildToolsList = Get-AndroidPackagesByVersion -AndroidPackages $androidPackages `
|
||||
-PrefixPackageName "build-tools;" `
|
||||
-MinimumVersion $buildToolsMinVersion `
|
||||
-Delimiter ";" `
|
||||
-Index 1
|
||||
$buildToolsList | ForEach-Object {
|
||||
$buildToolsTestCases += @{ buildToolsVersion = $_; installedPackages = $androidInstalledPackages }
|
||||
}
|
||||
|
||||
$extraPackagesTestCases = @()
|
||||
$extraPackageList = $androidToolset.extra_list
|
||||
$extraPackageList | ForEach-Object {
|
||||
$extraPackagesTestCases += @{ extraPackage = $_; installedPackages = $androidInstalledPackages }
|
||||
}
|
||||
|
||||
$addonsTestCases = @()
|
||||
$addonsPackageList = $androidToolset.addon_list
|
||||
$addonsPackageList | ForEach-Object {
|
||||
$addonsTestCases += @{ addonPackage = $_; installedPackages = $androidInstalledPackages }
|
||||
}
|
||||
|
||||
$additionalToolsTestCases = @()
|
||||
$additionalToolsList = $androidToolset.additional_tools
|
||||
$additionalToolsList | ForEach-Object {
|
||||
$additionalToolsTestCases += @{ additionalToolVersion = $_; installedPackages = $androidInstalledPackages }
|
||||
}
|
||||
|
||||
Context "SDKManagers" {
|
||||
$testCases = @(
|
||||
@{
|
||||
PackageName = "SDK tools"
|
||||
Sdkmanager = "$env:ANDROID_HOME\tools\bin\sdkmanager.bat"
|
||||
},
|
||||
@{
|
||||
PackageName = "Command-line tools"
|
||||
Sdkmanager = "$env:ANDROID_HOME\cmdline-tools\latest\bin\sdkmanager.bat"
|
||||
}
|
||||
)
|
||||
|
||||
It "Sdkmanager from <PackageName> is available" -TestCases $testCases {
|
||||
"$Sdkmanager --list" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Context "Packages" {
|
||||
It "Platform version <platformVersion> is installed" -TestCases $platformTestCases {
|
||||
"$installedPackages" | Should -Match "$platformVersion"
|
||||
}
|
||||
|
||||
It "Platform build tools <buildToolsVersion> is installed" -TestCases $buildToolsTestCases {
|
||||
"$installedPackages" | Should -Match "$buildToolsVersion"
|
||||
}
|
||||
|
||||
if (Test-IsWin19) {
|
||||
It "Extra package <extraPackage> is installed" -TestCases $extraPackagesTestCases {
|
||||
"$installedPackages" | Should -Match "extras;$extraPackage"
|
||||
}
|
||||
|
||||
It "Addon package <addonPackage> is installed" -TestCases $addonsTestCases {
|
||||
"$installedPackages" | Should -Match "add-ons;$addonPackage"
|
||||
}
|
||||
}
|
||||
|
||||
It "Additional tool <additionalToolVersion> is installed" -TestCases $additionalToolsTestCases {
|
||||
"$installedPackages" | Should -Match $additionalToolVersion
|
||||
}
|
||||
|
||||
It "NDK <ndkPackage> is installed" -TestCases $ndkPackagesTestCases {
|
||||
"$installedPackages" | Should -Match "ndk;$ndkPackage"
|
||||
}
|
||||
}
|
||||
}
|
||||
25
images/windows/scripts/tests/Apache.Tests.ps1
Normal file
25
images/windows/scripts/tests/Apache.Tests.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
Describe "Apache" {
|
||||
Context "Path" {
|
||||
It "Apache" {
|
||||
$apachePath = Join-Path (Join-Path "C:\tools\" (Get-Item C:\tools\apache*).Name) "\bin\httpd"
|
||||
"$apachePath -V" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Context "Service" {
|
||||
$apacheService = Get-Service -Name Apache
|
||||
$apacheServiceTests = @{
|
||||
Name = $apacheService.Name
|
||||
Status = $apacheService.Status
|
||||
StartType = $apacheService.StartType
|
||||
}
|
||||
|
||||
It "<Name> service is stopped" -TestCases $apacheServiceTests {
|
||||
$Status | Should -Be "Stopped"
|
||||
}
|
||||
|
||||
It "<Name> service is disabled" -TestCases $apacheServiceTests {
|
||||
$StartType | Should -Be "Disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
images/windows/scripts/tests/BizTalk.Tests.ps1
Normal file
19
images/windows/scripts/tests/BizTalk.Tests.ps1
Normal file
@@ -0,0 +1,19 @@
|
||||
################################################################################
|
||||
## File: BizTalk.Tests.ps1
|
||||
## Desc: Test BizTalk project build component installed.
|
||||
################################################################################
|
||||
|
||||
Describe "BizTalk Build Component Setup" -Skip:(-not (Test-IsWin19)) {
|
||||
It "BizTalk Registry Check" {
|
||||
Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\BizTalk Server\3.0" | Should -BeTrue
|
||||
}
|
||||
|
||||
It "BizTalk Folder Check" {
|
||||
"${env:ProgramFiles(x86)}\Microsoft BizTalk Server" | Should -Exist
|
||||
}
|
||||
|
||||
It "BizTalk Build Targets files Check" {
|
||||
"${env:ProgramFiles(x86)}\MSBuild\Microsoft\BizTalk\BizTalkC.targets" | Should -Exist
|
||||
"${env:ProgramFiles(x86)}\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets" | Should -Exist
|
||||
}
|
||||
}
|
||||
160
images/windows/scripts/tests/Browsers.Tests.ps1
Normal file
160
images/windows/scripts/tests/Browsers.Tests.ps1
Normal file
@@ -0,0 +1,160 @@
|
||||
Describe "Chrome" {
|
||||
Context "WebDriver" {
|
||||
It "ChromeWebDriver environment variable and path exists" {
|
||||
$env:ChromeWebDriver | Should -Not -BeNullOrEmpty
|
||||
$env:ChromeWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\ChromeDriver"
|
||||
$env:ChromeWebDriver | Should -Exist
|
||||
}
|
||||
|
||||
It "chromedriver.exe is installed" {
|
||||
"$env:ChromeWebDriver\chromedriver.exe --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "versioninfo.txt exists" {
|
||||
"$env:ChromeWebDriver\versioninfo.txt" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Browser" {
|
||||
$chromeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe"
|
||||
$chromePath = (Get-ItemProperty $chromeRegPath).'(default)'
|
||||
|
||||
It "Chrome '<chromeRegPath>' registry path exists" -TestCases @{chromeRegPath = $chromeRegPath} {
|
||||
$chromeRegPath | Should -Exist
|
||||
}
|
||||
|
||||
It "Chrome VersionInfo registry value exists" -TestCases @{chromePath = $chromePath} {
|
||||
$versionInfo = (Get-Item $chromePath).VersionInfo
|
||||
$versionInfo | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "gupdate service is stopped" {
|
||||
$svc = Get-Service -Name gupdate
|
||||
$svc.Status | Should -BeExactly Stopped
|
||||
}
|
||||
|
||||
It "gupdatem service is stopped" {
|
||||
$svc = Get-Service -Name gupdatem
|
||||
$svc.Status | Should -BeExactly Stopped
|
||||
}
|
||||
|
||||
It "BlockGoogleUpdate firewall rule exists" {
|
||||
Get-NetFirewallRule -DisplayName BlockGoogleUpdate | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "<chromePath> is installed" -TestCases @{chromePath = $chromePath} {
|
||||
$chromeName = (Get-Item $chromePath).Name
|
||||
$chromePath | Should -Exist
|
||||
$chromeName | Should -BeExactly "chrome.exe"
|
||||
}
|
||||
|
||||
It "Chrome and Chrome Driver major versions are the same" -TestCases @{chromePath = $chromePath} {
|
||||
$chromeMajor = (Get-Item $chromePath).VersionInfo.ProductMajorPart
|
||||
$chromeDriverMajor = (Get-Content $env:ChromeWebDriver\versioninfo.txt).Split(".")[0]
|
||||
$chromeMajor | Should -BeExactly $chromeDriverMajor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Edge" {
|
||||
Context "WebDriver" {
|
||||
It "EdgeWebDriver environment variable and path exists" {
|
||||
$env:EdgeWebDriver | Should -Not -BeNullOrEmpty
|
||||
$env:EdgeWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\EdgeDriver"
|
||||
$env:EdgeWebDriver | Should -Exist
|
||||
}
|
||||
|
||||
It "msedgedriver.exe is installed" {
|
||||
"$env:EdgeWebDriver\msedgedriver.exe --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "versioninfo.txt exists" {
|
||||
"$env:EdgeWebDriver\versioninfo.txt" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Browser" {
|
||||
$edgeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe"
|
||||
|
||||
It "Edge '<edgeRegPath>' registry path exists" -TestCases @{edgeRegPath = $edgeRegPath} {
|
||||
$edgeRegPath | Should -Exist
|
||||
}
|
||||
|
||||
It "Edge VersionInfo registry value exists" -TestCases @{edgeRegPath = $edgeRegPath} {
|
||||
$versionInfo = (Get-Item (Get-ItemProperty $edgeRegPath).'(Default)').VersionInfo
|
||||
$versionInfo | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "msedge.exe is installed" {
|
||||
"${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" | Should -Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Firefox" {
|
||||
Context "WebDriver" {
|
||||
It "GeckoWebDriver environment variable and path exists" {
|
||||
$env:GeckoWebDriver | Should -Not -BeNullOrEmpty
|
||||
$env:GeckoWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\GeckoDriver"
|
||||
$env:GeckoWebDriver | Should -Exist
|
||||
}
|
||||
|
||||
It "geckodriver.exe is installed" {
|
||||
"$env:GeckoWebDriver\geckodriver.exe --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "versioninfo.txt exists" {
|
||||
"$env:GeckoWebDriver\versioninfo.txt" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Browser" {
|
||||
$firefoxRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe"
|
||||
|
||||
It "Firefox '<firefoxRegPath>' registry path exists" -TestCases @{firefoxRegPath = $firefoxRegPath} {
|
||||
$firefoxRegPath | Should -Exist
|
||||
}
|
||||
|
||||
It "Firefox VersionInfo registry value exists" -TestCases @{firefoxRegPath = $firefoxRegPath} {
|
||||
$versionInfo = (Get-Item (Get-ItemProperty $firefoxRegPath).'(Default)').VersionInfo
|
||||
$versionInfo | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "firefox.exe is installed" {
|
||||
"$env:ProgramFiles\Mozilla Firefox\firefox.exe" | Should -Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Internet Explorer" {
|
||||
Context "WebDriver" {
|
||||
It "IEWebDriver environment variable and path exists" {
|
||||
$env:IEWebDriver | Should -Not -BeNullOrEmpty
|
||||
$env:IEWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\IEDriver"
|
||||
$env:IEWebDriver | Should -Exist
|
||||
}
|
||||
|
||||
It "iedriverserver.exe is installed" {
|
||||
"$env:IEWebDriver\IEDriverServer.exe --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "versioninfo.txt exists" {
|
||||
"$env:IEWebDriver\versioninfo.txt" | Should -Exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Selenium" {
|
||||
BeforeAll {
|
||||
$seleniumBinaryName = (Get-ToolsetContent).selenium.binary_name
|
||||
$seleniumBinPath = Join-Path "C:\selenium\" "$seleniumBinaryName.jar"
|
||||
}
|
||||
|
||||
It "Selenium server is installed" {
|
||||
$seleniumBinPath | Should -Exist
|
||||
}
|
||||
|
||||
It "SELENIUM_JAR_PATH environment variable exists" {
|
||||
Get-EnvironmentVariable "SELENIUM_JAR_PATH" | Should -BeExactly "$seleniumBinPath"
|
||||
}
|
||||
}
|
||||
50
images/windows/scripts/tests/CLI.Tools.Tests.ps1
Normal file
50
images/windows/scripts/tests/CLI.Tools.Tests.ps1
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
Describe "Azure CLI" {
|
||||
It "Azure CLI" {
|
||||
"az --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Azure DevOps CLI" {
|
||||
It "az devops" {
|
||||
"az devops -h" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Aliyun CLI" {
|
||||
It "Aliyun CLI" {
|
||||
"aliyun version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Describe "AWS" {
|
||||
It "AWS CLI" {
|
||||
"aws --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Session Manager Plugin for the AWS CLI" {
|
||||
@(session-manager-plugin) -Match '\S' | Out-String | Should -Match "plugin was installed successfully"
|
||||
}
|
||||
|
||||
It "AWS SAM CLI" {
|
||||
"sam --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Describe "GitHub CLI" {
|
||||
It "gh" {
|
||||
"gh --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "CloudFoundry CLI" -Skip:(Test-IsWin22) {
|
||||
It "cf is located in C:\cf-cli" {
|
||||
"C:\cf-cli\cf.exe" | Should -Exist
|
||||
}
|
||||
|
||||
It "cf" {
|
||||
"cf --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
105
images/windows/scripts/tests/ChocoPackages.Tests.ps1
Normal file
105
images/windows/scripts/tests/ChocoPackages.Tests.ps1
Normal file
@@ -0,0 +1,105 @@
|
||||
Describe "7-Zip" {
|
||||
It "7z" {
|
||||
"7z" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Aria2" {
|
||||
It "Aria2" {
|
||||
"aria2c --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "AzCopy" {
|
||||
It "AzCopy" {
|
||||
"azcopy --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Bicep" {
|
||||
It "Bicep" {
|
||||
"bicep --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "GitVersion" -Skip:(Test-IsWin22) {
|
||||
It "gitversion is installed" {
|
||||
"gitversion /version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "InnoSetup" {
|
||||
It "InnoSetup" {
|
||||
(Get-Command -Name iscc).CommandType | Should -BeExactly "Application"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Jq" {
|
||||
It "Jq" {
|
||||
"jq -n ." | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Nuget" {
|
||||
It "Nuget" {
|
||||
"nuget" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Packer" {
|
||||
It "Packer" {
|
||||
"packer --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Perl" {
|
||||
It "Perl" {
|
||||
"perl --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Pulumi" {
|
||||
It "pulumi" {
|
||||
"pulumi version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Svn" {
|
||||
It "svn" {
|
||||
"svn --version --quiet" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Swig" {
|
||||
It "Swig" {
|
||||
"swig -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "VSWhere" {
|
||||
It "vswhere" {
|
||||
"vswhere" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Julia" {
|
||||
It "Julia path exists" {
|
||||
"C:\Julia" | Should -Exist
|
||||
}
|
||||
|
||||
It "Julia" {
|
||||
"julia --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "CMake" {
|
||||
It "cmake" {
|
||||
"cmake --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "ImageMagick" {
|
||||
It "ImageMagick" {
|
||||
"magick -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
90
images/windows/scripts/tests/Databases.Tests.ps1
Normal file
90
images/windows/scripts/tests/Databases.Tests.ps1
Normal file
@@ -0,0 +1,90 @@
|
||||
Describe "MongoDB" {
|
||||
Context "Version" {
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "mongo" }
|
||||
@{ ToolName = "mongod" }
|
||||
) {
|
||||
$toolsetVersion = (Get-ToolsetContent).mongodb.version
|
||||
(&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
|
||||
}
|
||||
}
|
||||
|
||||
Context "Service" {
|
||||
$mongoService = Get-Service -Name mongodb -ErrorAction Ignore
|
||||
$mongoServiceTests = @{
|
||||
Name = $mongoService.Name
|
||||
Status = $mongoService.Status
|
||||
StartType = $mongoService.StartType
|
||||
}
|
||||
|
||||
It "<Name> service is stopped" -TestCases $mongoServiceTests {
|
||||
$Status | Should -Be "Stopped"
|
||||
}
|
||||
|
||||
It "<Name> service is disabled" -TestCases $mongoServiceTests {
|
||||
$StartType | Should -Be "Disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "PostgreSQL" {
|
||||
$psqlTests = @(
|
||||
@{envVar = "PGROOT"; pgPath = Get-EnvironmentVariable "PGROOT"}
|
||||
@{envVar = "PGBIN"; pgPath = Get-EnvironmentVariable "PGBIN"}
|
||||
@{envVar = "PGDATA"; pgPath = Get-EnvironmentVariable "PGDATA"}
|
||||
)
|
||||
|
||||
Context "Environment variable" {
|
||||
It "PGUSER contains postgres" {
|
||||
Get-EnvironmentVariable "PGUSER" | Should -Be "postgres"
|
||||
}
|
||||
|
||||
It "PGPASSWORD contains root" {
|
||||
Get-EnvironmentVariable "PGPASSWORD" | Should -Be "root"
|
||||
}
|
||||
|
||||
It "<envVar> environment variable exists" -TestCases $psqlTests {
|
||||
Get-EnvironmentVariable $envVar | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Context "Path" {
|
||||
It "<pgPath> path exists" -TestCases $psqlTests {
|
||||
$pgPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Service" {
|
||||
$psqlService = Get-Service -Name postgresql*
|
||||
$psqlServiceTests = @{
|
||||
Name = $psqlService.Name
|
||||
Status = $psqlService.Status
|
||||
StartType = $psqlService.StartType
|
||||
}
|
||||
|
||||
It "<Name> service is stopped" -TestCases $psqlServiceTests {
|
||||
$Status | Should -Be "Stopped"
|
||||
}
|
||||
|
||||
It "<Name> service is disabled" -TestCases $psqlServiceTests {
|
||||
$StartType | Should -Be "Disabled"
|
||||
}
|
||||
}
|
||||
|
||||
Context "PostgreSQL version" {
|
||||
It "PostgreSQL version should correspond to the version in the toolset" {
|
||||
$toolsetVersion = (Get-ToolsetContent).postgresql.version
|
||||
# Client version
|
||||
(&$Env:PGBIN\psql --version).split()[-1] | Should -BeLike "$toolsetVersion*"
|
||||
# Server version
|
||||
(&$Env:PGBIN\pg_config --version).split()[-1] | Should -BeLike "$toolsetVersion*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "MySQL" {
|
||||
It "MySQL CLI" {
|
||||
$MysqlVersion = (Get-ToolsetContent).mysql.version
|
||||
mysql -V | Should -BeLike "*${MysqlVersion}*"
|
||||
}
|
||||
}
|
||||
40
images/windows/scripts/tests/Docker.Tests.ps1
Normal file
40
images/windows/scripts/tests/Docker.Tests.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
Describe "Docker" {
|
||||
It "docker is installed" {
|
||||
"docker --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "docker service is up" {
|
||||
"docker images" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "docker symlink" {
|
||||
"C:\Windows\SysWOW64\docker.exe ps" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "DockerCompose" {
|
||||
It "docker-compose is installed" {
|
||||
"docker-compose --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "docker compose v2" {
|
||||
"docker compose version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Describe "DockerWinCred" {
|
||||
It "docker-wincred" {
|
||||
"docker-credential-wincred version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "DockerImages" {
|
||||
Context "docker images" {
|
||||
$testCases = (Get-ToolsetContent).docker.images | ForEach-Object { @{ ImageName = $_ } }
|
||||
|
||||
It "<ImageName>" -TestCases $testCases {
|
||||
docker images "$ImageName" --format "{{.Repository}}" | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
34
images/windows/scripts/tests/DotnetSDK.Tests.ps1
Normal file
34
images/windows/scripts/tests/DotnetSDK.Tests.ps1
Normal file
@@ -0,0 +1,34 @@
|
||||
$dotnetVersions = (Get-ToolsetContent).dotnet.versions
|
||||
$dotnetTools = (Get-ToolsetContent).dotnet.tools
|
||||
|
||||
Describe "Dotnet SDK and tools" {
|
||||
|
||||
Context "Default" {
|
||||
It "Default Dotnet SDK is available" {
|
||||
"dotnet --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($version in $dotnetVersions) {
|
||||
Context "Dotnet $version" {
|
||||
$dotnet = @{ dotnetVersion = $version }
|
||||
|
||||
It "SDK $version is available" -TestCases $dotnet {
|
||||
(dotnet --list-sdks | Where-Object { $_ -match "${dotnetVersion}\.[0-9]*" }).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
|
||||
It "Runtime $version is available" -TestCases $dotnet {
|
||||
(dotnet --list-runtimes | Where-Object { $_ -match "${dotnetVersion}\.[0-9]*" }).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Dotnet tools" {
|
||||
$env:Path += ";C:\Users\Default\.dotnet\tools"
|
||||
$testCases = $dotnetTools | ForEach-Object { @{ ToolName = $_.name; TestInstance = $_.test }}
|
||||
|
||||
It "<ToolName> is available" -TestCases $testCases {
|
||||
"$TestInstance" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
}
|
||||
25
images/windows/scripts/tests/Git.Tests.ps1
Normal file
25
images/windows/scripts/tests/Git.Tests.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
Describe "Git" {
|
||||
$gitTools = 'bash', 'awk', 'git', 'git-lfs'
|
||||
$gitTestCases = $gitTools | ForEach-Object {
|
||||
@{
|
||||
toolName = $_
|
||||
source = [regex]::Escape("$env:ProgramFiles\Git")
|
||||
}
|
||||
}
|
||||
|
||||
It "<toolName> is installed" -TestCases $gitTestCases {
|
||||
"$toolName --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "<toolName> is located in '<source>'" -TestCases $gitTestCases {
|
||||
(Get-Command -Name $toolName).Source | Should -Match $source
|
||||
}
|
||||
|
||||
It "Git core.symlinks=true option is enabled" {
|
||||
git config core.symlinks | Should -BeExactly true
|
||||
}
|
||||
|
||||
It "GCM_INTERACTIVE environment variable should be equal Never" {
|
||||
$env:GCM_INTERACTIVE | Should -BeExactly Never
|
||||
}
|
||||
}
|
||||
62
images/windows/scripts/tests/Haskell.Tests.ps1
Normal file
62
images/windows/scripts/tests/Haskell.Tests.ps1
Normal file
@@ -0,0 +1,62 @@
|
||||
Describe "Haskell" {
|
||||
$ghcPackagesPath = "c:\ghcup\ghc"
|
||||
[array]$ghcVersionList = Get-ChildItem -Path $ghcPackagesPath -Filter "*" | ForEach-Object { $_.Name.Trim() }
|
||||
$ghcCount = $ghcVersionList.Count
|
||||
$defaultGhcVersion = $ghcVersionList | Sort-Object {[Version]$_} | Select-Object -Last 1
|
||||
$ghcDefaultCases = @{
|
||||
defaultGhcVersion = $defaultGhcVersion
|
||||
defaultGhcShortVersion = ([version]$defaultGhcVersion).ToString(3)
|
||||
}
|
||||
|
||||
$ghcTestCases = $ghcVersionList | ForEach-Object {
|
||||
$ghcVersion = $_
|
||||
$ghcShortVersion = ([version]$ghcVersion).ToString(3)
|
||||
$binGhcPath = Join-Path $ghcPackagesPath "$ghcShortVersion\bin\ghc.exe"
|
||||
@{
|
||||
ghcVersion = $ghcVersion
|
||||
ghcShortVersion = $ghcShortVersion
|
||||
binGhcPath = $binGhcPath
|
||||
}
|
||||
}
|
||||
|
||||
$ghcupEnvExists = @(
|
||||
@{envVar = "GHCUP_INSTALL_BASE_PREFIX"}
|
||||
@{envVar = "GHCUP_MSYS2"}
|
||||
)
|
||||
|
||||
It "<envVar> environment variable exists" -TestCases $ghcupEnvExists {
|
||||
Test-Path env:\$envVar
|
||||
}
|
||||
|
||||
It "Accurate 3 versions of GHC are installed" -TestCases @{ghcCount = $ghcCount} {
|
||||
$ghcCount | Should -BeExactly 3
|
||||
}
|
||||
|
||||
It "GHC <ghcVersion> is installed" -TestCases $ghcTestCases {
|
||||
"$binGhcPath --version" | Should -MatchCommandOutput $ghcShortVersion
|
||||
}
|
||||
|
||||
It "GHC <defaultGhcVersion> is the default version and should be the latest installed" -TestCases $ghcDefaultCases {
|
||||
"ghc --version" | Should -MatchCommandOutput $defaultGhcShortVersion
|
||||
}
|
||||
|
||||
It "Cabal is installed" {
|
||||
"cabal --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "cabal folder does not exist" {
|
||||
$env:CABAL_DIR | Should -Not -Exist
|
||||
}
|
||||
|
||||
It "CABAL_DIR environment variable exists" {
|
||||
Get-EnvironmentVariable CABAL_DIR | Should -BeExactly "C:\cabal"
|
||||
}
|
||||
|
||||
It "ghcup is installed" {
|
||||
"ghcup --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "ghcup can access msys2" {
|
||||
"ghcup run --mingw-path -- pacman --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
40
images/windows/scripts/tests/Java.Tests.ps1
Normal file
40
images/windows/scripts/tests/Java.Tests.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
Describe "Java" {
|
||||
$toolsetJava = (Get-ToolsetContent).java
|
||||
$defaultVersion = $toolsetJava.default
|
||||
$jdkVersions = $toolsetJava.versions
|
||||
|
||||
[array]$testCases = $jdkVersions | ForEach-Object { @{Version = $_ } }
|
||||
|
||||
It "Java <DefaultJavaVersion> is default" -TestCases @(@{ DefaultJavaVersion = $defaultVersion }) {
|
||||
$actualJavaPath = Get-EnvironmentVariable "JAVA_HOME"
|
||||
$expectedJavaPath = Get-EnvironmentVariable "JAVA_HOME_${DefaultJavaVersion}_X64"
|
||||
|
||||
$actualJavaPath | Should -Not -BeNullOrEmpty
|
||||
$expectedJavaPath | Should -Not -BeNullOrEmpty
|
||||
$actualJavaPath | Should -Be $expectedJavaPath
|
||||
}
|
||||
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "java" }
|
||||
@{ ToolName = "mvn" }
|
||||
@{ ToolName = "ant" }
|
||||
@{ ToolName = "gradle" }
|
||||
) {
|
||||
"$ToolName -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Java <Version>" -TestCases $testCases {
|
||||
$javaVariableValue = Get-EnvironmentVariable "JAVA_HOME_${Version}_X64"
|
||||
$javaVariableValue | Should -Not -BeNullOrEmpty
|
||||
$javaPath = Join-Path $javaVariableValue "bin\java"
|
||||
|
||||
$result = Get-CommandResult "`"$javaPath`" -version"
|
||||
$result.ExitCode | Should -Be 0
|
||||
|
||||
if ($Version -eq 8) {
|
||||
$Version = "1.${Version}"
|
||||
}
|
||||
$outputPattern = "openjdk version `"${Version}"
|
||||
$result.Output[0] | Should -Match $outputPattern
|
||||
}
|
||||
}
|
||||
10
images/windows/scripts/tests/LLVM.Tests.ps1
Normal file
10
images/windows/scripts/tests/LLVM.Tests.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
Describe "Clang/LLVM" {
|
||||
BeforeAll {
|
||||
$toolsetVersion = (Get-ToolsetContent).llvm.version
|
||||
}
|
||||
|
||||
It "Clang/LLVM <toolsetVersion> installed and version is correct" {
|
||||
$clangVersion = clang --version
|
||||
$clangVersion[0] | Should -BeLike "*${toolsetVersion}*"
|
||||
}
|
||||
}
|
||||
72
images/windows/scripts/tests/MSYS2.Tests.ps1
Normal file
72
images/windows/scripts/tests/MSYS2.Tests.ps1
Normal file
@@ -0,0 +1,72 @@
|
||||
BeforeAll {
|
||||
$msys2Dir = "C:\msys64\usr\bin"
|
||||
$originalPath = $env:PATH
|
||||
}
|
||||
|
||||
Describe "MSYS2 packages" {
|
||||
BeforeEach {
|
||||
$env:PATH = "$msys2Dir;$env:PATH"
|
||||
}
|
||||
|
||||
It "msys2Dir exists" {
|
||||
$msys2Dir | Should -Exist
|
||||
}
|
||||
|
||||
$TestCases = @(
|
||||
@{ ToolName = "bash.exe" }
|
||||
)
|
||||
|
||||
if (Test-IsWin19) {
|
||||
$TestCases += @(
|
||||
@{ ToolName = "tar.exe" }
|
||||
@{ ToolName = "make.exe" }
|
||||
)
|
||||
}
|
||||
|
||||
It "<ToolName> is installed in <msys2Dir>" -TestCases $TestCases {
|
||||
(Get-Command "$ToolName").Source | Should -BeLike "$msys2Dir*"
|
||||
}
|
||||
|
||||
It "<ToolName> is avaialable" -TestCases $TestCases {
|
||||
"$ToolName" | Should -ReturnZeroExitCodeWithParam
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
$env:PATH = $originalPath
|
||||
}
|
||||
}
|
||||
|
||||
$mingwTypes = (Get-ToolsetContent).MsysPackages.mingw
|
||||
foreach ($mingwType in $mingwTypes) {
|
||||
Describe "$($mingwType.arch) packages" {
|
||||
$tools = $mingwType.runtime_packages
|
||||
$execDir = Join-Path "C:\msys64" $mingwType.exec_dir | Join-Path -ChildPath "bin"
|
||||
|
||||
foreach ($tool in $tools) {
|
||||
Context "$($tool.name) package"{
|
||||
$executables = $tool.executables | ForEach-Object {
|
||||
@{
|
||||
ExecName = $_
|
||||
ExecDir = $execDir
|
||||
}
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$env:PATH = "$execDir;$env:PATH"
|
||||
}
|
||||
|
||||
It "<ExecName> is installed in <ExecDir>" -TestCases $executables {
|
||||
(Get-Command "$ExecName").Source | Should -BeLike "$ExecDir*"
|
||||
}
|
||||
|
||||
It "<ExecName> is available" -TestCases $executables {
|
||||
"$ExecName" | Should -ReturnZeroExitCodeWithParam
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
$env:PATH = $originalPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
images/windows/scripts/tests/Miniconda.Tests.ps1
Normal file
14
images/windows/scripts/tests/Miniconda.Tests.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
Describe "Miniconda" {
|
||||
It "Miniconda Environment variables is set. " {
|
||||
${env:CONDA} | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Miniconda $env:CONDA\<PathTest> " -TestCases @(
|
||||
@{ PathTest = "python.exe" }
|
||||
@{ PathTest = "Scripts\conda.exe" }
|
||||
) {
|
||||
$condaPath = Join-Path ${env:CONDA} $PathTest
|
||||
$condaPath | Should -Exist
|
||||
"$condaPath --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
25
images/windows/scripts/tests/Nginx.Tests.ps1
Normal file
25
images/windows/scripts/tests/Nginx.Tests.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
Describe "Nginx" {
|
||||
Context "Path" {
|
||||
It "Nginx" {
|
||||
$nginxPath = Join-Path (Join-Path "C:\tools\" (Get-Item C:\tools\nginx*).Name) "nginx"
|
||||
"$nginxPath -v" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Context "Service" {
|
||||
$nginxService = Get-Service -Name nginx
|
||||
$nginxServiceTests = @{
|
||||
Name = $nginxService.Name
|
||||
Status = $nginxService.Status
|
||||
StartType = $nginxService.StartType
|
||||
}
|
||||
|
||||
It "<Name> service is stopped" -TestCases $nginxServiceTests {
|
||||
$Status | Should -Be "Stopped"
|
||||
}
|
||||
|
||||
It "<Name> service is disabled" -TestCases $nginxServiceTests {
|
||||
$StartType | Should -Be "Disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
25
images/windows/scripts/tests/Node.Tests.ps1
Normal file
25
images/windows/scripts/tests/Node.Tests.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
Describe "Node.JS" {
|
||||
Context "Basic modules"{
|
||||
It "<ToolName> " -TestCases @(
|
||||
@{ ToolName = "node" }
|
||||
@{ ToolName = "npm" }
|
||||
) {
|
||||
"$ToolName --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
$globalNpmPackages = (Get-ToolsetContent).npm.global_packages
|
||||
$globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } }
|
||||
|
||||
Context "Global NPM Packages" {
|
||||
It "<Name>" -TestCases $globalNpmPackagesWithTests {
|
||||
$Test | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Context "Node.js version" {
|
||||
It "Node.js version should correspond to the version in the toolset" {
|
||||
node --version | Should -BeLike "v$((Get-ToolsetContent).node.default)*"
|
||||
}
|
||||
}
|
||||
}
|
||||
16
images/windows/scripts/tests/PHP.Tests.ps1
Normal file
16
images/windows/scripts/tests/PHP.Tests.ps1
Normal file
@@ -0,0 +1,16 @@
|
||||
Describe "PHP" {
|
||||
It "Check PHP version" {
|
||||
$phpMajorMinor = (Get-ToolsetContent).php.version
|
||||
$phpInstalledVersion = php --version | Select-String -Pattern "PHP $phpMajorMinor"
|
||||
$phpInstalledVersion | Should -BeLike "*${phpMajorMinor}*"
|
||||
}
|
||||
|
||||
It "Check Composer in the PATH" {
|
||||
"composer --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "PHP Environment variables is set." {
|
||||
${env:PHPROOT} | Should -Not -BeNullOrEmpty
|
||||
${env:PHPROOT} | Should -Exist
|
||||
}
|
||||
}
|
||||
7
images/windows/scripts/tests/PipxPackages.Tests.ps1
Normal file
7
images/windows/scripts/tests/PipxPackages.Tests.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
Describe "PipxPackages" {
|
||||
$pipxToolset = (Get-ToolsetContent).pipx
|
||||
$testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} }
|
||||
It "<package>" -TestCases $testCases {
|
||||
"$cmd" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
40
images/windows/scripts/tests/PowerShellAzModules.Tests.ps1
Normal file
40
images/windows/scripts/tests/PowerShellAzModules.Tests.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
Describe "AzureModules" {
|
||||
|
||||
$modules = (Get-ToolsetContent).azureModules
|
||||
$modulesRootPath = "C:\\Modules"
|
||||
|
||||
foreach ($module in $modules) {
|
||||
$moduleName = $module.name
|
||||
|
||||
Context "$moduleName" {
|
||||
|
||||
foreach ($version in $module.versions) {
|
||||
$modulePath = Join-Path -Path $modulesRootPath -ChildPath "${moduleName}_${version}"
|
||||
$moduleInfo = @{ moduleName = $moduleName; modulePath = $modulePath; expectedVersion = $version }
|
||||
It "<expectedVersion> exists in modules directory" -TestCases $moduleInfo {
|
||||
$ScriptBlock = {
|
||||
param ($modulePath, $moduleName)
|
||||
Import-Module ImageHelpers
|
||||
Get-ModuleVersionAsJob -modulePath $modulePath -moduleName $moduleName
|
||||
}
|
||||
if ($moduleName -eq "Az"){
|
||||
Start-Process -FilePath pwsh.exe -ArgumentList "-Command (Invoke-Command -ScriptBlock {$ScriptBlock} -ArgumentList $modulePath, $moduleName)" -Wait -PassThru
|
||||
} else {
|
||||
Start-Process -FilePath powershell.exe -ArgumentList "-Command (Invoke-Command -ScriptBlock {$ScriptBlock} -ArgumentList $modulePath, $moduleName)" -Wait -PassThru
|
||||
}
|
||||
$moduleVersion = Get-Content -Path "$env:TEMP\module-version.txt"
|
||||
Remove-Item -Path "${env:TEMP}\module-version.txt" -Force
|
||||
$moduleVersion | Should -Match $expectedVersion
|
||||
}
|
||||
}
|
||||
|
||||
if ($module.default) {
|
||||
$moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default }
|
||||
It "<moduleDefault> set as default" -TestCases $moduleInfo {
|
||||
$moduleVersions = Get-Module -ListAvailable -Name $moduleName | ForEach-Object { $_.Version.ToString() }
|
||||
$moduleVersions | Should -Contain $moduleDefault
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
images/windows/scripts/tests/PowerShellModules.Tests.ps1
Normal file
23
images/windows/scripts/tests/PowerShellModules.Tests.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
Describe "PowerShellModules" {
|
||||
$modules = (Get-ToolsetContent).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 {
|
||||
Get-Module -Name $moduleName -ListAvailable | Should -BeTrue
|
||||
}
|
||||
|
||||
if ($withVersionsModules) {
|
||||
It "<moduleName> with <expectedVersion> is installed" -TestCases $withVersionsModules {
|
||||
(Get-Module -Name $moduleName -ListAvailable).Version -contains $expectedVersion | Should -BeTrue
|
||||
}
|
||||
}
|
||||
}
|
||||
1
images/windows/scripts/tests/RunAll-Tests.ps1
Normal file
1
images/windows/scripts/tests/RunAll-Tests.ps1
Normal file
@@ -0,0 +1 @@
|
||||
Invoke-PesterTests "*"
|
||||
7
images/windows/scripts/tests/RunnerCache.tests.ps1
Normal file
7
images/windows/scripts/tests/RunnerCache.tests.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
Describe "RunnerCache" {
|
||||
Context "runner cache directory not empty" {
|
||||
It "C:\ProgramData\runner" {
|
||||
(Get-ChildItem -Path "C:\ProgramData\runner\*.zip" -Recurse).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
}
|
||||
35
images/windows/scripts/tests/Rust.Tests.ps1
Normal file
35
images/windows/scripts/tests/Rust.Tests.ps1
Normal file
@@ -0,0 +1,35 @@
|
||||
Describe "Rust" {
|
||||
BeforeAll {
|
||||
$env:RUSTUP_HOME = "C:\Users\Default\.rustup"
|
||||
$env:CARGO_HOME = "C:\Users\Default\.cargo"
|
||||
$env:Path += ";$env:CARGO_HOME\bin"
|
||||
}
|
||||
|
||||
$rustTools = @(
|
||||
@{ToolName = "rustup"; binPath = "C:\Users\Default\.cargo\bin\rustup.exe"}
|
||||
@{ToolName = "rustc"; binPath = "C:\Users\Default\.cargo\bin\rustc.exe"}
|
||||
@{ToolName = "bindgen.exe"; binPath = "C:\Users\Default\.cargo\bin\bindgen.exe"}
|
||||
@{ToolName = "cbindgen.exe"; binPath = "C:\Users\Default\.cargo\bin\cbindgen.exe"}
|
||||
@{ToolName = "cargo"; binPath = "C:\Users\Default\.cargo\bin\cargo.exe"}
|
||||
@{ToolName = "cargo audit"; binPath = "C:\Users\Default\.cargo\bin\cargo-audit.exe"}
|
||||
@{ToolName = "cargo outdated"; binPath = "C:\Users\Default\.cargo\bin\cargo-outdated.exe"}
|
||||
)
|
||||
|
||||
$rustEnvNotExists = @(
|
||||
@{envVar = "RUSTUP_HOME"}
|
||||
@{envVar = "CARGO_HOME"}
|
||||
)
|
||||
|
||||
It "C:\Users\Default\.rustup and C:\Users\Default\.cargo folders exist" {
|
||||
"C:\Users\Default\.rustup", "C:\Users\Default\.cargo" | Should -Exist
|
||||
}
|
||||
|
||||
It "<envVar> environment variable does not exist" -TestCases $rustEnvNotExists {
|
||||
[Environment]::GetEnvironmentVariables("Machine").ContainsKey($envVar) | Should -BeFalse
|
||||
}
|
||||
|
||||
It "<ToolName> is installed to the '<binPath>' folder" -TestCases $rustTools {
|
||||
"$ToolName --version" | Should -ReturnZeroExitCode
|
||||
$binPath | Should -Exist
|
||||
}
|
||||
}
|
||||
21
images/windows/scripts/tests/SSDTExtensions.Tests.ps1
Normal file
21
images/windows/scripts/tests/SSDTExtensions.Tests.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
Describe "SSDTExtensions" {
|
||||
#These extensions don't have any proper name in the state.packages.json file, only id is available, which can be found on extension marketplace download page
|
||||
|
||||
if (Test-isWin19) {
|
||||
$testExtenions = @(
|
||||
@{id = "04a86fc2-dbd5-4222-848e-911638e487fe"}
|
||||
@{id = "851E7A09-7B2B-4F06-A15D-BABFCB26B970"}
|
||||
@{id = "717ad572-c4b7-435c-c166-c2969777f718"}
|
||||
)
|
||||
|
||||
It "Extensions id=<id>" -TestCases $testExtenions {
|
||||
$version = Get-VSExtensionVersion -packageName "${id}"
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
} else {
|
||||
It "Extension SSDT" {
|
||||
$version = Get-VSExtensionVersion -packageName "SSDT"
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
11
images/windows/scripts/tests/Shell.Tests.ps1
Normal file
11
images/windows/scripts/tests/Shell.Tests.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
Describe "Shell" {
|
||||
$shellTestCases = @(
|
||||
@{Name = "C:\shells\gitbash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"},
|
||||
@{Name = "C:\shells\msys2bash.cmd"; Target = $null}
|
||||
@{Name = "C:\shells\wslbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"}
|
||||
)
|
||||
|
||||
It "<Name> target to <Target>" -TestCases $shellTestCases {
|
||||
(Get-Item $Name).Target | Should -BeExactly $Target
|
||||
}
|
||||
}
|
||||
224
images/windows/scripts/tests/Tools.Tests.ps1
Normal file
224
images/windows/scripts/tests/Tools.Tests.ps1
Normal file
@@ -0,0 +1,224 @@
|
||||
Describe "Azure Cosmos DB Emulator" {
|
||||
$cosmosDbEmulatorRegKey = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -eq 'Azure Cosmos DB Emulator' }
|
||||
$installDir = $cosmosDbEmulatorRegKey.InstallLocation
|
||||
|
||||
It "Azure Cosmos DB Emulator install location registry key exists" -TestCases @{installDir = $installDir} {
|
||||
$installDir | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Azure Cosmos DB Emulator exe file exists" -TestCases @{installDir = $installDir} {
|
||||
$exeFilePath = Join-Path $installDir 'CosmosDB.Emulator.exe'
|
||||
$exeFilePath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Bazel" {
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "bazel" }
|
||||
@{ ToolName = "bazelisk" }
|
||||
) {
|
||||
"$ToolName --version"| Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "CodeQL Bundle" {
|
||||
It "Single distribution installed" {
|
||||
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
|
||||
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Should -HaveCount 1
|
||||
}
|
||||
|
||||
It "Contains CodeQL executable" {
|
||||
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
|
||||
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Sort-Object -Descending | Select-Object -First 1 -Expand FullName
|
||||
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql.exe"
|
||||
"$CodeQLPath version --quiet" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Contains CodeQL packs" {
|
||||
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
|
||||
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Sort-Object -Descending | Select-Object -First 1 -Expand FullName
|
||||
$CodeQLPacksPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "qlpacks"
|
||||
$CodeQLPacksPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "R" {
|
||||
It "Rscript" {
|
||||
"Rscript --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "DACFx" {
|
||||
It "DACFx" {
|
||||
(Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -Contains "Microsoft SQL Server Data-Tier Application Framework" | Should -BeTrue
|
||||
$sqlPackagePath = 'C:\Program Files\Microsoft SQL Server\160\DAC\bin\SqlPackage.exe'
|
||||
"${sqlPackagePath}" | Should -Exist
|
||||
}
|
||||
|
||||
It "SqlLocalDB" -Skip:(Test-IsWin22) {
|
||||
$sqlLocalDBPath = 'C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe'
|
||||
"${sqlLocalDBPath}" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "DotnetTLS" -Skip:(Test-IsWin22) {
|
||||
It "Tls 1.2 is enabled" {
|
||||
[Net.ServicePointManager]::SecurityProtocol -band "Tls12" | Should -Be Tls12
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Mercurial" {
|
||||
It "Mercurial" {
|
||||
"hg --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "KubernetesTools" {
|
||||
It "Kind" {
|
||||
"kind version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "kubectl" {
|
||||
"kubectl version --client=true" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Helm" {
|
||||
"helm version --short" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "minikube" {
|
||||
"minikube version --short" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Mingw64" {
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "gcc" }
|
||||
@{ ToolName = "g++" }
|
||||
@{ ToolName = "make" }
|
||||
) {
|
||||
"$ToolName --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "GoogleCloudCLI" -Skip:(Test-IsWin22) {
|
||||
It "<ToolName>" -TestCases @(
|
||||
@{ ToolName = "bq" }
|
||||
@{ ToolName = "gcloud" }
|
||||
@{ ToolName = "gsutil" }
|
||||
) {
|
||||
"$ToolName version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "NET48" {
|
||||
It "NET48" {
|
||||
Get-ChildItem -Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX 4.8 Tools" -Directory | Should -HaveCount 1
|
||||
}
|
||||
}
|
||||
|
||||
Describe "NSIS" {
|
||||
It "NSIS" {
|
||||
"makensis /VERSION" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "PowerShell Core" {
|
||||
It "pwsh" {
|
||||
"pwsh --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "Execute 2+2 command" {
|
||||
pwsh -Command "2+2" | Should -BeExactly 4
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Sbt" {
|
||||
It "sbt" {
|
||||
"sbt --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "ServiceFabricSDK" {
|
||||
It "PowerShell Module" {
|
||||
Get-Module -Name ServiceFabric -ListAvailable | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "ServiceFabricSDK version" {
|
||||
Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Service Fabric\' -Name FabricVersion | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Stack" {
|
||||
It "Stack" {
|
||||
"stack --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Vcpkg" {
|
||||
It "vcpkg" {
|
||||
"vcpkg version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
|
||||
It "env variable VCPKG_INSTALLATION_ROOT is set" {
|
||||
$env:VCPKG_INSTALLATION_ROOT | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "VCPKG_INSTALLATION_ROOT directory" {
|
||||
$env:VCPKG_INSTALLATION_ROOT | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "VCRedist" -Skip:(Test-IsWin22) {
|
||||
It "vcredist_2010_x64" {
|
||||
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1D8E6291-B0D5-35EC-8441-6616F567A0F7}" | Should -Exist
|
||||
"C:\Windows\System32\msvcr100.dll" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "WebPlatformInstaller" {
|
||||
It "WebPlatformInstaller" {
|
||||
"WebPICMD" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Zstd" {
|
||||
It "zstd" {
|
||||
"zstd -V" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Pipx" {
|
||||
It "Pipx" {
|
||||
"pipx --version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Kotlin" {
|
||||
$kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlin-dce-js", "kotlinc-jvm")
|
||||
|
||||
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
|
||||
"$toolName -version" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Describe "SQL OLEDB Driver" {
|
||||
It "SQL OLEDB Driver" {
|
||||
"HKLM:\SOFTWARE\Microsoft\MSOLEDBSQL" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "OpenSSL" {
|
||||
It "OpenSSL Version" {
|
||||
$OpenSSLVersion = (Get-ToolsetContent).openssl.version
|
||||
openssl version | Should -BeLike "* ${OpenSSLVersion}*"
|
||||
}
|
||||
|
||||
It "OpenSSL Path" {
|
||||
(Get-Command openssl).Source -eq (Join-Path ${env:ProgramFiles} 'OpenSSL\bin\openssl.exe') | Should -Be $true
|
||||
}
|
||||
|
||||
It "OpenSSL Full package" {
|
||||
Join-Path ${env:ProgramFiles} 'OpenSSL\include' | Should -Exist
|
||||
}
|
||||
}
|
||||
89
images/windows/scripts/tests/Toolset.Tests.ps1
Normal file
89
images/windows/scripts/tests/Toolset.Tests.ps1
Normal file
@@ -0,0 +1,89 @@
|
||||
$toolsExecutables = @{
|
||||
Python = @(
|
||||
@{ Binary = "python.exe"; Arguments = "--version" },
|
||||
@{ Binary = "Scripts\pip.exe"; Arguments = "--version" }
|
||||
)
|
||||
PyPy = @(
|
||||
@{ Binary = "python.exe"; Arguments = "--version" },
|
||||
@{ Binary = "Scripts\pip.exe"; Arguments = "--version" }
|
||||
)
|
||||
Node = @(
|
||||
@{ Binary = "node.exe"; Arguments = "--version" },
|
||||
@{ Binary = "npm"; Arguments = "--version" }
|
||||
)
|
||||
Go = @(
|
||||
@{ Binary = "bin\go.exe"; Arguments = "version" }
|
||||
)
|
||||
Ruby = @(
|
||||
@{ Binary = "bin\ruby.exe"; Arguments = "--version" }
|
||||
)
|
||||
}
|
||||
|
||||
function Get-ToolExecutables {
|
||||
Param ([String] $Name)
|
||||
if ($toolsExecutables.ContainsKey($Name)) { $toolsExecutables[$Name] } else { @() }
|
||||
}
|
||||
|
||||
function Test-Binaries {
|
||||
Param (
|
||||
[String] $Name,
|
||||
[String] $Version,
|
||||
[String] $Arch,
|
||||
[Array] $ToolExecs
|
||||
)
|
||||
$testCases = $ToolExecs | ForEach-Object {
|
||||
@{ Name = $Name; Version = $Version; Arch = $Arch; Binary = $_.Binary; Arguments = $_.Arguments }
|
||||
}
|
||||
It "<Binary> <Arguments>" -TestCases $testCases {
|
||||
$binaryFullPath = Join-Path (Get-ToolsetToolFullPath -Name $Name -Version $Version -Arch $Arch) $Binary
|
||||
"$binaryFullPath $Arguments" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
function Test-DefaultVersion {
|
||||
Param (
|
||||
[String] $Name,
|
||||
[String] $ExpectedVersion,
|
||||
[Array] $ToolExecs
|
||||
)
|
||||
$binaryName = [IO.Path]::GetFileNameWithoutExtension($ToolExecs[0].Binary)
|
||||
$testCase = @{ Binary = $binaryName; Arguments = $ToolExecs[0].Arguments; ExpectedVersion = $ExpectedVersion }
|
||||
It "<ExpectedVersion> is default version" -TestCases $testCase {
|
||||
$commandResult = Get-CommandResult "$Binary $Arguments"
|
||||
$commandResult.ExitCode | Should -Be 0
|
||||
$commandResult.Output | Should -Match $ExpectedVersion
|
||||
}
|
||||
|
||||
It "default version is located in tool-cache" -TestCases $testCase {
|
||||
$binaryFullPath = Get-WhichTool $Binary
|
||||
$toolcacheDirectory = Get-ToolcacheToolDirectory -ToolName $Name
|
||||
$binaryFullPath | Should -Match ([Regex]::Escape($toolcacheDirectory))
|
||||
}
|
||||
}
|
||||
|
||||
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache
|
||||
foreach ($tool in $tools) {
|
||||
Describe "$($tool.name) [$($tool.arch)]" {
|
||||
$toolExecs = Get-ToolExecutables -Name $tool.name
|
||||
|
||||
foreach ($version in $tool.versions) {
|
||||
Context "$version" {
|
||||
$toolInfo = @{ Name = $tool.name; Version = $version; Arch = $tool.arch }
|
||||
It "tool-cache directory exists" -TestCases $toolInfo {
|
||||
$toolFullPath = Get-ToolsetToolFullPath -Name $Name -Version $Version -Arch $Arch
|
||||
$toolFullPath | Should -Exist
|
||||
}
|
||||
|
||||
if ($toolExecs) {
|
||||
Test-Binaries -Name $tool.name -Version $version -Arch $tool.arch -ToolExecs $toolExecs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($tool.default -and $toolExecs) {
|
||||
Context "Default" {
|
||||
Test-DefaultVersion -Name $tool.name -ExpectedVersion $tool.default -ToolExecs $toolExecs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
images/windows/scripts/tests/VisualStudio.Tests.ps1
Normal file
37
images/windows/scripts/tests/VisualStudio.Tests.ps1
Normal file
@@ -0,0 +1,37 @@
|
||||
Describe "Visual Studio" {
|
||||
Context "Basic" {
|
||||
It "Catalog.json" {
|
||||
Get-VsCatalogJsonPath | Should -Exist
|
||||
}
|
||||
|
||||
It "Devenv.exe" {
|
||||
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
||||
$devenvexePath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Visual Studio components" {
|
||||
$expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads
|
||||
$testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} }
|
||||
BeforeAll {
|
||||
$installedComponents = Get-VisualStudioComponents | Select-Object -ExpandProperty Package
|
||||
}
|
||||
|
||||
It "<ComponentName>" -TestCases $testCases {
|
||||
$installedComponents | Should -Contain $ComponentName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Windows 10 SDK" {
|
||||
It "Verifies 17763 SDK is installed" -Skip:(Test-IsWin19) {
|
||||
"${env:ProgramFiles(x86)}\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.17763.0\UAP.props" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Windows 11 SDK" {
|
||||
It "Verifies 22621 SDK is installed" -Skip:(Test-IsWin22) {
|
||||
"${env:ProgramFiles(x86)}\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.22621.0\UAP.props" | Should -Exist
|
||||
}
|
||||
}
|
||||
20
images/windows/scripts/tests/Vsix.Tests.ps1
Normal file
20
images/windows/scripts/tests/Vsix.Tests.ps1
Normal file
@@ -0,0 +1,20 @@
|
||||
Describe "Vsix" {
|
||||
$toolset = Get-ToolsetContent
|
||||
$requiredVsixs = $toolset.visualStudio.vsix
|
||||
|
||||
$allPackages = (Get-VisualStudioInstance).Packages
|
||||
$testCases = $requiredVsixs | ForEach-Object {
|
||||
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
||||
@{
|
||||
VsixName = $vsix.ExtensionName
|
||||
VsixId = $vsix.VsixId
|
||||
AllPackages = $allPackages
|
||||
}
|
||||
}
|
||||
if ($testCases.Count -gt 0) {
|
||||
It "Extension <VsixName> is installed" -TestCases $testCases {
|
||||
$objVsix = $AllPackages | Where-Object { $_.id -eq $VsixId }
|
||||
$objVsix | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
13
images/windows/scripts/tests/WDK.Tests.ps1
Normal file
13
images/windows/scripts/tests/WDK.Tests.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
Describe "WDK" {
|
||||
It "WDK exists" {
|
||||
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
$installedApplications = Get-ItemProperty -Path $regKey
|
||||
$WDKVersion = $installedApplications | Where-Object DisplayName -eq 'Windows Driver Kit' | Select-Object -First 1 -ExpandProperty DisplayVersion
|
||||
$WDKVersion | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Windows Driver Kit VSIX extension" {
|
||||
$version = Get-VSExtensionVersion -packageName "Microsoft.Windows.DriverKit"
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
12
images/windows/scripts/tests/WinAppDriver.Tests.ps1
Normal file
12
images/windows/scripts/tests/WinAppDriver.Tests.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
Describe "WinAppDriver" {
|
||||
It "WinAppDriver directory exists" {
|
||||
Test-Path -Path "${env:ProgramFiles(x86)}\Windows Application Driver" | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Developer Mode" {
|
||||
It "Developer Mode is enabled" {
|
||||
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock";
|
||||
Get-ItemProperty -Path $path | Select-Object -ExpandProperty "AllowDevelopmentWithoutDevLicense" | Should -Be 1
|
||||
}
|
||||
}
|
||||
80
images/windows/scripts/tests/WindowsFeatures.Tests.ps1
Normal file
80
images/windows/scripts/tests/WindowsFeatures.Tests.ps1
Normal file
@@ -0,0 +1,80 @@
|
||||
Describe "WindowsFeatures" {
|
||||
$windowsFeatures = (Get-ToolsetContent).windowsFeatures
|
||||
$testCases = $windowsFeatures | ForEach-Object { @{ Name = $_.name; OptionalFeature = $_.optionalFeature } }
|
||||
|
||||
It "Windows Feature <Name> is installed" -TestCases $testCases {
|
||||
if ($OptionalFeature) {
|
||||
(Get-WindowsOptionalFeature -Online -FeatureName $Name).State | Should -Be "Enabled"
|
||||
} else {
|
||||
(Get-WindowsFeature -Name $Name).InstallState | Should -Be "Installed"
|
||||
}
|
||||
}
|
||||
|
||||
it "Check WSL is on path" {
|
||||
(Get-Command -Name 'wsl') | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
Describe "DiskSpace" {
|
||||
It "The image has enough disk space"{
|
||||
$availableSpaceMB = [math]::Round((Get-PSDrive -Name C).Free / 1MB)
|
||||
$minimumFreeSpaceMB = 18 * 1024
|
||||
|
||||
$availableSpaceMB | Should -BeGreaterThan $minimumFreeSpaceMB
|
||||
}
|
||||
}
|
||||
|
||||
Describe "DynamicPorts" {
|
||||
It "Test TCP dynamicport start=49152 num=16384" {
|
||||
$tcpPorts = Get-NetTCPSetting | Where-Object {$_.SettingName -ne "Automatic"} | Where-Object {
|
||||
$_.DynamicPortRangeStartPort -ne 49152 -or $_.DynamicPortRangeNumberOfPorts -ne 16384
|
||||
}
|
||||
|
||||
$tcpPorts | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Test UDP dynamicport start=49152 num=16384" {
|
||||
$udpPorts = Get-NetUDPSetting | Where-Object {
|
||||
$_.DynamicPortRangeStartPort -ne 49152 -or $_.DynamicPortRangeNumberOfPorts -ne 16384
|
||||
}
|
||||
|
||||
$udpPorts | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Describe "GDIProcessHandleQuota" {
|
||||
It "The GDIProcessHandleQuota value is 20000" {
|
||||
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows"
|
||||
$regPath32 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Windows"
|
||||
(Get-ItemProperty $regPath).GDIProcessHandleQuota | Should -BeExactly 20000
|
||||
(Get-ItemProperty $regPath32).GDIProcessHandleQuota | Should -BeExactly 20000
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Test Signed Drivers" {
|
||||
It "bcdedit testsigning should be Yes"{
|
||||
"$(bcdedit)" | Should -Match "testsigning\s+Yes"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Windows Updates" {
|
||||
It "WindowsUpdateDone.txt should exist" {
|
||||
"$env:windir\WindowsUpdateDone.txt" | Should -Exist
|
||||
}
|
||||
|
||||
$testCases = Get-WindowsUpdatesHistory | Sort-Object Title | ForEach-Object {
|
||||
@{
|
||||
Title = $_.Title
|
||||
Status = $_.Status
|
||||
}
|
||||
}
|
||||
|
||||
It "<Title>" -TestCases $testCases {
|
||||
$expect = "Successful"
|
||||
if ( $Title -match "Microsoft Defender Antivirus" ) {
|
||||
$expect = "Successful", "Failure", "InProgress"
|
||||
}
|
||||
|
||||
$Status | Should -BeIn $expect
|
||||
}
|
||||
}
|
||||
11
images/windows/scripts/tests/Wix.Tests.ps1
Normal file
11
images/windows/scripts/tests/Wix.Tests.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
Describe "Wix" {
|
||||
BeforeAll {
|
||||
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
$installedApplications = Get-ItemProperty -Path $regKey
|
||||
$version = ($installedApplications | Where-Object { $_.BundleCachePath -imatch ".*\\WiX\d*\.exe$" } | Select-Object -First 1).DisplayName
|
||||
}
|
||||
|
||||
It "Wix Toolset version from registry" {
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user