Merge pull request #1216 from al-cheb/al-cheb/pester-part-#2

Replace current validates with pester testing approach #2
This commit is contained in:
Maxim Lobanov
2020-07-14 10:36:53 +03:00
committed by GitHub
39 changed files with 356 additions and 543 deletions

View File

@@ -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
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
Invoke-PesterTests -TestFile "Browsers" -TestName "Chrome"

View File

@@ -20,4 +20,6 @@ Write-Host "Extracting cf cli..."
Extract-7Zip -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath
# Add cf to path
Add-MachinePathItem $CloudFoundryCliPath
Add-MachinePathItem $CloudFoundryCliPath
Invoke-PesterTests -TestFile "Tools" -TestName "CloudFoundryCli"

View File

@@ -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
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
Invoke-PesterTests -TestFile "Browsers" -TestName "Edge"

View File

@@ -49,4 +49,6 @@ Extract-7Zip -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath
Write-Host "Setting the environment variables..."
Add-MachinePathItem -PathItem $GeckoDriverPath
setx GeckoWebDriver "$GeckoDriverPath" /M
setx GeckoWebDriver "$GeckoDriverPath" /M
Invoke-PesterTests -TestFile "Browsers" -TestName "Firefox"

View File

@@ -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"

View File

@@ -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"
Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI"
Invoke-PesterTests -TestFile "Tools" -TestName "GitHub-CLI"

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName gitversion.portable
Invoke-PesterTests -TestFile "Git" -TestName "GitVersion"

View File

@@ -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"

View File

@@ -22,3 +22,5 @@ Add-MachinePathItem -PathItem $DefaultGhcPath
Write-Host "Installing cabal..."
Choco-Install -PackageName cabal
Invoke-PesterTests -TestFile "Haskell"

View File

@@ -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"

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName innosetup
Invoke-PesterTests -TestFile "Tools" -TestName "InnoSetup"

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName jq
Invoke-PesterTests -TestFile "Tools" -TestName "Jq"

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName julia -ArgumentList "--ia","/DIR=C:\Julia"
Invoke-PesterTests -TestFile "Tools" -TestName "Julia"

View File

@@ -5,3 +5,5 @@
Choco-Install -PackageName kubernetes-cli
Choco-Install -PackageName minikube
Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesCli"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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'

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}