|
1 | | -function Invoke-LabPester |
2 | | -{ |
| 1 | +function Invoke-LabPester { |
3 | 2 | [CmdletBinding(DefaultParameterSetName = 'ByLab')] |
4 | 3 | param |
5 | 4 | ( |
|
21 | 20 | $OutputFile |
22 | 21 | ) |
23 | 22 |
|
24 | | - process |
25 | | - { |
26 | | - if (-not $Lab) |
27 | | - { |
| 23 | + process { |
| 24 | + if (-not $Lab) { |
28 | 25 | $Lab = Import-Lab -Name $LabName -ErrorAction Stop -NoDisplay -NoValidation -PassThru |
29 | 26 | } |
30 | 27 |
|
31 | 28 | $global:pesterLab = $Lab # No parameters in Pester v5 yet |
32 | 29 | $configuration = [PesterConfiguration]::Default |
33 | | - $configuration.Run.Path = Join-Path -Path $PSCmdlet.MyInvocation.MyCommand.Module.ModuleBase -ChildPath 'tests' |
| 30 | + $config_paths = @() # Setup the array to pass to $Configuration.Run.Path |
| 31 | + $config_paths += Join-Path -Path $PSCmdlet.MyInvocation.MyCommand.Module.ModuleBase -ChildPath 'tests' # This is for the built-in Roles |
34 | 32 | $configuration.Run.PassThru = $PassThru.IsPresent |
35 | 33 | [string[]]$tags = 'General' |
36 | 34 |
|
37 | | - if ($Lab.Machines.Roles.Name) |
38 | | - { |
| 35 | + if ($Lab.Machines.Roles.Name) { |
39 | 36 | $tags += $Lab.Machines.Roles.Name |
40 | 37 | } |
41 | | - if ($Lab.Machines.PostInstallationActivity | Where-Object IsCustomRole) |
42 | | - { |
| 38 | + if ($Lab.Machines.PostInstallationActivity | Where-Object IsCustomRole) { |
43 | 39 | $tags += ($Lab.Machines.PostInstallationActivity | Where-Object IsCustomRole).RoleName |
| 40 | + foreach ( $role in (($Lab.Machines.PostInstallationActivity | Where-Object IsCustomRole).RoleName)) { |
| 41 | + $config_paths += Join-Path -Path $global:LabSources\CustomRoles -ChildPath $role |
| 42 | + } |
44 | 43 | } |
45 | | - if ($Lab.Machines.PreInstallationActivity | Where-Object IsCustomRole) |
46 | | - { |
| 44 | + if ($Lab.Machines.PreInstallationActivity | Where-Object IsCustomRole) { |
47 | 45 | $tags += ($Lab.Machines.PreInstallationActivity | Where-Object IsCustomRole).RoleName |
| 46 | + foreach ( $role in (($Lab.Machines.PreInstallationActivity | Where-Object IsCustomRole).RoleName)) { |
| 47 | + $config_paths += Join-Path -Path $global:LabSources\CustomRoles -ChildPath $role |
| 48 | + } |
48 | 49 | } |
49 | | - |
| 50 | + $configuration.Run.Path = $config_paths |
50 | 51 | $configuration.Filter.Tag = $tags |
51 | 52 | $configuration.Should.ErrorAction = 'Continue' |
52 | 53 | $configuration.TestResult.Enabled = $true |
53 | | - if ($OutputFile) |
54 | | - { |
| 54 | + |
| 55 | + if ($OutputFile) { |
55 | 56 | $configuration.TestResult.OutputPath = $OutputFile |
56 | 57 | } |
57 | 58 | $configuration.Output.Verbosity = $Show |
|
0 commit comments