Skip to content

Commit 89e3e61

Browse files
committed
Updated Invoke-LabPester.ps1 to now check the CustomRole directory for each detected CustomRole used for tests.ps1 files.
1 parent ac5e1a1 commit 89e3e61

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

AutomatedLabTest/functions/Invoke-LabPester.ps1

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
function Invoke-LabPester
2-
{
1+
function Invoke-LabPester {
32
[CmdletBinding(DefaultParameterSetName = 'ByLab')]
43
param
54
(
@@ -21,37 +20,39 @@
2120
$OutputFile
2221
)
2322

24-
process
25-
{
26-
if (-not $Lab)
27-
{
23+
process {
24+
if (-not $Lab) {
2825
$Lab = Import-Lab -Name $LabName -ErrorAction Stop -NoDisplay -NoValidation -PassThru
2926
}
3027

3128
$global:pesterLab = $Lab # No parameters in Pester v5 yet
3229
$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
3432
$configuration.Run.PassThru = $PassThru.IsPresent
3533
[string[]]$tags = 'General'
3634

37-
if ($Lab.Machines.Roles.Name)
38-
{
35+
if ($Lab.Machines.Roles.Name) {
3936
$tags += $Lab.Machines.Roles.Name
4037
}
41-
if ($Lab.Machines.PostInstallationActivity | Where-Object IsCustomRole)
42-
{
38+
if ($Lab.Machines.PostInstallationActivity | Where-Object IsCustomRole) {
4339
$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+
}
4443
}
45-
if ($Lab.Machines.PreInstallationActivity | Where-Object IsCustomRole)
46-
{
44+
if ($Lab.Machines.PreInstallationActivity | Where-Object IsCustomRole) {
4745
$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+
}
4849
}
49-
50+
$configuration.Run.Path = $config_paths
5051
$configuration.Filter.Tag = $tags
5152
$configuration.Should.ErrorAction = 'Continue'
5253
$configuration.TestResult.Enabled = $true
53-
if ($OutputFile)
54-
{
54+
55+
if ($OutputFile) {
5556
$configuration.TestResult.OutputPath = $OutputFile
5657
}
5758
$configuration.Output.Verbosity = $Show

0 commit comments

Comments
 (0)