diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 349591cd4..8096a7c0e 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -760,18 +760,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Perl.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Git.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-GitHub-CLI.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -784,12 +772,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Rust.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Julia.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -802,30 +784,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Svn.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Chrome.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Edge.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Firefox.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-SeleniumWebDrivers.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -868,24 +826,12 @@ "{{ template_dir }}/scripts/Installers/Validate-SQLPowerShellTools.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Mingw64.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-TypeScript.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Haskell.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -910,48 +856,18 @@ "{{ template_dir }}/scripts/Installers/Validate-Packer.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Mercurial.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Jq.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-InnoSetup.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-GitVersion.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-NSIS.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-CloudFoundryCli.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -964,18 +880,6 @@ "{{ template_dir }}/scripts/Installers/Validate-VSWhere.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-KubernetesCli.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-GoogleCloudSDK.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 94a9a9375..d45e2583d 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -759,18 +759,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Perl.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Git.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-GitHub-CLI.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -783,12 +771,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Rust.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Julia.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -801,30 +783,6 @@ "{{ template_dir }}/scripts/Installers/Validate-Sbt.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Chrome.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Edge.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Firefox.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-SeleniumWebDrivers.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -855,24 +813,12 @@ "{{ template_dir }}/scripts/Installers/Validate-SQLPowerShellTools.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Mingw64.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-TypeScript.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Haskell.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -897,48 +843,18 @@ "{{ template_dir }}/scripts/Installers/Validate-Packer.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Mercurial.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-Jq.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-InnoSetup.ps1" - ] - }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-GitVersion.ps1" - ] - }, { "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-NSIS.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-CloudFoundryCli.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -957,12 +873,6 @@ "{{ template_dir }}/scripts/Installers/Validate-VSWhere.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-KubernetesCli.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -975,12 +885,6 @@ "{{ template_dir }}/scripts/Installers/Validate-AliyunCli.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-GoogleCloudSDK.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 index 7a0229ac5..5228492b2 100644 --- a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/TestsHelpers.ps1 @@ -91,6 +91,39 @@ function ShouldReturnZeroExitCode { } } +# Pester Assert to match output of command +function ShouldMatchCommandOutput { + Param( + [String] $ActualValue, + [String] $RegularExpression, + [switch] $Negate + ) + + $output = (Get-CommandResult $ActualValue).Output | Out-String + [bool] $succeeded = $output -cmatch $RegularExpression + + if ($Negate) { + $succeeded = -not $succeeded + } + + $failureMessage = '' + + if (-not $succeeded) { + if ($Negate) { + $failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to not match '$output', but it did match." + } + else { + $failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to match '$output', but it did not match." + } + } + + return [PSCustomObject] @{ + Succeeded = $succeeded + FailureMessage = $failureMessage + } +} + If (Get-Command -Name Add-AssertionOperator -ErrorAction SilentlyContinue) { Add-AssertionOperator -Name ReturnZeroExitCode -InternalName ShouldReturnZeroExitCode -Test ${function:ShouldReturnZeroExitCode} + Add-AssertionOperator -Name MatchCommandOutput -InternalName ShouldMatchCommandOutput -Test ${function:ShouldMatchCommandOutput} } \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Chrome.ps1 b/images/win/scripts/Installers/Install-Chrome.ps1 index f0eecc4c2..5e1d6ae48 100644 --- a/images/win/scripts/Installers/Install-Chrome.ps1 +++ b/images/win/scripts/Installers/Install-Chrome.ps1 @@ -74,4 +74,6 @@ setx ChromeWebDriver "$ChromeDriverPath" /M $regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' $PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path' $PathValue += ";$ChromeDriverPath\" -Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue \ No newline at end of file +Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue + +Invoke-PesterTests -TestFile "Browsers" -TestName "Chrome" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 b/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 index 6f9ea886b..8d6b44d63 100644 --- a/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 +++ b/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 @@ -20,4 +20,6 @@ Write-Host "Extracting cf cli..." Extract-7Zip -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath # Add cf to path -Add-MachinePathItem $CloudFoundryCliPath \ No newline at end of file +Add-MachinePathItem $CloudFoundryCliPath + +Invoke-PesterTests -TestFile "Tools" -TestName "CloudFoundryCli" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Edge.ps1 b/images/win/scripts/Installers/Install-Edge.ps1 index 85b828fb6..ebb7871b7 100644 --- a/images/win/scripts/Installers/Install-Edge.ps1 +++ b/images/win/scripts/Installers/Install-Edge.ps1 @@ -37,4 +37,6 @@ setx EdgeWebDriver "$EdgeDriverPath" /M $regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' $PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path' $PathValue += ";$EdgeDriverPath\" -Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue \ No newline at end of file +Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue + +Invoke-PesterTests -TestFile "Browsers" -TestName "Edge" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/win/scripts/Installers/Install-Firefox.ps1 index 8817bf013..979a7b4b4 100644 --- a/images/win/scripts/Installers/Install-Firefox.ps1 +++ b/images/win/scripts/Installers/Install-Firefox.ps1 @@ -49,4 +49,6 @@ Extract-7Zip -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath Write-Host "Setting the environment variables..." Add-MachinePathItem -PathItem $GeckoDriverPath -setx GeckoWebDriver "$GeckoDriverPath" /M \ No newline at end of file +setx GeckoWebDriver "$GeckoDriverPath" /M + +Invoke-PesterTests -TestFile "Browsers" -TestName "Firefox" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/win/scripts/Installers/Install-Git.ps1 index 460a2a1ba..25ce857db 100644 --- a/images/win/scripts/Installers/Install-Git.ps1 +++ b/images/win/scripts/Installers/Install-Git.ps1 @@ -40,4 +40,5 @@ Choco-Install -PackageName hub Add-MachinePathItem "C:\Program Files\Git\bin" -exit 0 +Invoke-PesterTests -TestFile "Git" -TestName "Git" +Invoke-PesterTests -TestFile "Git" -TestName "Hub" diff --git a/images/win/scripts/Installers/Install-GitHub-CLI.ps1 b/images/win/scripts/Installers/Install-GitHub-CLI.ps1 index 5fb49887a..98cc51495 100644 --- a/images/win/scripts/Installers/Install-GitHub-CLI.ps1 +++ b/images/win/scripts/Installers/Install-GitHub-CLI.ps1 @@ -3,8 +3,8 @@ ## Desc: Install GitHub CLI ################################################################################ -Import-Module -Name ImageHelpers -Force - Choco-Install -PackageName gh -Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI" \ No newline at end of file +Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI" + +Invoke-PesterTests -TestFile "Tools" -TestName "GitHub-CLI" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-GitVersion.ps1 b/images/win/scripts/Installers/Install-GitVersion.ps1 index 1e27e49f9..d59dd67ed 100644 --- a/images/win/scripts/Installers/Install-GitVersion.ps1 +++ b/images/win/scripts/Installers/Install-GitVersion.ps1 @@ -4,3 +4,5 @@ ################################################################################ Choco-Install -PackageName gitversion.portable + +Invoke-PesterTests -TestFile "Git" -TestName "GitVersion" diff --git a/images/win/scripts/Installers/Install-GoogleCloudSDK.ps1 b/images/win/scripts/Installers/Install-GoogleCloudSDK.ps1 index eb75707f0..7123e3e44 100644 --- a/images/win/scripts/Installers/Install-GoogleCloudSDK.ps1 +++ b/images/win/scripts/Installers/Install-GoogleCloudSDK.ps1 @@ -7,3 +7,5 @@ $googleCloudSDKInstaller = "https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe" $argumentList = @("/S", "/allusers", "/noreporting") Install-Binary -Url $googleCloudSDKInstaller -Name "GoogleCloudSDKInstaller.exe" -ArgumentList $argumentList + +Invoke-PesterTests -TestFile "Tools" -TestName "GoogleCouldSDK" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Haskell.ps1 b/images/win/scripts/Installers/Install-Haskell.ps1 index 7f398a862..459b74a5e 100644 --- a/images/win/scripts/Installers/Install-Haskell.ps1 +++ b/images/win/scripts/Installers/Install-Haskell.ps1 @@ -22,3 +22,5 @@ Add-MachinePathItem -PathItem $DefaultGhcPath Write-Host "Installing cabal..." Choco-Install -PackageName cabal + +Invoke-PesterTests -TestFile "Haskell" diff --git a/images/win/scripts/Installers/Install-IEWebDriver.ps1 b/images/win/scripts/Installers/Install-IEWebDriver.ps1 index e62b8ab62..79e9cf3ae 100644 --- a/images/win/scripts/Installers/Install-IEWebDriver.ps1 +++ b/images/win/scripts/Installers/Install-IEWebDriver.ps1 @@ -36,3 +36,5 @@ Write-Host "Get the IEDriver version..." Write-Host "Setting the IEWebDriver environment variables" setx IEWebDriver $ieDriverPath /M + +Invoke-PesterTests -TestFile "Browsers" -TestName "Internet Explorer" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-InnoSetup.ps1 b/images/win/scripts/Installers/Install-InnoSetup.ps1 index 17f26962e..0bbbc9250 100644 --- a/images/win/scripts/Installers/Install-InnoSetup.ps1 +++ b/images/win/scripts/Installers/Install-InnoSetup.ps1 @@ -4,3 +4,5 @@ ################################################################################ Choco-Install -PackageName innosetup + +Invoke-PesterTests -TestFile "Tools" -TestName "InnoSetup" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Jq.ps1 b/images/win/scripts/Installers/Install-Jq.ps1 index 5a383d797..50a05a5fd 100644 --- a/images/win/scripts/Installers/Install-Jq.ps1 +++ b/images/win/scripts/Installers/Install-Jq.ps1 @@ -4,3 +4,5 @@ ################################################################################ Choco-Install -PackageName jq + +Invoke-PesterTests -TestFile "Tools" -TestName "Jq" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Julia.ps1 b/images/win/scripts/Installers/Install-Julia.ps1 index 6677b5d1d..c44321012 100644 --- a/images/win/scripts/Installers/Install-Julia.ps1 +++ b/images/win/scripts/Installers/Install-Julia.ps1 @@ -4,3 +4,5 @@ ################################################################################ Choco-Install -PackageName julia -ArgumentList "--ia","/DIR=C:\Julia" + +Invoke-PesterTests -TestFile "Tools" -TestName "Julia" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-KubernetesCli.ps1 b/images/win/scripts/Installers/Install-KubernetesCli.ps1 index e006f7793..cf4b8a8f4 100644 --- a/images/win/scripts/Installers/Install-KubernetesCli.ps1 +++ b/images/win/scripts/Installers/Install-KubernetesCli.ps1 @@ -5,3 +5,5 @@ Choco-Install -PackageName kubernetes-cli Choco-Install -PackageName minikube + +Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesCli" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Mercurial.ps1 b/images/win/scripts/Installers/Install-Mercurial.ps1 index da820d1b3..bcbab65cd 100644 --- a/images/win/scripts/Installers/Install-Mercurial.ps1 +++ b/images/win/scripts/Installers/Install-Mercurial.ps1 @@ -8,3 +8,5 @@ Choco-Install -PackageName hg -ArgumentList "--version", "5.0.0" $hgPath = "${env:ProgramFiles}\Mercurial\" Add-MachinePathItem $hgPath $env:Path = Get-MachinePath + +Invoke-PesterTests -TestFile "Tools" -TestName "Mercurial" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Mingw64.ps1 b/images/win/scripts/Installers/Install-Mingw64.ps1 index fcb8f781f..b6c860485 100644 --- a/images/win/scripts/Installers/Install-Mingw64.ps1 +++ b/images/win/scripts/Installers/Install-Mingw64.ps1 @@ -1,13 +1,13 @@ ################################################################################ ## File: Install-Mingw64.ps1 -## Desc: Install GNU tools for Windows to C:\tools\mingw64 +## Desc: Install GNU tools for Windows ################################################################################ -Import-Module -Name ImageHelpers -Force - Choco-Install -PackageName mingw # Make a copy of mingw32-make.exe to make.exe, which is a more discoverable name # and so the same command line can be used on Windows as on macOS and Linux $path = where.exe mingw32-make.exe | Get-Item Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe') + +Invoke-PesterTests -TestFile "Tools" -TestName "Mingw64" diff --git a/images/win/scripts/Installers/Validate-Chrome.ps1 b/images/win/scripts/Installers/Validate-Chrome.ps1 deleted file mode 100644 index 0f94190b1..000000000 --- a/images/win/scripts/Installers/Validate-Chrome.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-Chrome.ps1 -## Desc: Validate Google Chrome installation. -################################################################################ - -if (Test-Path 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe') -{ - (Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo -} -else -{ - Write-Host 'Google Chrome is not installed.' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-CloudFoundryCli.ps1 b/images/win/scripts/Installers/Validate-CloudFoundryCli.ps1 deleted file mode 100644 index 69928a46d..000000000 --- a/images/win/scripts/Installers/Validate-CloudFoundryCli.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -################################################################################ -## File: Validate-CloudFoundryCli.ps1 -## Desc: Validate Cloud Foundry CLI -################################################################################ - -if (Get-Command -Name 'cf') -{ - Write-Host 'cf on path' -} -else -{ - Write-Host 'cf is not on path' - exit 1 -} - diff --git a/images/win/scripts/Installers/Validate-Edge.ps1 b/images/win/scripts/Installers/Validate-Edge.ps1 deleted file mode 100644 index 2db17fb99..000000000 --- a/images/win/scripts/Installers/Validate-Edge.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -################################################################################ -## File: Validate-Edge.ps1 -## Desc: Validate Microsoft Edge installation. -################################################################################ - -$RegistryKey = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe" -if (Test-Path $RegistryKey) -{ - (Get-Item (Get-ItemProperty $RegistryKey).'(Default)').VersionInfo -} -else -{ - Write-Host "Microsoft Edge is not installed." - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-Firefox.ps1 b/images/win/scripts/Installers/Validate-Firefox.ps1 deleted file mode 100644 index 1fa1852fd..000000000 --- a/images/win/scripts/Installers/Validate-Firefox.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-Firefox.ps1 -## Desc: Validate Mozilla Firefox installation. -################################################################################ - -if (Test-Path 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe') -{ - (Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe').'(Default)').VersionInfo -} -else -{ - Write-Host 'Mozilla Firefox is not installed.' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-Git.ps1 b/images/win/scripts/Installers/Validate-Git.ps1 deleted file mode 100644 index c74239a5c..000000000 --- a/images/win/scripts/Installers/Validate-Git.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -################################################################################ -## File: Validate-Git.ps1 -## Desc: Validate Git for Windows -################################################################################ -function Test-CommandName { - param( - [parameter(Mandatory)][string] $CommandName - ) - Write-Host "Checking the [$CommandName]" - if(-not (Get-Command $CommandName -ErrorAction "Continue")) { - Write-Host "[!] $CommandName is not found" - exit 1 - } -} - -Test-CommandName -CommandName 'bash' -Test-CommandName -CommandName 'awk' -Test-CommandName -CommandName 'git' -Test-CommandName -CommandName 'git-lfs' -Test-CommandName -CommandName 'hub' diff --git a/images/win/scripts/Installers/Validate-GitHub-CLI.ps1 b/images/win/scripts/Installers/Validate-GitHub-CLI.ps1 deleted file mode 100644 index 391631398..000000000 --- a/images/win/scripts/Installers/Validate-GitHub-CLI.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-GitHub-CLI.ps1 -## Desc: Validate GitHub CLI -################################################################################ - -if (Get-Command -Name 'gh') -{ - Write-Host 'gh on path' -} -else -{ - Write-Host 'gh is not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-GitVersion.ps1 b/images/win/scripts/Installers/Validate-GitVersion.ps1 deleted file mode 100644 index b315cda5d..000000000 --- a/images/win/scripts/Installers/Validate-GitVersion.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-GitVersion.ps1 -## Desc: Validate GitVersion -################################################################################ - -if (Get-Command -Name 'gitversion') -{ - Write-Host 'gitversion on path' -} -else -{ - Write-Host 'gitversion is not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-GoogleCloudSDK.ps1 b/images/win/scripts/Installers/Validate-GoogleCloudSDK.ps1 deleted file mode 100644 index 6bc348f38..000000000 --- a/images/win/scripts/Installers/Validate-GoogleCloudSDK.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -################################################################################ -## File: Validate-GoogleCloudSDK.ps1 -## Desc: Validate Install Google Cloud SDK for Windows -################################################################################ - -# Simple validation gcloud, gsutil, and bq command line tools -$validateTools = @("bq", "gcloud", "gsutil") -foreach($tool in $validateTools) -{ - if (Get-Command -Name $tool) - { - Write-Host "$tool on path" - } - else - { - Write-Host "$tool is not on path" - exit 1 - } -} diff --git a/images/win/scripts/Installers/Validate-Haskell.ps1 b/images/win/scripts/Installers/Validate-Haskell.ps1 deleted file mode 100644 index f64c75362..000000000 --- a/images/win/scripts/Installers/Validate-Haskell.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -################################################################################ -## File: Validate-Haskell.ps1 -## Desc: Validate Haskell for Windows -################################################################################ - -# GHC validation -if (Get-Command -Name 'ghc') -{ - Write-Host "ghc is on the path" -} -else -{ - Write-Host "ghc is not on path." - exit 1 -} - -$ChocoPackagesPath = Join-Path $env:ChocolateyInstall "lib" -[Array] $GhcVersionList = Get-ChildItem -Path $ChocoPackagesPath -Filter "ghc.*" | ForEach-Object { $_.Name.TrimStart("ghc.") } - -# Validation that accurate 3 versions of GHC are installed -if ($GhcVersionList.Count -eq 3) -{ - Write-Host "Versions of GHC are accurate" -} -else -{ - Write-Host "Versions of GHC not accurate" - exit 1 -} - -# Validation each of GHC version -foreach ($version in $GhcVersionList) -{ - $BinGhcPath = Join-Path $env:ChocolateyInstall "lib\ghc.$version\tools\ghc-$version\bin\ghc.exe" - if ((& $BinGhcPath --version) -match $version) - { - Write-Host "ghc $version is valid" - } - else - { - Write-Host "ghc $version is not valid" - exit 1 - } -} - -# Cabal validation -if (Get-Command -Name 'cabal') -{ - Write-Host "cabal is on the path" -} -else -{ - Write-Host "cabal is not on path." - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-InnoSetup.ps1 b/images/win/scripts/Installers/Validate-InnoSetup.ps1 deleted file mode 100644 index 21c551196..000000000 --- a/images/win/scripts/Installers/Validate-InnoSetup.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -################################################################################ -## File: Validate-InnoSetup.ps1 -## Desc: Validate Inno Setup -################################################################################ - -if (Get-Command -Name 'iscc') -{ - Write-Host 'iscc is on PATH' -} -else -{ - Write-Host 'iscc is not on PATH' - exit 1 -} - diff --git a/images/win/scripts/Installers/Validate-Jq.ps1 b/images/win/scripts/Installers/Validate-Jq.ps1 deleted file mode 100644 index 67b4275fb..000000000 --- a/images/win/scripts/Installers/Validate-Jq.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -################################################################################ -## File: Validate-Jq.ps1 -## Desc: Validate jq -################################################################################ - -if (Get-Command -Name 'jq') -{ - Write-Host 'jq on path' -} -else -{ - Write-Host 'jq is not on path' - exit 1 -} - diff --git a/images/win/scripts/Installers/Validate-Julia.ps1 b/images/win/scripts/Installers/Validate-Julia.ps1 deleted file mode 100644 index 94d02cfc4..000000000 --- a/images/win/scripts/Installers/Validate-Julia.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -################################################################################ -## File: Validate-Julia.ps1 -## Desc: Validate Julia -################################################################################ - -# Verify that julia.exe is on the path -if ((Get-Command -Name 'julia') -and (Test-Path -Path 'C:\Julia')) -{ - Write-Host "$(julia --version) is on the path." -} -else -{ - Write-Host "Julia is not on the path." - exit 1 -} - diff --git a/images/win/scripts/Installers/Validate-KubernetesCli.ps1 b/images/win/scripts/Installers/Validate-KubernetesCli.ps1 deleted file mode 100644 index a51cbac66..000000000 --- a/images/win/scripts/Installers/Validate-KubernetesCli.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -################################################################################ -## File: Validate-KubernetesCli.ps1 -## Desc: Validate KubernetesCli. -################################################################################ - -if (Get-Command -Name 'kubectl') -{ - Write-Host "kubectl $(kubectl version --client=true --short=true) in path" -} -else -{ - Write-Host "kubectl is not in path" - exit 1 -} - -if (Get-Command -Name 'minikube') -{ - Write-Host "minikube $(minikube version --short) in path" -} -else -{ - Write-Host "minikube is not in path" - exit 1 -} - diff --git a/images/win/scripts/Installers/Validate-Mercurial.ps1 b/images/win/scripts/Installers/Validate-Mercurial.ps1 deleted file mode 100644 index d42189b82..000000000 --- a/images/win/scripts/Installers/Validate-Mercurial.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -################################################################################ -## File: Validate-Mercurial.ps1 -## Desc: Validate Mercurial -################################################################################ - -if (Get-Command -Name 'hg') -{ - Write-Host 'Mercurial on path' -} -else -{ - Write-Host 'Mercurial is not on path' - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-Mingw64.ps1 b/images/win/scripts/Installers/Validate-Mingw64.ps1 deleted file mode 100644 index eb097ae77..000000000 --- a/images/win/scripts/Installers/Validate-Mingw64.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -################################################################################ -## File: Validate-Mingw64.ps1 -## Desc: Validate Mingw64 -################################################################################ - -if (Get-Command -Name 'gcc') -{ - Write-Host "gcc is successfully installed:" - gcc --version | Write-Host -} -else -{ - Write-Host "gcc is not on PATH" - exit 1 -} - -if (Get-Command -Name 'g++') -{ - Write-Host "g++ is successfully installed:" - g++ --version | Write-Host -} -else -{ - Write-Host "g++ is not on PATH" - exit 1 -} - -if (Get-Command -Name 'make') -{ - Write-Host "make is successfully installed:" - make --version | Write-Host -} -else -{ - Write-Host "make is not on PATH" - exit 1 -} diff --git a/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 b/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 deleted file mode 100644 index 7dd9529f8..000000000 --- a/images/win/scripts/Installers/Validate-SeleniumWebDrivers.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -################################################################################ -## File: Validate-Chrome.ps1 -## Desc: Validate Google Chrome installation. -################################################################################ - -$IEDriverPath = $env:IEWebDriver -Write-Host "IEDriverPath: $IEDriverPath" -$GeckoDriverPath = $env:GeckoWebDriver -Write-Host "GeckoDriverPath: $GeckoDriverPath" -$ChromeDriverPath = $env:ChromeWebDriver -Write-Host "ChromeDriverPath: $ChromeDriverPath" -$EdgeDriverPath = $env:EdgeWebDriver -Write-Host "EdgeDriverPath: $EdgeDriverPath" - -if ( - ($IEDriverPath -like "C:\SeleniumWebDrivers\IEDriver") -and - ($GeckoDriverPath -like "C:\SeleniumWebDrivers\GeckoDriver") -and - ($ChromeDriverPath -like "C:\SeleniumWebDrivers\ChromeDriver") -and - ($EdgeDriverPath -like "C:\SeleniumWebDrivers\EdgeDriver") -) -{ - Write-Host "IEDriver installed at " - (Get-Item "$IEDriverPath\IEDriverServer.exe").VersionInfo - - Write-Host "Gecko Driver installed at " - (Get-Item "$GeckoDriverPath\geckodriver.exe").VersionInfo - - Write-Host "Chrome Driver installed at " - (Get-Item "$ChromeDriverPath\chromedriver.exe").VersionInfo - - Write-Host "Edge Driver installed at " - (Get-Item "$EdgeDriverPath\msedgedriver.exe").VersionInfo -} -else -{ - Write-Host "Selenium Web Drivers are not installed." - exit 1 -} diff --git a/images/win/scripts/Tests/Browsers.Tests.ps1 b/images/win/scripts/Tests/Browsers.Tests.ps1 new file mode 100644 index 000000000..5f687090b --- /dev/null +++ b/images/win/scripts/Tests/Browsers.Tests.ps1 @@ -0,0 +1,136 @@ +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" + + It "Chrome '' registry path exists" -TestCases @{chromeRegPath = $chromeRegPath} { + $chromeRegPath | Should -Exist + } + + It "Chrome VersionInfo registry value exists" -TestCases @{chromeRegPath = $chromeRegPath} { + $versionInfo = (Get-Item (Get-ItemProperty $chromeRegPath).'(Default)').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 "chrome.exe is installed" { + "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe" | Should -Exist + } + } +} + +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 '' 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 '' 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 + } + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Git.Tests.ps1 b/images/win/scripts/Tests/Git.Tests.ps1 new file mode 100644 index 000000000..97100e78f --- /dev/null +++ b/images/win/scripts/Tests/Git.Tests.ps1 @@ -0,0 +1,37 @@ +Describe "Git" { + $gitTools = 'bash', 'awk', 'git', 'git-lfs' + $gitTestCases = $gitTools | ForEach-Object { + @{ + toolName = $_ + source = [regex]::Escape("$env:ProgramFiles\Git") + } + } + + It " is installed" -TestCases $gitTestCases { + "$toolName --version" | Should -ReturnZeroExitCode + } + + It " is located in ''" -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 + } +} + +Describe "Hub" { + It "hub is installed" { + "hub --version" | Should -ReturnZeroExitCode + } +} + +Describe "GitVersion" { + It "gitversion is installed" { + "gitversion /version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Haskell.Tests.ps1 b/images/win/scripts/Tests/Haskell.Tests.ps1 new file mode 100644 index 000000000..b6ebb7630 --- /dev/null +++ b/images/win/scripts/Tests/Haskell.Tests.ps1 @@ -0,0 +1,30 @@ +Describe "Haskell" { + $chocoPackagesPath = Join-Path $env:ChocolateyInstall "lib" + [array]$ghcVersionList = Get-ChildItem -Path $chocoPackagesPath -Filter "ghc.*" | ForEach-Object { $_.Name.TrimStart("ghc.") } + $ghcCount = $ghcVersionList.Count + $defaultGhcVersion = $ghcVersionList | Sort-Object {[Version]$_} | Select-Object -Last 1 + + $ghcTestCases = $ghcVersionList | ForEach-Object { + $ghcVersion = $_ + @{ + ghcVersion = $ghcVersion + binGhcPath = Join-Path $chocoPackagesPath "ghc.$ghcVersion\tools\ghc-$ghcVersion\bin\ghc.exe" + } + } + + It "Accurate 3 versions of GHC are installed" -TestCases @{ghcCount = $ghcCount} { + $ghcCount | Should -BeExactly 3 + } + + It "GHC is installed" -TestCases $ghcTestCases { + "$binGhcPath --version" | Should -MatchCommandOutput $ghcVersion + } + + It "GHC is the default version and should be the latest installed" -TestCases @{defaultGhcVersion = $defaultGhcVersion} { + "ghc --version" | Should -MatchCommandOutput $defaultGhcVersion + } + + It "Cabal is installed" { + "cabal --version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/win/scripts/Tests/Tools.Tests.ps1 index 6ddbcb217..16be04e7d 100644 --- a/images/win/scripts/Tests/Tools.Tests.ps1 +++ b/images/win/scripts/Tests/Tools.Tests.ps1 @@ -14,4 +14,86 @@ Describe "Kind" { It "Kind" { "kind version" | Should -ReturnZeroExitCode } +} + +Describe "Jq" { + It "Jq" { + "jq -n ." | Should -ReturnZeroExitCode + } +} + +Describe "Julia" { + It "Julia path exists" { + "C:\Julia" | Should -Exist + } + + It "Julia" { + "julia --version" | Should -ReturnZeroExitCode + } +} + +Describe "Mercurial" { + It "Mercurial" { + "hg --version" | Should -ReturnZeroExitCode + } +} + +Describe "KubernetesCli" { + It "kubectl" { + "kubectl version --client=true --short=true" | Should -ReturnZeroExitCode + } + + It "minikube" { + "minikube version --short" | Should -ReturnZeroExitCode + } +} + +Describe "Mingw64" { + It "gcc" { + "gcc --version" | Should -ReturnZeroExitCode + } + + It "g++" { + "g++ --version" | Should -ReturnZeroExitCode + } + + It "make" { + "make --version" | Should -ReturnZeroExitCode + } +} + +Describe "InnoSetup" { + It "InnoSetup" { + (Get-Command -Name iscc).CommandType | Should -BeExactly "Application" + } +} + +Describe "GitHub-CLI" { + It "gh" { + "gh --version" | Should -ReturnZeroExitCode + } +} + +Describe "CloudFoundryCli" { + It "cf is located in C:\cf-cli" { + "C:\cf-cli\cf.exe" | Should -Exist + } + + It "cf" { + "cf --version" | Should -ReturnZeroExitCode + } +} + +Describe "GoogleCouldSDK" { + It "bq" { + "bq version" | Should -ReturnZeroExitCode + } + + It "gcloud" { + "gcloud version" | Should -ReturnZeroExitCode + } + + It "gsutil" { + "gsutil version" | Should -ReturnZeroExitCode + } } \ No newline at end of file