2020-03-24 19:08:37 +01:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2018-02-13 18:23:53 +01:00
|
|
|
# Licensed under the MIT License.
|
2016-07-26 02:43:28 +02:00
|
|
|
Describe "Read-Host" -Tags "Slow","Feature" {
|
2016-07-07 23:46:14 +02:00
|
|
|
Context "[Console]::ReadKey() implementation on non-Windows" {
|
|
|
|
BeforeAll {
|
2020-01-13 20:35:33 +01:00
|
|
|
$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
|
2016-07-07 23:46:14 +02:00
|
|
|
$assetsDir = Join-Path -Path $PSScriptRoot -ChildPath assets
|
|
|
|
if ($IsWindows) {
|
|
|
|
$ItArgs = @{ skip = $true }
|
|
|
|
} elseif (-not (Get-Command expect -ErrorAction Ignore)) {
|
|
|
|
$ItArgs = @{ pending = $true }
|
|
|
|
} else {
|
|
|
|
$ItArgs = @{ }
|
|
|
|
}
|
2019-05-10 19:56:12 +02:00
|
|
|
|
|
|
|
$expectFile = Join-Path $assetsDir "Read-Host.Output.expect"
|
|
|
|
|
|
|
|
if (-not $IsWindows) {
|
|
|
|
chmod a+x $expectFile
|
|
|
|
}
|
2016-07-07 23:46:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It @ItArgs "Should output correctly" {
|
2019-05-10 19:56:12 +02:00
|
|
|
& $expectFile $powershell | Out-Null
|
2018-03-23 18:48:26 +01:00
|
|
|
$LASTEXITCODE | Should -Be 0
|
2016-07-07 23:46:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|