From e95f0099edc4e051b9c2f1ffa6510defb5b39e9f Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 27 Feb 2018 09:23:05 -0800 Subject: [PATCH] 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. --- build.psm1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build.psm1 b/build.psm1 index 4ed2788baf..000b619775 100644 --- a/build.psm1 +++ b/build.psm1 @@ -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 $_}