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 15:29:03 +07:00
committed by GitHub
parent 4b271d3303
commit b47ba413c9
31 changed files with 146 additions and 440 deletions

View File

@@ -269,12 +269,6 @@
"{{ template_dir }}/scripts/Installers/Validate-Wix.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-NET48.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -711,30 +705,6 @@
"{{ template_dir }}/scripts/Installers/Validate-AzCopy.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Msys2.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-OpenSSL.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Perl.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-PHP.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -753,12 +723,6 @@
"{{ template_dir }}/scripts/Installers/Validate-Svn.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-NodeLts.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -783,12 +747,6 @@
"{{ template_dir }}/scripts/Installers/Validate-DotnetSDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-MysqlCli.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -807,36 +765,18 @@
"{{ template_dir }}/scripts/Installers/Validate-Stack.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Miniconda.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Packer.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-NSIS.ps1"
]
},
{
"type": "powershell",
"scripts":[

View File

@@ -268,12 +268,6 @@
"{{ template_dir }}/scripts/Installers/Windows2019/Validate-SSDTExtensions.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-NET48.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -710,30 +704,6 @@
"{{ template_dir }}/scripts/Installers/Validate-AzCopy.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Msys2.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-OpenSSL.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Perl.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-PHP.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -752,12 +722,6 @@
"{{ template_dir }}/scripts/Installers/Validate-Sbt.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-NodeLts.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -770,12 +734,6 @@
"{{ template_dir }}/scripts/Installers/Validate-DotnetSDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-MysqlCli.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -794,36 +752,18 @@
"{{ template_dir }}/scripts/Installers/Validate-Stack.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Miniconda.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-AzureCosmosDbEmulator.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Packer.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-NSIS.ps1"
]
},
{
"type": "powershell",
"scripts":[

View File

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

View File

@@ -87,4 +87,4 @@ pacman.exe -Q | grep -v ^mingw-w64-
Write-Host "`nMSYS2 installation completed"
exit 0
Invoke-PesterTests -TestFile "MSYS2"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName openssl.light
Invoke-PesterTests -TestFile "Tools" -TestName "OpenSSL"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,4 +5,10 @@ Describe "MongoDB" {
) {
"$ToolName --version" | Should -ReturnZeroExitCode
}
}
}
Describe "MySQL" {
It "MySQL CLI" {
"mysql -V" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,22 @@
BeforeAll {
$msys2BinDir = "C:\msys64\usr\bin"
$msys2mingwDir = "C:\msys64\mingw64\bin"
}
Describe "MSYS2" {
It "<ToolName>" -TestCases @(
@{ ToolName = "bash.exe" }
@{ ToolName = "tar.exe" }
@{ ToolName = "make.exe" }
) {
Join-Path $msys2BinDir $ToolName | Should -Exist
}
It "<ToolName>" -TestCases @(
@{ ToolName = "gcc.exe" }
@{ ToolName = "cmake.exe" }
@{ ToolName = "g++.exe" }
) {
Join-Path $msys2mingwDir $ToolName | Should -Exist
}
}

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

View File

@@ -0,0 +1,21 @@
Describe "Node.JS" {
Context "Basic modules"{
It "<ToolName> " -TestCases @(
@{ ToolName = "node" }
@{ ToolName = "npm" }
) {
"$ToolName --version" | Should -ReturnZeroExitCode
}
}
Context "Global NPM Packages" {
It "<ToolName> " -TestCases @(
@{ ToolName = "gulp" }
@{ ToolName = "grunt" }
@{ ToolName = "yarn" }
@{ ToolName = "lerna" }
@{ ToolName = "newman" }
) {
"$ToolName --version" | Should -ReturnZeroExitCode
}
}
}

View File

@@ -0,0 +1,13 @@
Describe "PHP" {
It "Check <ToolName> in the PATH" -TestCases @(
@{ ToolName = "php" }
@{ ToolName = "composer" }
) {
"$ToolName --version" | Should -ReturnZeroExitCode
}
It "PHP Environment variables is set." {
${env:PHPROOT} | Should -Not -BeNullOrEmpty
${env:PHPROOT} | Should -Exist
}
}

View File

@@ -1,3 +1,5 @@
Import-Module (Join-Path $PSScriptRoot "..\SoftwareReport\SoftwareReport.Common.psm1") -DisableNameChecking
Describe "7-Zip" {
It "7z" {
"7z" | Should -ReturnZeroExitCode
@@ -55,16 +57,12 @@ Describe "KubernetesCli" {
}
Describe "Mingw64" {
It "gcc" {
"gcc --version" | Should -ReturnZeroExitCode
}
It "g++" {
"g++ --version" | Should -ReturnZeroExitCode
}
It "make" {
"make --version" | Should -ReturnZeroExitCode
It "<ToolName>" -TestCases @(
@{ ToolName = "gcc" }
@{ ToolName = "g++" }
@{ ToolName = "make" }
) {
"$ToolName --version" | Should -ReturnZeroExitCode
}
}
@@ -90,16 +88,49 @@ Describe "CloudFoundryCli" {
}
}
Describe "GoogleCouldSDK" {
It "bq" {
"bq version" | Should -ReturnZeroExitCode
Describe "GoogleCouldSDK" {
It "<ToolName>" -TestCases @(
@{ ToolName = "bq" }
@{ ToolName = "gcloud" }
@{ ToolName = "gsutil" }
) {
"$ToolName version" | Should -ReturnZeroExitCode
}
}
It "gcloud" {
"gcloud version" | Should -ReturnZeroExitCode
Describe "NET48" {
It "NET48" {
$netPath = (Get-DotnetFrameworkTools).Path.Split("<")[0]
${netPath} + "4.8 Tools" | Should -Exist
}
}
It "gsutil" {
"gsutil version" | Should -ReturnZeroExitCode
Describe "NSIS" {
It "NSIS" {
"makensis /VERSION" | Should -ReturnZeroExitCode
}
}
Describe "Nuget" {
It "Nuget" {
"nuget" | Should -ReturnZeroExitCode
}
}
Describe "OpenSSL" {
It "OpenSSL" {
"openssl version" | Should -ReturnZeroExitCode
}
}
Describe "Packer" {
It "Packer" {
"packer --version" | Should -ReturnZeroExitCode
}
}
Describe "Perl" {
It "Perl" {
"perl --version" | Should -ReturnZeroExitCode
}
}