-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false errors and broken CI-logs from P-tests (#2345)
- Loading branch information
Showing
3 changed files
with
26 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function Invoke-InNewProcess ([ScriptBlock] $ScriptBlock) { | ||
# get the path of the currently loaded Pester to re-import it in the child process | ||
$pesterPath = Get-Module Pester | Select-Object -ExpandProperty Path | ||
$powershell = Get-Process -Id $pid | Select-Object -ExpandProperty Path | ||
# run any scriptblock in a separate process to be able to grab all the output | ||
# doesn't enforce Invoke-Pester usage so we can test other public functions directly | ||
$command = { | ||
param ($PesterPath, [ScriptBlock] $ScriptBlock) | ||
Import-Module $PesterPath | ||
|
||
. $ScriptBlock | ||
}.ToString() | ||
|
||
if ($PSVersionTable.PSVersion -ge '7.3' -and $PSNativeCommandArgumentPassing -ne 'Legacy') { | ||
$cmd = "& { $command } -PesterPath ""$PesterPath"" -ScriptBlock { $ScriptBlock }" | ||
} | ||
else { | ||
$cmd = "& { $command } -PesterPath ""$PesterPath"" -ScriptBlock { $($ScriptBlock -replace '"','\"') }" | ||
} | ||
|
||
& $powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command $cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters