forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnter-PSHostProcess.Tests.ps1
More file actions
54 lines (46 loc) · 1.72 KB
/
Copy pathEnter-PSHostProcess.Tests.ps1
File metadata and controls
54 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Enter-PSHostProcess tests" -Tag Feature {
BeforeAll {
$si = [System.Diagnostics.ProcessStartInfo]::new()
$si.FileName = "pwsh"
$si.Arguments = "-noexit"
$si.RedirectStandardInput = $true
$si.RedirectStandardOutput = $true
$si.RedirectStandardError = $true
$pwsh = [System.Diagnostics.Process]::Start($si)
if ($IsWindows) {
$si.FileName = "powershell"
$powershell = [System.Diagnostics.Process]::Start($si)
}
if ($env:AppVeyor) {
$IsAppveyor = $true
}
else {
$IsAppveyor = $false
}
}
AfterAll {
$pwsh | Stop-Process
if ($IsWindows) {
$powershell | Stop-Process
}
}
# Skip on Appveyor due to PSReadline issue.
It "Can enter and exit another PSHost" -Skip:$IsAppVeyor {
"enter-pshostprocess -id $($pwsh.Id)`n`$pid`nexit-pshostprocess" | pwsh -c - | Should -Be $pwsh.Id
}
# Skip on Appveyor due to PSReadline issue.
It "Can enter and exit another Windows PowerShell PSHost" -Skip:(!$IsWindows -or $IsAppVeyor) {
"enter-pshostprocess -id $($powershell.Id)`n`$pid`nexit-pshostprocess" | pwsh -c - | Should -Be $powershell.Id
}
It "Can enter using NamedPipeConnectionInfo" {
$npInfo = [System.Management.Automation.Runspaces.NamedPipeConnectionInfo]::new($pwsh.Id)
$rs = [runspacefactory]::CreateRunspace($npInfo)
$rs.Open()
$ps = [powershell]::Create()
$ps.Runspace = $rs
$ps.AddScript('$pid').Invoke() | Should -Be $pwsh.Id
$rs.Dispose()
}
}