Fix Start-PSPester to include or exclude 'RequireSudoOnUnix' tag smartly on Unix (#6241)

If `-sudo` is specified, make sure to include 'RequireSudoOnUnix' tag on Unix if the 'Tag' is not specified.
If `-sudo` is not specified, make sure to exclude `RequireSudoOnUnix` tag on Unix if the 'ExcludeTag' is not specified.
This commit is contained in:
Steve Lee 2018-02-27 09:23:05 -08:00 committed by Dongbo Wang
parent 5030c9a2fd
commit e95f0099ed

View file

@ -1025,6 +1025,20 @@ Restore the module to '$Pester' by running:
$ExcludeTag += 'RequireAdminOnWindows'
}
}
elseif (-not $Environment.IsWindows -and (-not $Sudo.IsPresent))
{
if (-not $PSBoundParameters.ContainsKey('ExcludeTag'))
{
$ExcludeTag += 'RequireSudoOnUnix'
}
}
elseif (-not $Environment.IsWindows -and $Sudo.IsPresent)
{
if (-not $PSBoundParameters.ContainsKey('Tag'))
{
$Tag = 'RequireSudoOnUnix'
}
}
Write-Verbose "Running pester tests at '$path' with tag '$($Tag -join ''', ''')' and ExcludeTag '$($ExcludeTag -join ''', ''')'" -Verbose
Publish-PSTestTools | ForEach-Object {Write-Host $_}