Replace current validates with pester testing approach #3 (#1230)

* Pester Tests Approach implementation.

* changes for netPath
This commit is contained in:
Darii Nurgaleev
2020-07-17 11:29:03 +03:00
committed by GitHub
parent 4b271d3303
commit b47ba413c9
31 changed files with 146 additions and 440 deletions
@@ -16,3 +16,5 @@ $ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestinatio
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
Set-SystemVariable -SystemVariable "CONDA" -Value $CondaDestination
Invoke-PesterTests -TestFile "Miniconda"
@@ -87,4 +87,4 @@ pacman.exe -Q | grep -v ^mingw-w64-
Write-Host "`nMSYS2 installation completed"
exit 0
Invoke-PesterTests -TestFile "MSYS2"
@@ -25,4 +25,6 @@ $mysqlArchPath = Start-DownloadWithRetry -Url $MysqlVersionUrl -Name "mysql.zip"
Extract-7Zip -Path $mysqlArchPath -DestinationPath "C:\"
# Adding mysql in system environment path
Add-MachinePathItem $mysqlPath
Add-MachinePathItem $mysqlPath
Invoke-PesterTests -TestFile "Databases" -TestName "MySQL"
@@ -1,13 +0,0 @@
################################################################################
## File: Install-NET472.ps1
## Desc: Install .NET 4.7.2
################################################################################
Import-Module -Name ImageHelpers -Force
# .NET 4.7.2 Dev pack
$InstallerName = "NDP472-DevPack-ENU.exe"
$InstallerUrl = "https://download.microsoft.com/download/3/B/F/3BFB9C35-405D-45DF-BDAF-0EB57D047888/${InstallerName}"
$ArgumentList = ('Setup', '/passive', '/norestart' )
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
@@ -11,3 +11,5 @@ $InstallerUrl = "https://download.visualstudio.microsoft.com/download/pr/014120d
$ArgumentList = ("Setup", "/passive", "/norestart")
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
Invoke-PesterTests -TestFile "Tools" -TestName "NET48"
@@ -8,3 +8,5 @@ Choco-Install -PackageName nsis
$NsisPath = "${env:ProgramFiles(x86)}\NSIS\"
Add-MachinePathItem $NsisPath
$env:Path = Get-MachinePath
Invoke-PesterTests -TestFile "Tools" -TestName "NSIS"
@@ -34,3 +34,5 @@ npm install -g yarn
npm install -g lerna
npm install -g node-sass
npm install -g newman
Invoke-PesterTests -TestFile "Node"
@@ -5,12 +5,4 @@
Choco-Install -PackageName NuGet.CommandLine
if (Get-Command -Name 'nuget.exe')
{
Write-Host 'nuget on path'
}
else
{
Write-Host 'nuget is not on path'
exit 1
}
Invoke-PesterTests -TestFile "Tools" -TestName "Nuget"
@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName openssl.light
Invoke-PesterTests -TestFile "Tools" -TestName "OpenSSL"
@@ -19,5 +19,5 @@ Choco-Install -PackageName composer -ArgumentList "--ia", "/DEV=$installDir /PHP
# Set the PHPROOT environment variable.
setx PHPROOT $installDir /M
# Done
exit 0
# Invoke Pester Tests
Invoke-PesterTests -TestFile "PHP"
@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName packer
Invoke-PesterTests -TestFile "Tools" -TestName "Packer"
@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName strawberryperl
Invoke-PesterTests -TestFile "Tools" -TestName "Perl"
@@ -1,27 +0,0 @@
################################################################################
## File: Validate-Miniconda.ps1
## Desc: Validate Miniconda
################################################################################
if ($env:CONDA)
{
Write-Host "The CONDA environment variable is set"
Write-Host $env:CONDA
}
else
{
Write-Host "The CONDA environment variable is not set"
exit 1
}
if ((Test-Path "$env:CONDA\python.exe") -and (Test-Path "$env:CONDA\Scripts\conda.exe"))
{
Write-Host "Miniconda is successfully installed:"
& "$env:CONDA\Scripts\conda.exe" --version | Write-Host
}
else
{
Write-Host "Miniconda is not installed"
exit 1
}
@@ -1,43 +0,0 @@
################################################################################
## File: Validate-Msys2.ps1
## Desc: Validate Msys2
################################################################################
$msys2BinDir = "C:\msys64\usr\bin"
$msys2mingwDir = "C:\msys64\mingw64\bin"
$installedTools = @(
"bash",
"tar",
"make"
)
$installedMinGWTools = @(
"gcc",
"cmake"
)
Write-Host "Check installed tools in msys2/usr/bin directory"
$installedTools | ForEach-Object {
$toolName = $_
try {
Invoke-Expression "$msys2BinDir\$_ --version"
} catch {
Write-Host "$toolName was not installed in MSYS2 bin directory"
Write-Error $_
exit 1
}
}
Write-Host "Check installed tools in msys2/mingw/bin directory"
$installedMinGWTools | ForEach-Object {
$toolName = $_
try {
Invoke-Expression "$msys2mingwDir\$_ --version"
} catch {
Write-Error "$toolName was not installed in MSYS2 mingw bin directory"
Write-Error $_
exit 1
}
}
@@ -1,15 +0,0 @@
################################################################################
## File: Validate-MysqlCli.ps1
## Desc: Validate Mysql Cli
################################################################################
if (Get-Command -Name 'mysql')
{
Write-Host 'Mysql is on path'
}
else
{
Write-Host 'Mysql not on path'
exit 1
}
@@ -1,17 +0,0 @@
################################################################################
## File: Validate-NET472.ps1
## Desc: Validate .NET 4.7.2
################################################################################
# For reference, visit https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#ps_a
if (Get-ChildItem "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Release | ForEach-Object { $_ -ge 461814 })
{
$version = Get-ChildItem "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Version
Write-Host "Installed .Net version $version"
}
else
{
Write-Host ".Net 472 not found"
exit 1
}
@@ -1,16 +0,0 @@
################################################################################
## File: Validate-NET48.ps1
## Desc: Validate .NET 4.8
################################################################################
# For reference, visit https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#ps_a
if (Get-ChildItem "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Release | ForEach-Object { $_ -ge 528049 })
{
$version = Get-ChildItem "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Version
Write-Host "Installed .Net version $version"
}
else
{
Write-Host ".Net 48 not found"
exit 1
}
@@ -1,17 +0,0 @@
################################################################################
## File: Validate-NSIS.ps1
## Desc: Validate NSIS installation.
################################################################################
$SoftwareName = 'Nullsoft Install System (NSIS)'
if (Get-Command -Name 'makensis')
{
Write-Host "$SoftwareName is installed"
}
else
{
Write-Host "$SoftwareName is not installed"
exit 1
}
@@ -1,47 +0,0 @@
################################################################################
## File: Validate-NodeLts.ps1
## Desc: Validate nodejs-lts and other common node tools.
################################################################################
if ((Get-Command -Name 'node') -and (Get-Command -Name 'npm'))
{
Write-Host "Node $(node --version) on path"
Write-Host "Npm $(npm -version) on path"
}
else
{
Write-Host "Node or npm is not on path"
exit 1
}
if ((Get-Command -Name 'gulp') -and (Get-Command -Name 'grunt') -and (Get-Command -Name 'cordova') -and (Get-Command -Name 'yarn'))
{
Write-Host "Gulp $(gulp -version) on path"
Write-Host "Grunt $(grunt -version) on path"
Write-Host "Yarn $(yarn -version) on path"
}
else
{
Write-Host "One of Gulp, Grunt, Cordova, or Yarn is not on the path."
exit 1
}
if (Get-Command -Name 'lerna')
{
Write-Host "lerna $(lerna --version) on path"
}
else
{
Write-Host "lerna is not on path"
exit 1
}
if (Get-Command -Name 'newman')
{
Write-Host "Newman $(newman --version) is on the path."
}
else
{
Write-Host "Newman is not on the path."
exit 1
}
@@ -1,15 +0,0 @@
################################################################################
## File: Validate-OpenSSL.ps1
## Desc: Validate openssl
################################################################################
if (Get-Command -Name 'openssl')
{
Write-Host 'openssl on path'
}
else
{
Write-Host 'openssl is not on path'
exit 1
}
@@ -1,49 +0,0 @@
################################################################################
## File: Validate-PHP.ps1
## Desc: Validate PHP
################################################################################
# Function that gets the version of php at the specified path
function Get-PHPVersion
{
Param
(
[String]$phpRootPath
)
$env:Path = "$phpRootPath;" + $env:Path
if($($(php --version)| Out-String) -match 'PHP (?<version>.*) (.*cli).*')
{
$phpVersion = $Matches.version
Write-Host "PHP version at $phpRootPath is $phpVersion"
exit 0
}
Write-Host "Unable to determine PHP version at " + $phpRootPath
exit 1
}
# Verify that php.exe is on the path
if(Get-Command -Name 'php')
{
Write-Host "$(php --version) is on the path."
}
else
{
Write-Host "php is not on the path."
exit 1
}
# Verify that composer.exe is on the path
if(Get-Command -Name 'composer')
{
Write-Host "$(composer --version) is on the path."
}
else
{
Write-Host "composer is not on the path."
exit 1
}
# Get available versions of PHP
Get-PHPVersion -phpRootPath "C:\tools\php72"
@@ -1,15 +0,0 @@
################################################################################
## File: Validate-Packer.ps1
## Desc: Validate Packer
################################################################################
if (Get-Command -Name 'packer')
{
Write-Host 'Packer is on path'
}
else
{
Write-Host 'Packer is not on path'
exit 1
}
@@ -1,15 +0,0 @@
################################################################################
## File: Validate-Perl.ps1
## Desc: Validate perl
################################################################################
if (Get-Command -Name 'perl')
{
Write-Host 'perl on path'
}
else
{
Write-Host 'perl is not on path'
exit 1
}