Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1e0142

Browse files
committed
Add -powershell and -Pester options to Start-PSPester
When testing containers, we want to use the in-box PowerShell.
1 parent 03237e9 commit e1e0142

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

build.psm1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,24 +557,24 @@ function Start-PSPester {
557557
[string]$Path = "$PSScriptRoot/test/powershell",
558558
[switch]$ThrowOnFailure,
559559
[switch]$FullCLR,
560-
[string]$binDir = (Split-Path (New-PSOptions -FullCLR:$FullCLR).Output)
560+
[string]$binDir = (Split-Path (New-PSOptions -FullCLR:$FullCLR).Output),
561+
[string]$powershell = (Join-Path $binDir 'powershell'),
562+
[string]$Pester = ([IO.Path]::Combine($binDir, "Modules", "Pester"))
561563
)
562564

563565
Write-Verbose "Running pester tests at '$path' with tag '$($Tag -join ''', ''')' and ExcludeTag '$($ExcludeTag -join ''', ''')'" -Verbose
564566
# All concatenated commands/arguments are suffixed with the delimiter (space)
565567
$Command = ""
566-
$powershell = Join-Path $binDir 'powershell'
567568

568569
# Windows needs the execution policy adjusted
569570
if ($IsWindows) {
570571
$Command += "Set-ExecutionPolicy -Scope Process Unrestricted; "
571572
}
572573
$startParams = @{binDir=$binDir}
573574

574-
$PesterModule = [IO.Path]::Combine($binDir, "Modules", "Pester")
575575
if(!$FullCLR)
576576
{
577-
$Command += "Import-Module '$PesterModule'; "
577+
$Command += "Import-Module '$Pester'; "
578578
}
579579
$Command += "Invoke-Pester "
580580

docker/launch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ for build in $BUILDS; do
2727
image="$build/$distro"
2828
if [[ "$TEST" -eq 1 ]]; then
2929
echo "Testing $image"
30-
command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester"
30+
command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester -powershell powershell -Pester ./src/Modules/Shared/Pester"
3131
# clone repo for stable images because it's not already done
3232
if [[ "$build" = stable ]]; then
3333
command="git clone --recursive https://github.com/$FORK/PowerShell -b $BRANCH; $command"
3434
fi
3535
# run Pester tests inside container
36-
docker run --rm -it powershell/powershell:$build-$distro powershell -c "$command"
36+
docker run --rm -it powershell/powershell:$build-$distro -c "$command"
3737
else
3838
echo "Building $image"
3939
# copy the common script because it lives outside the docker build context

0 commit comments

Comments
 (0)