@@ -46,6 +46,7 @@ function new-OperationValidationInfo
46
46
[Parameter ()][string []]$TestCases ,
47
47
[Parameter (Mandatory = $true )][ValidateSet (" None" , " Simple" , " Comprehensive" )][string ]$Type ,
48
48
[Parameter ()][string ]$modulename ,
49
+ [Parameter ()][Version ]$Version ,
49
50
[Parameter ()][hashtable ]$Parameters
50
51
)
51
52
$o = [pscustomobject ]@ {
@@ -55,6 +56,7 @@ function new-OperationValidationInfo
55
56
TestCases = $testCases
56
57
Type = $type
57
58
ModuleName = $modulename
59
+ Version = $Version
58
60
ScriptParameters = $Parameters
59
61
}
60
62
$o.psobject.Typenames.Insert (0 , " OperationValidationInfo" )
@@ -69,7 +71,6 @@ function Get-TestFromScript
69
71
param ( [string ]$scriptPath )
70
72
$errs = $null
71
73
$tok = [System.Management.Automation.PSParser ]::Tokenize((get-content - read 0 - Path $scriptPath ), [ref ]$Errs )
72
- write-verbose - Message $scriptPath
73
74
74
75
for ($i = 0 ; $i -lt $tok.count ; $i ++ ) {
75
76
if ( $tok [$i ].type -eq " Command" -and $tok [$i ].content -eq " Describe" )
@@ -285,20 +286,31 @@ param (
285
286
foreach ($module in $moduleCollection )
286
287
{
287
288
Write-Progress - Activity (" Searching for Diagnostics in " + $module ) - PercentComplete ($count ++/ $moduleCount * 100 ) - status " "
288
- $diagnosticsDir = $module + " \Diagnostics"
289
+ $diagnosticsDir = " $module \Diagnostics"
290
+
291
+ # Get the module manifest so we can pull out the version
292
+ $moduleName = Split-Path - Path $module - Leaf
293
+ $manifestFile = Get-ChildItem - Path $module - Filter " $moduleName .psd1"
294
+ if (-not $manifestFile ) {
295
+ # We may be in a "version" directory so get the actual module name from the parent directory
296
+ $parent = (Split-Path - Path $module - Parent).Name
297
+ $manifestFile = Get-ChildItem - Path $module - Filter " $parent .psd1"
298
+ }
299
+ $manifest = Test-ModuleManifest - Path $manifestFile.FullName - Verbose:$false
300
+
289
301
if ( test-path - path $diagnosticsDir )
290
302
{
291
303
foreach ($dir in $testType )
292
304
{
293
- $testDir = " $diagnosticsDir \ $dir "
294
- write-verbose - Message " SPECIFIC TEST: $testDir "
305
+ $testDir = Join-Path - Path $diagnosticsDir - ChildPath $dir
306
+ write-verbose - Message " TEST DIR : $testDir "
295
307
if ( ! (test-path - path $testDir ) )
296
308
{
297
309
continue
298
310
}
299
311
foreach ($file in get-childitem - path $testDir - filter * .tests.ps1)
300
312
{
301
- Write-Verbose - Message $ file.fullname
313
+ Write-Verbose - Message " PESTER TEST: $ ( $ file.fullname ) "
302
314
303
315
# Pull out parameters to Pester script if they exist
304
316
$script = Get-Command - Name $file.fullname
@@ -311,7 +323,16 @@ param (
311
323
312
324
$testNames = @ (Get-TestFromScript - scriptPath $file.FullName )
313
325
foreach ($testName in $testNames ) {
314
- New-OperationValidationInfo - FilePath $file.Fullname - File $file.Name - Type $dir - Name $testName - ModuleName $Module - Parameters $parameters
326
+ $modInfoParams = @ {
327
+ FilePath = $file.Fullname
328
+ File = $file.Name
329
+ Type = $dir
330
+ Name = $testName
331
+ ModuleName = $Module
332
+ Version = [version ]$manifest.Version
333
+ Parameters = $parameters
334
+ }
335
+ New-OperationValidationInfo @modInfoParams
315
336
}
316
337
}
317
338
}
@@ -431,7 +452,7 @@ function Invoke-OperationValidation
431
452
}
432
453
}
433
454
434
- Write-Verbose - Message (" EXECUTING: {0} {1}" -f $ti.FilePath , ($ti.Name -join " ," ))
455
+ Write-Verbose - Message (" EXECUTING: {0} [ {1}] " -f $ti.FilePath , ($ti.Name -join " ," ))
435
456
foreach ($ti in $testinfo )
436
457
{
437
458
$pesterParams = @ {
@@ -446,7 +467,7 @@ function Invoke-OperationValidation
446
467
Write-Verbose - Message ' Test has script parameters'
447
468
if ($PSBoundParameters.ContainsKey (' Overrides' ))
448
469
{
449
- Write-Verbose - Message " Overriding with parameters:`n $ ( $Overrides | Format-List - Property * | Out-String ) "
470
+ Write-Verbose - Message " Overriding with parameters:`n $ ( $Overrides | Format-Table - Property Key , Value | Out-String ) "
450
471
$pesterParams.Script = @ {
451
472
Path = $ti.FilePath
452
473
Parameters = $Overrides
0 commit comments