Migrate validation to Pester (#1249)

* remove Validate-* scripts

* Remove references to validation scripts from .json files

* Separate "It"s by new lines

* Remove new line before the first  "It"

* Separate "It"s by new lines

* remove 32-bit WinAppDriver check

* remove explicit variable definition

Co-authored-by: Sergey Dolin <v-sedoli@micorosoft.com>
This commit is contained in:
Sergey Dolin
2020-07-30 12:12:49 +05:00
committed by GitHub
parent 9364062300
commit d3788c5fcf
30 changed files with 133 additions and 349 deletions

View File

@@ -266,24 +266,6 @@
"type": "windows-restart",
"restart_timeout": "30m"
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Windows2016/Validate-SSDT.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Wix.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-WDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -464,12 +446,6 @@
"{{ template_dir }}/scripts/Installers/Install-WinAppDriver.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-WinAppDriver.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -661,48 +637,6 @@
"type": "windows-restart",
"restart_timeout": "30m"
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Svn.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-SQLPowerShellTools.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-TypeScript.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Stack.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Vcpkg.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-VSWhere.ps1"
]
},
{
"type": "powershell",
"scripts":[

View File

@@ -259,24 +259,6 @@
"type": "windows-restart",
"restart_timeout": "10m"
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Wix.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Windows2019/Validate-SSDTExtensions.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-WDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -439,12 +421,6 @@
"{{ template_dir }}/scripts/Installers/Install-WinAppDriver.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-WinAppDriver.ps1"
]
},
{
"type": "powershell",
"scripts":[
@@ -660,48 +636,6 @@
"type": "windows-restart",
"restart_timeout": "10m"
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Svn.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-SQLPowerShellTools.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-TypeScript.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Stack.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Zstd.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-Vcpkg.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-VSWhere.ps1"
]
},
{
"type": "powershell",
"scripts":[

View File

@@ -19,4 +19,6 @@ Extract-7Zip -Path $StackArchivePath -DestinationPath $DestinationPath
New-Item -Name "x64.complete" -Path $StackToolcachePath
Add-MachinePathItem -PathItem $DestinationPath
Add-MachinePathItem -PathItem $DestinationPath
Invoke-PesterTests -TestFile "Tools" -TestName "Stack"

View File

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

View File

@@ -4,3 +4,5 @@
################################################################################
npm install -g typescript
Invoke-PesterTests -TestFile "Tools" -TestName "Typescript"

View File

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

View File

@@ -19,3 +19,5 @@ Invoke-Expression "$InstallDir\$VcpkgExecPath integrate install"
Add-MachinePathItem $InstallDir
$env:Path = Get-MachinePath
setx VCPKG_INSTALLATION_ROOT $InstallDir /M
Invoke-PesterTests -TestFile "Tools" -TestName "Vcpkg"

View File

@@ -32,3 +32,5 @@ Install-Binary -Url $wdkUrl -Name "wdksetup.exe" -ArgumentList $argumentList
# Need to install the VSIX to get the build targets when running VSBuild
Install-VsixExtension -FilePath $FilePath -Name "WDK.vsix" -VSversion $VSver -InstallOnly
Invoke-PesterTests -TestFile "WDK"

View File

@@ -10,3 +10,5 @@ $InstallerUrl = "https://github.com/Microsoft/WinAppDriver/releases/download/v1.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Binary -Url $InstallerUrl -Name $InstallerName
Invoke-PesterTests -TestFile "WinAppDriver"

View File

@@ -21,3 +21,5 @@ else
$extensionName = "Votive$VSver.vsix"
#Installing VS extension 'Wix Toolset Visual Studio Extension'
Install-VsixExtension -Url $extensionUrl -Name $extensionName -VSversion $VSver
Invoke-PesterTests -TestFile "Wix"

View File

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

View File

@@ -1,10 +0,0 @@
# Validate the installation
$env:PSModulePath = Get-SystemVariable "PSModulePath"
$modules = Get-Module -Name SQLPS -ListAvailable
Write-Host "The SQLPS Modules present are:"
$modules | Select-Object Name,Version,Path | Format-Table
# Validate the SQLserver PS module installation
$modules = Get-Module -Name SQLServer -ListAvailable
Write-Host "The SQLServer Modules present are:"
$modules | Select-Object Name,Version,Path | Format-Table

View File

@@ -1,15 +0,0 @@
################################################################################
## File: Validate-Stack.ps1
## Desc: Validate Stack for Windows
################################################################################
if (Get-Command -Name 'stack')
{
Write-Host 'stack is on the path'
}
else
{
Write-Host 'stack is not on path.'
exit 1
}

View File

@@ -1,14 +0,0 @@
################################################################################
## File: Validate-Svn.ps1
## Desc: Validate Subversion
################################################################################
if (Get-Command -Name 'svn')
{
Write-Host "Subversion $(svn --version --quiet) is on the path."
}
else
{
Write-Host "Subversion is not on the path."
exit 1
}

View File

@@ -1,14 +0,0 @@
################################################################################
## File: Validate-TypeScript.ps1
## Desc: Validate Typescript Installation
################################################################################
if (Get-Command -Name 'tsc')
{
Write-Host "TypeScript $(tsc --version) is on the path."
}
else
{
Write-Host "TypeScript is not on the path."
exit 1
}

View File

@@ -1,14 +0,0 @@
################################################################################
## File: Validate-VSWhere.ps1
## Desc: Validate vswhere
################################################################################
if (Get-Command -Name 'vswhere')
{
Write-Host "vswhere $(vswhere) on path"
}
else
{
Write-Host "vswhere is not on path"
exit 1
}

View File

@@ -1,27 +0,0 @@
################################################################################
## File: Validate-Vcpkg.ps1
## Desc: Validate vcpkg Cli
################################################################################
if (Get-Command -Name 'Vcpkg')
{
Write-Host 'Vcpkg is succesfully installed:'
vcpkg version | Write-Host
}
else
{
Write-Host 'Vcpkg is not on PATH'
exit 1
}
if ($env:VCPKG_INSTALLATION_ROOT)
{
Write-Host 'The VCPKG_INSTALLATION_ROOT environment variable is set'
Write-Host $env:VCPKG_INSTALLATION_ROOT
}
else
{
Write-Host 'The VCPKG_INSTALLATION_ROOT environment variable is not set'
exit 1
}

View File

@@ -1,19 +0,0 @@
################################################################################
## File: Validate-WDK.ps1
## Desc: Validate the installation of the Windows Driver Kit
################################################################################
function Get-WDKVersion
{
$WDKVersion = (Get-CimInstance -ClassName Win32_Product -Filter "Name = 'Windows Driver Kit'").Version
if (!$WDKVersion)
{
Write-Host "WDK was not found"
exit 1
}
}
Get-WDKVersion
$null = Get-VSExtensionVersion -packageName "Microsoft.Windows.DriverKit"

View File

@@ -1,37 +0,0 @@
################################################################################
## File: Validate-WinAppDriver.ps1
## Desc: Validate WinAppDriver installation
################################################################################
$wad = "Windows Application Driver"
if (${env:ProgramFiles(x86)})
{
$wadPath = "${env:ProgramFiles(x86)}\$wad"
}
else
{
$wadPath = "${env:ProgramFiles}\$wad"
}
if (Test-Path $wadPath -PathType Any)
{
Write-Host "WinAppDriver directory found."
}
else
{
Write-Host "Failed to locate WinAppDriver directory. Exiting."
exit 1
}
#Validate if Developer Mode is enabled
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock";
if ((Get-ItemProperty -Path $path | Select-Object -ExpandProperty "AllowDevelopmentWithoutDevLicense") -eq 1)
{
Write-Host "Developer Mode is successfully provisioned."
}
else
{
Write-Host "Developer Mode was not successfully provisioned."
exit 1
}

View File

@@ -1,33 +0,0 @@
################################################################################
## File: Validate-Wix.ps1
## Desc: Validate WIX.
################################################################################
Import-Module -Name ImageHelpers -Force
function Get-WixVersion {
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedApplications = Get-ItemProperty -Path $regKey
$Version = ($installedApplications | Where-Object { $_.DisplayName -and $_.DisplayName.toLower().Contains("wix") } | Select-Object -First 1).DisplayVersion
return $Version
}
$WixToolSetVersion = Get-WixVersion
if ($WixToolSetVersion) {
Write-Host "Wix Toolset version" $WixPackage.version "installed"
}
else {
Write-Host "Wix Toolset is not installed"
exit 1
}
if (Test-IsWin19)
{
$null = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev16"
}
else
{
$null = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev15"
}

View File

@@ -1,15 +0,0 @@
################################################################################
## File: Validate-zstd.ps1
## Desc: Validate zstd
################################################################################
if (Get-Command -Name 'zstd')
{
Write-Host 'zstd on path'
}
else
{
Write-Host 'zstd is not on path'
exit 1
}

View File

@@ -16,4 +16,6 @@ Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentLi
Write-Host "******** SSDT SETUP LOG START ********"
Write-Host $(Get-Content $logFilePath | Out-String)
Write-Host "******** SSDT SETUP LOG END ********"
Write-Host "******** SSDT SETUP LOG END ********"
Invoke-PesterTests -TestFile "SSDTExtensions"

View File

@@ -1,7 +0,0 @@
################################################################################
## File: Validate-SSDT.ps1
## Desc: Validate SQL Server Data Tools for Windows
################################################################################
$null = Get-VSExtensionVersion -packageName "SSDT"

View File

@@ -9,3 +9,4 @@ Install-VsixExtension -Url 'https://marketplace.visualstudio.com/_apis/public/ga
Install-VsixExtension -Url 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/SSIS/vsextensions/SqlServerIntegrationServicesProjects/3.4/vspackage' -Name 'Microsoft.DataTools.IntegrationServices.exe' -VSversion "2019"
Install-VsixExtension -Url 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ProBITools/vsextensions/MicrosoftReportProjectsforVisualStudio/2.6.3/vspackage' -Name 'Microsoft.DataTools.ReportingServices.vsix' -VSversion "2019"
Invoke-PesterTests -TestFile "SSDTExtensions"

View File

@@ -1,9 +0,0 @@
################################################################################
## File: Validate-SSDTExtensions.ps1
## Desc: Validate SQL Server Data Tools Visual Studio extensions
################################################################################
#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
$null = Get-VSExtensionVersion -packageName "04a86fc2-dbd5-4222-848e-911638e487fe"
$null = Get-VSExtensionVersion -packageName "851E7A09-7B2B-4F06-A15D-BABFCB26B970"
$null = Get-VSExtensionVersion -packageName "717ad572-c4b7-435c-c166-c2969777f718"

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

View File

@@ -245,4 +245,48 @@ Describe "ServiceFabricSDK" {
It "PowerShell Module" {
Get-Module -Name ServiceFabric -ListAvailable | Should -Not -BeNullOrEmpty
}
}
}
Describe "Svn" {
It "svn" {
"svn --version --quiet" | Should -ReturnZeroExitCode
}
}
Describe "Stack" {
It "Stack" {
"stack --version" | Should -ReturnZeroExitCode
}
}
Describe "Typescript" {
It "tsc" {
"tsc --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 "VSWhere" {
It "vswhere" {
"vswhere" | Should -ReturnZeroExitCode
}
}
Describe "Zstd" {
It "zstd" {
"zstd -V" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,11 @@
Describe "WDK" {
It "WDK exists" {
$WDKVersion = (Get-CimInstance -ClassName Win32_Product -Filter "Name = 'Windows Driver Kit'").Version
$WDKVersion| Should -Not -BeNullOrEmpty
}
It "WDK version from system" {
$version = Get-VSExtensionVersion -packageName "Microsoft.Windows.DriverKit"
$version | Should -Not -BeNullOrEmpty
}
}

View File

@@ -0,0 +1,10 @@
Describe "WinAppDriver" {
It "WinAppDriver directory exists" {
Test-Path -Path "${env:ProgramFiles(x86)}\Windows Application Driver" | Should -BeTrue
}
It "Developer Mode is enabled" {
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock";
Get-ItemProperty -Path $path | Select-Object -ExpandProperty "AllowDevelopmentWithoutDevLicense" | Should -Be 1
}
}

View File

@@ -0,0 +1,23 @@
Describe "Wix" {
BeforeAll {
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedApplications = Get-ItemProperty -Path $regKey
$version = ($installedApplications | Where-Object { $_.DisplayName -and $_.DisplayName.toLower().Contains("wix") } | Select-Object -First 1).DisplayVersion
}
It "Wix Toolset version from registry" {
$version | Should -Not -BeNullOrEmpty
}
It "Wix Toolset version from system" {
if (Test-IsWin19)
{
$exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev16"
}
else
{
$exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev15"
}
$exVersion | Should -Not -BeNullOrEmpty
}
}