From 68ed14d49a008e559f28f2493960e1e1e8b17531 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Mon, 3 Oct 2016 23:25:04 -0700 Subject: [PATCH 01/19] Add Version and Override parameters Add the ability to specify a specific version of an OVF module to execute as well as the ability to override script parameters defined in Pester tests. --- .../OperationValidation.psm1 | 197 +++++++++++++----- 1 file changed, 147 insertions(+), 50 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index b4e9222..2747b0e 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -39,13 +39,14 @@ function New-OperationValidationResult } function new-OperationValidationInfo { - param ( + param ( [Parameter(Mandatory=$true)][string]$File, [Parameter(Mandatory=$true)][string]$FilePath, [Parameter(Mandatory=$true)][string[]]$Name, [Parameter()][string[]]$TestCases, [Parameter(Mandatory=$true)][ValidateSet("None","Simple","Comprehensive")][string]$Type, - [Parameter()][string]$modulename + [Parameter()][string]$modulename, + [Parameter()][hashtable]$Parameters ) $o = [pscustomobject]@{ File = $File @@ -54,6 +55,7 @@ function new-OperationValidationInfo TestCases = $testCases Type = $type ModuleName = $modulename + ScriptParameters = $Parameters } $o.psobject.Typenames.Insert(0,"OperationValidationInfo") $ToString = { return ("{0} ({1}): {2}" -f $this.testFile, $this.Type, ($this.TestCases -join ",")) } @@ -70,13 +72,13 @@ function Get-TestFromScript write-verbose -Message $scriptPath for($i = 0; $i -lt $tok.count; $i++) { - if ( $tok[$i].type -eq "Command" -and $tok[$i].content -eq "Describe" ) + if ( $tok[$i].type -eq "Command" -and $tok[$i].content -eq "Describe" ) { $i++ if ( $tok[$i].Type -eq "String" ) { $tok[$i].Content } else { - # ok - we didn't get the describe text first, + # ok - we didn't get the describe text first, # we likely saw a "-Tags" statement, so that means that # the describe text will immediately preceed the scriptblock while($tok[$i].Type -ne "GroupStart") @@ -95,20 +97,20 @@ function Get-TestFromScript Retrieve the operational tests from modules .DESCRIPTION -Modules which include a Diagnostics directory are inspected for +Modules which include a Diagnostics directory are inspected for Pester tests in either the "Simple" or "Comprehensive" directories. If files are found in those directories, they will be inspected to determine -whether they are Pester tests. If Pester tests are found, the +whether they are Pester tests. If Pester tests are found, the test names in those files will be returned. The module structure required is as follows: ModuleBase\ Diagnostics\ - Simple # simple tests are held in this location + Simple # simple tests are held in this location (e.g., ping, serviceendpoint checks) Comprehensive # comprehensive scenario tests should be placed here - + .PARAMETER ModuleName By default this is * which will retrieve all modules in $env:psmodulepath Additional module directories may be added. If you wish to check both @@ -146,7 +148,8 @@ function Get-OperationValidation [CmdletBinding()] param ( [Parameter(Position=0)][string[]]$ModuleName = "*", - [Parameter()][ValidateSet("Simple","Comprehensive")][string[]]$TestType = @("Simple","Comprehensive") + [Parameter()][ValidateSet("Simple","Comprehensive")][string[]]$TestType = @("Simple","Comprehensive"), + [Parameter()][Version]$Version ) BEGIN @@ -197,9 +200,12 @@ param ( } } } - function Get-ModuleList + function Get-ModuleList { - param ( [string[]]$Name ) + param ( + [string[]]$Name, + [version]$Version + ) foreach($p in $env:psmodulepath.split(";")) { if ( test-path -path $p ) @@ -213,17 +219,42 @@ param ( # now determine if there's a diagnostics directory, or a version if ( test-path -path ($modDir.FullName + "\Diagnostics")) { - $modDir.FullName - break + # Did we specify a specific version to find? + if ($PSBoundParameters.ContainsKey('Version')) + { + $manifestFile = Get-ChildItem -Path $modDir.FullName -Filter "$modDir.psd1" | Select-Object -First 1 + $manifest = Test-ModuleManifest -Path $manifestFile.FullName + if ($manifest.Version -eq $Version) + { + $modDir.FullName + break + } + } + else + { + $modDir.FullName + break + } + } + + # Get latest version if no specific version specified + if ($PSBoundParameters.ContainsKey('Version')) + { + $versionDirectories = Get-Childitem -path $modDir.FullName -dir | + where-object { $_.name -as [version] -and $_.Name -eq $Version } } - $versionDirectories = Get-Childitem -path $modDir.FullName -dir | - where-object { $_.name -as [version] } + else + { + $versionDirectories = Get-Childitem -path $modDir.FullName -dir | + where-object { $_.name -as [version] } + } + $potentialDiagnostics = $versionDirectories | where-object { test-path ($_.fullname + "\Diagnostics") } # now select the most recent module path which has diagnostics - $DiagnosticDir = $potentialDiagnostics | - sort-object {$_.name -as [version]} | + $DiagnosticDir = $potentialDiagnostics | + sort-object {$_.name -as [version]} | Select-Object -Last 1 if ( $DiagnosticDir ) { @@ -240,28 +271,48 @@ param ( PROCESS { Write-Progress -Activity "Inspecting Modules" -Status " " - $moduleCollection = Get-ModuleList -Name $ModuleName - $count = 1; + if ($PSBoundParameters.ContainsKey('Version')) + { + $moduleCollection = Get-ModuleList -Name $ModuleName -Version $Version + } + else + { + $moduleCollection = Get-ModuleList -Name $ModuleName + } + + $count = 1; $moduleCount = @($moduleCollection).Count foreach($module in $moduleCollection) { Write-Progress -Activity ("Searching for Diagnostics in " + $module) -PercentComplete ($count++/$moduleCount*100) -status " " - $diagnosticsDir=$module + "\Diagnostics" + $diagnosticsDir=$module + "\Diagnostics" if ( test-path -path $diagnosticsDir ) { foreach($dir in $testType) { $testDir = "$diagnosticsDir\$dir" write-verbose -Message "SPECIFIC TEST: $testDir" - if ( ! (test-path -path $testDir) ) + if ( ! (test-path -path $testDir) ) { continue } foreach($file in get-childitem -path $testDir -filter *.tests.ps1) { Write-Verbose -Message $file.fullname - $testName = Get-TestFromScript -scriptPath $file.FullName - new-OperationValidationInfo -FilePath $file.Fullname -File $file.Name -Type $dir -Name $testName -ModuleName $Module + + # Pull out parameters to Pester script if they exist + $script = Get-Command -Name $file.fullname + $parameters = $script.Parameters + if ($parameters.Keys.Count -gt 0) + { + Write-Debug -Message 'Test script has overrideable parameters' + Write-Debug -Message "`n$($parameters.Keys | Out-String)" + } + + $testNames = @(Get-TestFromScript -scriptPath $file.FullName) + foreach ($testName in $testNames) { + New-OperationValidationInfo -FilePath $file.Fullname -File $file.Name -Type $dir -Name $testName -ModuleName $Module -Parameters $parameters + } } } } @@ -324,7 +375,12 @@ function Invoke-OperationValidation [Parameter(ParameterSetName="UseGetOperationTest")][string[]]$ModuleName = "*", [Parameter(ParameterSetName="UseGetOperationTest")] [ValidateSet("Simple","Comprehensive")][string[]]$TestType = @("Simple","Comprehensive"), - [Parameter()][switch]$IncludePesterOutput + [Parameter()][switch]$IncludePesterOutput, + [Parameter(ParameterSetName="UseGetOperationTest")] + [Parameter()][Version]$Version, + [Parameter(ParameterSetName="FileAndTest")] + [Parameter(ParameterSetName="UseGetOperationTest")] + [Parameter()][hashtable]$Overrides ) BEGIN { @@ -340,25 +396,22 @@ function Invoke-OperationValidation Throw "Cannot load Pester module" } } - # $resultCollection = @() } PROCESS { if ( $PSCmdlet.ParameterSetName -eq "UseGetOperationTest" ) { - $tests = Get-OperationValidation -ModuleName $ModuleName -TestType $TestType - $tests | Invoke-OperationValidation -IncludePesterOutput:$IncludePesterOutput - return - } - - if ( ($testFilePath -eq $null) -and ($TestInfo -eq $null) ) - { - Get-OperationValidation | Invoke-OperationValidation -IncludePesterOutput:$IncludePesterOutput - return + if ($PSBoundParameters.ContainsKey('Version')) + { + $TestInfo = Get-OperationValidation -ModuleName $ModuleName -TestType $TestType -Version $Version + } + else + { + $TestInfo = Get-OperationValidation -ModuleName $ModuleName -TestType $TestType + } } - - if ( $testInfo -ne $null ) + if ( $null -ne $testInfo ) { # first check to be sure all of the TestInfos are sane foreach($ti in $testinfo) @@ -368,29 +421,73 @@ function Invoke-OperationValidation throw "TestInfo must contain the path and the list of tests" } } - - write-verbose -Message ("EXECUTING: {0} {1}" -f $ti.FilePath,($ti.Name -join ",")) - foreach($tname in $ti.Name) + + # first check to be sure all of the TestInfos are sane + foreach($ti in $testinfo) { - $testResult = Invoke-pester -Path $ti.FilePath -TestName $tName -quiet:$quiet -PassThru - Add-member -InputObject $testResult -MemberType NoteProperty -Name Path -Value $ti.FilePath - Convert-TestResult $testResult + if ( ! ($ti.FilePath -and $ti.Name)) + { + throw "TestInfo must contain the path and the list of tests" + } + } + + Write-Verbose -Message ("EXECUTING: {0} {1}" -f $ti.FilePath,($ti.Name -join ",")) + foreach($ti in $testinfo) + { + $pesterParams = @{ + TestName = $ti.Name + Quiet = $quiet + PassThru = $true + Verbose = $false + } + + if ($ti.ScriptParameters) + { + Write-Verbose -Message 'Test has script parameters' + if ($PSBoundParameters.ContainsKey('Overrides')) + { + Write-Verbose -Message "Overriding with parameters:`n$($Overrides | Format-List -Property * | Out-String)" + $pesterParams.Script = @{ + Path = $ti.FilePath + Parameters = $Overrides + } + } + else + { + Write-Verbose -Message 'Using default parameters for test' + $pesterParams.Path = $ti.FilePath + } + } + else + { + $pesterParams.Path = $ti.FilePath + } + + if ( $PSCmdlet.ShouldProcess("$($ti.Name) [$($ti.FilePath)]")) + { + $testResult = Invoke-Pester @pesterParams + if ($testResult) + { + Add-member -InputObject $testResult -MemberType NoteProperty -Name Path -Value $ti.FilePath + Convert-TestResult $testResult + } + } } return } - foreach($test in $testFilePath) + if ($testFilePath) { - write-progress -Activity "Invoking tests in $test" - if ( $PSCmdlet.ShouldProcess($test)) - { - $testResult = Invoke-Pester $test -passthru -quiet:$quiet - Add-Member -InputObject $testResult -MemberType NoteProperty -Name Path -Value $test - Convert-TestResult $testResult + foreach($filePath in $testFilePath) { + write-progress -Activity "Invoking tests in $filePath" + if ( $PSCmdlet.ShouldProcess($filePath)) { + $testResult = Invoke-Pester $filePath -passthru -quiet:$quiet + Add-Member -InputObject $testResult -MemberType NoteProperty -Name Path -Value $filePath + Convert-TestResult $testResult + } } } } - } # emit an object which can be used in reporting From ffda8a729004b51a8e91fadf93227154d1f5af90 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Wed, 5 Oct 2016 21:22:58 -0700 Subject: [PATCH 02/19] Bump version and change to UTF-8 --- .../OperationValidation.psd1 | Bin 7846 -> 7846 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psd1 b/Modules/OperationValidation/OperationValidation.psd1 index be013e045a73ce7874672208e221d541433ae461..4190ffea4a05e570702ff2e377aa7753e8265b53 100644 GIT binary patch delta 18 acmZ2xyUcdO5++td20aFY%`2JyN&^5qxdtZy delta 18 acmZ2xyUcdO5++sy20aGD%`2JyN&^5qwFV~u From 8447666924655443af1d1b002df543e6327eb5c7 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Wed, 5 Oct 2016 21:27:25 -0700 Subject: [PATCH 03/19] Add version property to test info object --- .../OperationValidation.Format.ps1xml | 11 ++++++ .../OperationValidation.psm1 | 37 +++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.Format.ps1xml b/Modules/OperationValidation/OperationValidation.Format.ps1xml index 88d7b3a..3318978 100644 --- a/Modules/OperationValidation/OperationValidation.Format.ps1xml +++ b/Modules/OperationValidation/OperationValidation.Format.ps1xml @@ -46,6 +46,17 @@ + Version: + + 4 + + + Version + + + + + Type: 4 diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index 2747b0e..1db1b99 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -46,6 +46,7 @@ function new-OperationValidationInfo [Parameter()][string[]]$TestCases, [Parameter(Mandatory=$true)][ValidateSet("None","Simple","Comprehensive")][string]$Type, [Parameter()][string]$modulename, + [Parameter()][Version]$Version, [Parameter()][hashtable]$Parameters ) $o = [pscustomobject]@{ @@ -55,6 +56,7 @@ function new-OperationValidationInfo TestCases = $testCases Type = $type ModuleName = $modulename + Version = $Version ScriptParameters = $Parameters } $o.psobject.Typenames.Insert(0,"OperationValidationInfo") @@ -69,7 +71,6 @@ function Get-TestFromScript param ( [string]$scriptPath ) $errs = $null $tok =[System.Management.Automation.PSParser]::Tokenize((get-content -read 0 -Path $scriptPath), [ref]$Errs) - write-verbose -Message $scriptPath for($i = 0; $i -lt $tok.count; $i++) { if ( $tok[$i].type -eq "Command" -and $tok[$i].content -eq "Describe" ) @@ -285,20 +286,31 @@ param ( foreach($module in $moduleCollection) { Write-Progress -Activity ("Searching for Diagnostics in " + $module) -PercentComplete ($count++/$moduleCount*100) -status " " - $diagnosticsDir=$module + "\Diagnostics" + $diagnosticsDir = "$module\Diagnostics" + + # Get the module manifest so we can pull out the version + $moduleName = Split-Path -Path $module -Leaf + $manifestFile = Get-ChildItem -Path $module -Filter "$moduleName.psd1" + if (-not $manifestFile) { + # We may be in a "version" directory so get the actual module name from the parent directory + $parent = (Split-Path -Path $module -Parent).Name + $manifestFile = Get-ChildItem -Path $module -Filter "$parent.psd1" + } + $manifest = Test-ModuleManifest -Path $manifestFile.FullName -Verbose:$false + if ( test-path -path $diagnosticsDir ) { foreach($dir in $testType) { - $testDir = "$diagnosticsDir\$dir" - write-verbose -Message "SPECIFIC TEST: $testDir" + $testDir = Join-Path -Path $diagnosticsDir -ChildPath $dir + write-verbose -Message "TEST DIR: $testDir" if ( ! (test-path -path $testDir) ) { continue } foreach($file in get-childitem -path $testDir -filter *.tests.ps1) { - Write-Verbose -Message $file.fullname + Write-Verbose -Message "PESTER TEST: $($file.fullname)" # Pull out parameters to Pester script if they exist $script = Get-Command -Name $file.fullname @@ -311,7 +323,16 @@ param ( $testNames = @(Get-TestFromScript -scriptPath $file.FullName) foreach ($testName in $testNames) { - New-OperationValidationInfo -FilePath $file.Fullname -File $file.Name -Type $dir -Name $testName -ModuleName $Module -Parameters $parameters + $modInfoParams = @{ + FilePath = $file.Fullname + File = $file.Name + Type = $dir + Name = $testName + ModuleName = $Module + Version = [version]$manifest.Version + Parameters = $parameters + } + New-OperationValidationInfo @modInfoParams } } } @@ -431,7 +452,7 @@ function Invoke-OperationValidation } } - Write-Verbose -Message ("EXECUTING: {0} {1}" -f $ti.FilePath,($ti.Name -join ",")) + Write-Verbose -Message ("EXECUTING: {0} [{1}]" -f $ti.FilePath,($ti.Name -join ",")) foreach($ti in $testinfo) { $pesterParams = @{ @@ -446,7 +467,7 @@ function Invoke-OperationValidation Write-Verbose -Message 'Test has script parameters' if ($PSBoundParameters.ContainsKey('Overrides')) { - Write-Verbose -Message "Overriding with parameters:`n$($Overrides | Format-List -Property * | Out-String)" + Write-Verbose -Message "Overriding with parameters:`n$($Overrides | Format-Table -Property Key, Value | Out-String)" $pesterParams.Script = @{ Path = $ti.FilePath Parameters = $Overrides From f2f37b695712652192e0de74f84e70fcbdfc1f07 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Wed, 5 Oct 2016 21:31:55 -0700 Subject: [PATCH 04/19] Remove trailing whitespace --- Modules/OperationValidation/OperationValidation.psm1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index 1db1b99..cecb324 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -234,7 +234,7 @@ param ( else { $modDir.FullName - break + break } } @@ -280,7 +280,7 @@ param ( { $moduleCollection = Get-ModuleList -Name $ModuleName } - + $count = 1; $moduleCount = @($moduleCollection).Count foreach($module in $moduleCollection) @@ -311,7 +311,7 @@ param ( foreach($file in get-childitem -path $testDir -filter *.tests.ps1) { Write-Verbose -Message "PESTER TEST: $($file.fullname)" - + # Pull out parameters to Pester script if they exist $script = Get-Command -Name $file.fullname $parameters = $script.Parameters @@ -332,7 +332,7 @@ param ( Version = [version]$manifest.Version Parameters = $parameters } - New-OperationValidationInfo @modInfoParams + New-OperationValidationInfo @modInfoParams } } } From eca000bcf8d6e4e7ce58a58878343ed50be65255 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Wed, 5 Oct 2016 21:45:24 -0700 Subject: [PATCH 05/19] Update help --- .../OperationValidation.psm1 | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index cecb324..e7e7f7a 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -118,10 +118,14 @@ Additional module directories may be added. If you wish to check both $env:psmodulepath and your own specific locations, use *, -.PARAMETER Type +.PARAMETER TestType The type of tests to retrieve, this may be either "Simple", "Comprehensive" or Both ("Simple,Comprehensive"). "Simple,Comprehensive" is the default. +.PARAMETER Version +The version of the module to retrieve. If the specified, the latest version +of the module will be retured. + .EXAMPLE PS> Get-OperationValidation -ModuleName C:\temp\modules\AddNumbers @@ -348,13 +352,47 @@ Invoke the operational tests from modules .DESCRIPTION Modules which include Diagnostics tests are executed via this cmdlet -.PARAMETER testFilePath +.PARAMETER TestFilePath The path to a diagnostic test to execute. By default all discoverable diagnostics will be invoked .PARAMETER TestInfo The type of tests to invoke, this may be either "Simple", "Comprehensive" or Both ("Simple,Comprehensive"). "Simple,Comprehensive" is the default. +.PARAMETER ModuleName +By default this is * which will retrieve and execute all OVF modules in $env:psmodulepath +Additional module directories may be added. If you wish to check both +$env:psmodulepath and your own specific locations, use +*, + +.PARAMETER TestType +The type of tests to execute, this may be either "Simple", "Comprehensive" +or Both ("Simple,Comprehensive"). "Simple,Comprehensive" is the default. + +.PARAMETER IncludePesterOutput +Include the Pester output when execute the tests. + +.PARAMETER Version +The version of the module to retrieve. If the specified, the latest version +of the module will be retured. + +.PARAMETER Overrides +If the Pester test(s) include script parameters, those parameters can be overridden by +specifying a hashtable of values. The key(s) in the hashtable must match the parameter +names in the Pester test. + +For example, if the Pester test includes a parameter block like the following, one or more of +these parameters can be overriden using values from the hashtable passed to the -Overrides parameter. + +Pester test script: +param( + [int]$SomeValue = 100 + [bool]$ExtraChecks = $false +) + +Overrides the default parameter values: +Invoke-OperationValidation -ModuleName MyModule -Overrides @{ SomeValue = 500; ExtraChecks = $true } + .EXAMPLE PS> Get-OperationValidation -ModuleName OperationValidation | Invoke-OperationValidation -IncludePesterOutput Describing Simple Test Suite @@ -391,7 +429,7 @@ function Invoke-OperationValidation { [CmdletBinding(SupportsShouldProcess=$true,DefaultParameterSetName="FileAndTest")] param ( - [Parameter(ParameterSetName="Path",ValueFromPipelineByPropertyName=$true)][string[]]$testFilePath, + [Parameter(ParameterSetName="Path",ValueFromPipelineByPropertyName=$true)][string[]]$TestFilePath, [Parameter(ParameterSetName="FileAndTest",ValueFromPipeline=$true)][pscustomobject[]]$TestInfo, [Parameter(ParameterSetName="UseGetOperationTest")][string[]]$ModuleName = "*", [Parameter(ParameterSetName="UseGetOperationTest")] @@ -497,9 +535,9 @@ function Invoke-OperationValidation return } - if ($testFilePath) + if ($TestFilePath) { - foreach($filePath in $testFilePath) { + foreach($filePath in $TestFilePath) { write-progress -Activity "Invoking tests in $filePath" if ( $PSCmdlet.ShouldProcess($filePath)) { $testResult = Invoke-Pester $filePath -passthru -quiet:$quiet From 52604cf8cef8da8604c72e289ba9c98f4e0d7eb4 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Thu, 23 Mar 2017 22:02:05 -0700 Subject: [PATCH 06/19] Expand subexpression --- Modules/OperationValidation/OperationValidation.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index e7e7f7a..5471c71 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -227,7 +227,7 @@ param ( # Did we specify a specific version to find? if ($PSBoundParameters.ContainsKey('Version')) { - $manifestFile = Get-ChildItem -Path $modDir.FullName -Filter "$modDir.psd1" | Select-Object -First 1 + $manifestFile = Get-ChildItem -Path $modDir.FullName -Filter "$($modDir.Name).psd1" | Select-Object -First 1 $manifest = Test-ModuleManifest -Path $manifestFile.FullName if ($manifest.Version -eq $Version) { From 9e156c47b7ad4002f0aae7f3269ab43431088199 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Thu, 23 Mar 2017 23:11:28 -0700 Subject: [PATCH 07/19] Only get module manifest if it exists --- .../OperationValidation.psm1 | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index 5471c71..396fb87 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -296,11 +296,21 @@ param ( $moduleName = Split-Path -Path $module -Leaf $manifestFile = Get-ChildItem -Path $module -Filter "$moduleName.psd1" if (-not $manifestFile) { - # We may be in a "version" directory so get the actual module name from the parent directory - $parent = (Split-Path -Path $module -Parent).Name - $manifestFile = Get-ChildItem -Path $module -Filter "$parent.psd1" + if ($moduleName -as [version]) { + # We are in a "version" directory so get the actual module name from the parent directory + $parent = (Split-Path -Path $module -Parent).Name + $manifestFile = Get-ChildItem -Path $module -Filter "$parent.psd1" + } + } + + # Some OVF modules might not have a manifest (.psd1) file. + if ($manifestFile) { + $manifest = Test-ModuleManifest -Path $manifestFile.FullName -Verbose:$false + } + else + { + $manifest = $null } - $manifest = Test-ModuleManifest -Path $manifestFile.FullName -Verbose:$false if ( test-path -path $diagnosticsDir ) { @@ -333,7 +343,7 @@ param ( Type = $dir Name = $testName ModuleName = $Module - Version = [version]$manifest.Version + Version = if ($manifest.Version) { [version]$manifest.Version } else { $null } Parameters = $parameters } New-OperationValidationInfo @modInfoParams From b2e05c87a0a9f20796db441439cd2b735eddbdad Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Thu, 23 Mar 2017 23:11:38 -0700 Subject: [PATCH 08/19] Update tests --- .../Test/OperationValidation.Tests.ps1 | Bin 8668 -> 10858 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 index 245c9174b92c74922b8cf58e9788b5529ca7c7a7..8a910a1bafaf000e4999f0419ebd04995aa2ba96 100644 GIT binary patch delta 634 zcmccP{3>LF7#DjOLn=cNL-FK^eA1KuaTM`G`3#v1`3!js>XR=DicdZ#V8V+cK3PyO zb`od7{eoy> zaKoF}J%LuGG30|(aYET}Srcntpc#2UoDMWE7l`wKCh9RbGL!=8e4q%(28eU@fc6D5 z_%kFiWC7JBGn7o`6|~-bfzN>v&7UEYF9^yJ?N@U_e}*!kfki-=$&dnM6$72xE{q|H zaI~f~&}li~AOJc8>bzp0vps;$EoR67iX{S_2@E1&SemPXJe>^Wm4ZzV0NDUk0kY8_ z?9BoYIr%R~D9GLFM5#u&#hjD?3}z??y0!%9nvBT@xr8SR3C2v~3<6qf0*vWbESndJ z`Y;QZg98HOKwY3$@LJysF delta 109 zcmaDAa>sdt7}w+m9<@oF1(O#Da7@E+F4za-W>i<~X?yrp Date: Thu, 23 Mar 2017 23:14:06 -0700 Subject: [PATCH 09/19] Change encoding to UTF-8 --- .../OperationValidation.psd1 | Bin 7846 -> 3922 bytes .../Test/OperationValidation.Tests.ps1 | Bin 10858 -> 5428 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psd1 b/Modules/OperationValidation/OperationValidation.psd1 index 4190ffea4a05e570702ff2e377aa7753e8265b53..6607290e4ffb20fb87f51a26ce91bdd8135964b1 100644 GIT binary patch literal 3922 zcmbVPTTdG~6n>AC|8P_u0xL)t3SC-hrAAOF5>UjYyAOSFW;}_@j6Jnyl4e)^@B1Cw zGfW^&%kmOrAAjfeoy%dD$0zdBAg9AmePt!8U0D*D)s*j@P?nA zO3imNrSak|eNjba>nB%6zol0%cMo6g{l0tPZ~MJ>|Mq(faFbY7R*fns9V;#DqB+PE zj1tb7M0qW9RZXdyD%V;%?DwvXsiOUV(kg3*r7L#XbJXrLsjAr{6ohgDhU} z9gNdA^40#%ILqGb>>nKL?TEcs>CWN7{^7wN@cL zm4`4UciuwzO(u1v^n_+DeH$gFVKyHKatjC7hICdn3LQ@80y+%>H$idy13K!I0;r@b z)CyQp;m6T@s*))QD`{?3RY}dyqEbl@x;9ZUQ+_oSnsQYruAfYbs>V|fwH4!Xp|mRM z0vQV=jIsGkA%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VN7aeBJe z^8JVP`#Z?kRRrAW?F9XR&ZJ9qR5>QSsNm8x76dqXok-Isoh!?0hVS}V4F z-+FIQDGY7BU{GnX)3624Fu3Y=m$?^0&*@>z95okpY_NJuceJbY!Tl%t`SmDG)`-HEXczQ;DIaGyFw-NC-C>wlEd z`PshLkj~B=a36FBJAb$G z6W;J>$?p=EqFNx|WZ+(`TTQvWSn`>`f}RJvLc6%i53g7Aop;x2SlmlIzj z#@nq(yLI$!z8{q5t^QN%+LYf@Q|+(AGh((}oXP9UrK)8YKRaHf)U^)9Q^n5Lg{cXv z-$%UOhfQDG`X>ASUa`HGMMC!;AK!Ewf->|Yw>dZ3ki)Uk{{abeP!j+E From 06b1cb596ea82e747b348450edb2bfb430e564bf Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Sat, 22 Apr 2017 15:01:01 -0700 Subject: [PATCH 10/19] Add versioned module tests --- .../Test/OperationValidation.Tests.ps1 | 9 +++++++++ .../Simple/PSGallery.Simple.Tests.ps1 | 7 +++++++ .../VersionedModule/1.0.0/VersionedModule.psd1 | Bin 0 -> 7796 bytes .../Simple/PSGallery.Simple.Tests.ps1 | 15 +++++++++++++++ .../VersionedModule/2.0.0/VersionedModule.psd1 | Bin 0 -> 7796 bytes 5 files changed, 31 insertions(+) create mode 100644 Modules/VersionedModule/1.0.0/Diagnostrics/Simple/PSGallery.Simple.Tests.ps1 create mode 100644 Modules/VersionedModule/1.0.0/VersionedModule.psd1 create mode 100644 Modules/VersionedModule/2.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 create mode 100644 Modules/VersionedModule/2.0.0/VersionedModule.psd1 diff --git a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 index 4b8ed38..605fccf 100644 --- a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 +++ b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 @@ -85,6 +85,15 @@ Describe "OperationValidation Module Tests" { @($tests).Count | Should be 1 $tests.File | should be WindowsSearch.Simple.Tests.ps1 } + It "Can find a specific version of a module" { + $tests = Get-OperationValidation -ModuleName 'VersionedModule' -Version '1.0.0' + $tests.Count | Should be 1 + $tests.File | Should be 'PSGallery.Simple.Tests.ps1' + } + It "Can get the latest version of a module if no version is specified" { + $tests = Get-OperationValidation -ModuleName VersionedModule + $tests.Version | Should be [Version]'2.0.0' + } It "Formats the output appropriately" { $output = Get-OperationValidation -modulename OperationValidation | out-string -str -width 210|?{$_} $expected = ".*Module: .*OperationValidation", diff --git a/Modules/VersionedModule/1.0.0/Diagnostrics/Simple/PSGallery.Simple.Tests.ps1 b/Modules/VersionedModule/1.0.0/Diagnostrics/Simple/PSGallery.Simple.Tests.ps1 new file mode 100644 index 0000000..ae6f0ba --- /dev/null +++ b/Modules/VersionedModule/1.0.0/Diagnostrics/Simple/PSGallery.Simple.Tests.ps1 @@ -0,0 +1,7 @@ +Describe 'Simple Validation of PSGallery' { + It 'The PowerShell Gallery should be responsive' { + $request = [System.Net.WebRequest]::Create('https://www.powershellgallery.com') + $response = $Request.GetResponse() + $response.StatusCode | Should be OK + } +} \ No newline at end of file diff --git a/Modules/VersionedModule/1.0.0/VersionedModule.psd1 b/Modules/VersionedModule/1.0.0/VersionedModule.psd1 new file mode 100644 index 0000000000000000000000000000000000000000..03a724f6c0822e424e63c1b2231f99d1e83c8d55 GIT binary patch literal 7796 zcmeI1TTh!u5Qg`|K2` zZM7u-nO3*;CdzfGr*rp<*73J5imG0hrU(nSul1**%@@ ztA%)UOFKq;*>33$WnQ-5Gq>cH{cpbWfp!|}2i*kg?YRTDA)6tq`M}vV(lt>IMUPJU zLWs8N=nKcbuib)sl1aMd*7g2En!~TqaK{k3K9?zw3qPjU(Ea}^-ykekhL`39G zgakjDIJDD|cjt1f`|mLym@lW=LnmFYhqffL?=9_QS}BBmA_+d~8E?d2$!vM_=f2pq zr%8S25uv+XW!X(#(+riPf2Uos4|W=g5*cGwE=%!~r^Y`neOB7@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ion(-) diff --git a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 index 605fccf..f213130 100644 --- a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 +++ b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 @@ -92,7 +92,7 @@ Describe "OperationValidation Module Tests" { } It "Can get the latest version of a module if no version is specified" { $tests = Get-OperationValidation -ModuleName VersionedModule - $tests.Version | Should be [Version]'2.0.0' + $tests.Version | Should be ([Version]'2.0.0') } It "Formats the output appropriately" { $output = Get-OperationValidation -modulename OperationValidation | out-string -str -width 210|?{$_} From 678e067d9dde37dff1d80dcb25e884102db34186 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Sat, 22 Apr 2017 15:06:29 -0700 Subject: [PATCH 12/19] Fix directory name --- .../Simple/PSGallery.Simple.Tests.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Modules/VersionedModule/1.0.0/{Diagnostrics => Diagnostics}/Simple/PSGallery.Simple.Tests.ps1 (100%) diff --git a/Modules/VersionedModule/1.0.0/Diagnostrics/Simple/PSGallery.Simple.Tests.ps1 b/Modules/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 similarity index 100% rename from Modules/VersionedModule/1.0.0/Diagnostrics/Simple/PSGallery.Simple.Tests.ps1 rename to Modules/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 From 9029102ec530cb37f65579e3346ab3dd23d38264 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Sat, 22 Apr 2017 21:55:59 -0700 Subject: [PATCH 13/19] Fix casting "version" directory into [version] type --- Modules/OperationValidation/OperationValidation.psm1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index 396fb87..9a1bdea 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -256,7 +256,7 @@ param ( $potentialDiagnostics = $versionDirectories | where-object { test-path ($_.fullname + "\Diagnostics") - } + } # now select the most recent module path which has diagnostics $DiagnosticDir = $potentialDiagnostics | sort-object {$_.name -as [version]} | @@ -294,12 +294,12 @@ param ( # Get the module manifest so we can pull out the version $moduleName = Split-Path -Path $module -Leaf - $manifestFile = Get-ChildItem -Path $module -Filter "$moduleName.psd1" + $manifestFile = Get-ChildItem -Path $module -Filter "$($moduleName).psd1" if (-not $manifestFile) { - if ($moduleName -as [version]) { + if ("$moduleName" -as [version]) { # We are in a "version" directory so get the actual module name from the parent directory - $parent = (Split-Path -Path $module -Parent).Name - $manifestFile = Get-ChildItem -Path $module -Filter "$parent.psd1" + $parent = Split-Path -Path (Split-Path -Path $module -Parent) -Leaf + $manifestFile = Get-ChildItem -Path $module -Filter "$($parent).psd1" } } From 2f4ff13cf4f81f94910ec3fef45fefba6c3ad38b Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Sat, 22 Apr 2017 21:56:17 -0700 Subject: [PATCH 14/19] Improve tests for multple module versions --- .../Test/OperationValidation.Tests.ps1 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 index f213130..18dfec4 100644 --- a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 +++ b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 @@ -8,12 +8,13 @@ Describe "OperationValidation Module Tests" { { $env:psmodulepath += ";$moduleDir" } + Remove-Module Microsoft.PowerShell.Operation.Validation -Force -ErrorAction SilentlyContinue Import-Module OperationValidation -Force $Commands = Get-Command -module OperationValidation|sort-object Name } AfterAll { $env:PSModulePath = $SavedModulePath - remove-Module OperationValidation + Remove-Module OperationValidation } It "Module has been loaded" { Get-Module OperationValidation | should not BeNullOrEmpty @@ -86,13 +87,19 @@ Describe "OperationValidation Module Tests" { $tests.File | should be WindowsSearch.Simple.Tests.ps1 } It "Can find a specific version of a module" { - $tests = Get-OperationValidation -ModuleName 'VersionedModule' -Version '1.0.0' - $tests.Count | Should be 1 - $tests.File | Should be 'PSGallery.Simple.Tests.ps1' + $v1Tests = @(Get-OperationValidation -ModuleName 'VersionedModule' -Version '1.0.0') + $v1Tests.Count | Should be 1 + $v1Tests.File | Should be 'PSGallery.Simple.Tests.ps1' + + $v2Tests = @(Get-OperationValidation -ModuleName 'VersionedModule' -Version '2.0.0') + $v2Tests.Count | Should be 2 + $v2Tests[0].File | Should be 'PSGallery.Simple.Tests.ps1' + $v2Tests[1].File | Should be 'PSGallery.Simple.Tests.ps1' } It "Can get the latest version of a module if no version is specified" { $tests = Get-OperationValidation -ModuleName VersionedModule - $tests.Version | Should be ([Version]'2.0.0') + $tests[0].Version | Should be ([Version]'2.0.0') + $tests[1].Version | Should be ([Version]'2.0.0') } It "Formats the output appropriately" { $output = Get-OperationValidation -modulename OperationValidation | out-string -str -width 210|?{$_} From 0ef82c7b43eaa5f49a90fd0ce8dec783ebb093fc Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Mon, 24 Apr 2017 20:36:45 -0700 Subject: [PATCH 15/19] Done error out when testing module manifest --- Modules/OperationValidation/OperationValidation.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index 9a1bdea..023942c 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -305,7 +305,7 @@ param ( # Some OVF modules might not have a manifest (.psd1) file. if ($manifestFile) { - $manifest = Test-ModuleManifest -Path $manifestFile.FullName -Verbose:$false + $manifest = Test-ModuleManifest -Path $manifestFile.FullName -Verbose:$false -ErrorAction SilentlyContinue } else { From 72429b489f753f66fe9ac04f8eeb13729150d9c7 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Mon, 24 Apr 2017 21:04:33 -0700 Subject: [PATCH 16/19] Remove 'Write-Host' statement --- Modules/OperationValidation/Test/OperationValidation.Tests.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 index 18dfec4..e2e22c6 100644 --- a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 +++ b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 @@ -82,7 +82,6 @@ Describe "OperationValidation Module Tests" { } It "Can find tests which don't have an actual module" { $tests = Get-OperationValidation -moduleName Example.WindowsSearch - write-host $tests.File @($tests).Count | Should be 1 $tests.File | should be WindowsSearch.Simple.Tests.ps1 } From b09c74a19c24e5db4132b5ae2e6650ab41de1a4e Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Mon, 24 Apr 2017 21:05:01 -0700 Subject: [PATCH 17/19] Use proper Pester 4.0 parameter for showing test output --- .../OperationValidation.psm1 | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Modules/OperationValidation/OperationValidation.psm1 b/Modules/OperationValidation/OperationValidation.psm1 index 023942c..8eda500 100644 --- a/Modules/OperationValidation/OperationValidation.psm1 +++ b/Modules/OperationValidation/OperationValidation.psm1 @@ -453,7 +453,6 @@ function Invoke-OperationValidation ) BEGIN { - $quiet = ! $IncludePesterOutput if ( ! (get-module -Name Pester)) { if ( get-module -list Pester ) @@ -505,11 +504,28 @@ function Invoke-OperationValidation { $pesterParams = @{ TestName = $ti.Name - Quiet = $quiet PassThru = $true Verbose = $false } + # Pester 4.0.0 deprecated the 'Quiet' parameter in favor of 'Show' + $pesterMod = Get-Module -Name Pester + if ($pesterMod.Version -ge '4.0.0') + { + if ($IncludePesterOutput) + { + $pesterParams.Show = 'All' + } + else + { + $pesterParams.Show = 'None' + } + } + else + { + $pesterParams.Quiet = !$IncludePesterOutput + } + if ($ti.ScriptParameters) { Write-Verbose -Message 'Test has script parameters' From d2b21915fa60c523ddf2f59ddf05ed8a23851cff Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Mon, 24 Apr 2017 21:17:26 -0700 Subject: [PATCH 18/19] Add support for script parameters --- .../Simple/PSGallery.Simple.Tests.ps1 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Modules/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 b/Modules/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 index ae6f0ba..6e91fa7 100644 --- a/Modules/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 +++ b/Modules/VersionedModule/1.0.0/Diagnostics/Simple/PSGallery.Simple.Tests.ps1 @@ -1,7 +1,18 @@ +param( + [string]$WebsiteUrl = 'https://www.powershellgallery.com', + [string]$StatusCode = 'OK' +) + + Describe 'Simple Validation of PSGallery' { It 'The PowerShell Gallery should be responsive' { - $request = [System.Net.WebRequest]::Create('https://www.powershellgallery.com') + $request = [System.Net.WebRequest]::Create($WebsiteUrl) $response = $Request.GetResponse() - $response.StatusCode | Should be OK + $response.StatusCode | Should Be $StatusCode } -} \ No newline at end of file + + it 'Has correct test parameters' { + $WebsiteUrl | Should Be 'https://www.powershellgallery.com' + $StatusCode | Should Be 'OK' + } +} From 73eda4bf6aeab451483b9ee188ab4168bf75a6e1 Mon Sep 17 00:00:00 2001 From: Brandon Olin Date: Mon, 24 Apr 2017 21:18:06 -0700 Subject: [PATCH 19/19] Add test to validate Pester test parameters can be overridden --- .../Test/OperationValidation.Tests.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 index e2e22c6..7c91e07 100644 --- a/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 +++ b/Modules/OperationValidation/Test/OperationValidation.Tests.ps1 @@ -122,4 +122,20 @@ Describe "OperationValidation Module Tests" { } } } + + Context "Invoke-OperationValidation passes override parameters" { + $tests = Get-OperationValidation -ModuleName VersionedModule -Version '1.0.0' + + It "No override parameters supplied" { + $results = $tests | Invoke-OperationValidation + $results[0].Result | Should be 'Passed' + $results[1].Result | Should be 'Passed' + } + + It "Override parameters supplied" { + $results = $tests | Invoke-OperationValidation -Overrides @{ WebsiteUrl = 'http://www.microsoft.com'} + $results[0].Result | Should be 'Passed' + $results[1].Result | Should be 'Failed' + } + } }