Remove async tests for parser (#3119)
* Remove async tests for parser this is a fix for https://github.com/PowerShell/PowerShell/issues/3069 This removes an attempt to work-around the issue of tests hanging on Travis-CI. * remove unneeded finally block
This commit is contained in:
parent
fd70adbc90
commit
d801b75d35
|
@ -23,57 +23,18 @@ function Get-RuntimeError
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Parameter(ValueFromPipeline=$True,Mandatory=$True)]
|
[Parameter(ValueFromPipeline=$True,Mandatory=$True)][string]$src
|
||||||
[string]$src,
|
|
||||||
[Parameter()]
|
|
||||||
[int]$Timeout = 0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
$errors = $null
|
$errors = $null
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
# some tests cannot be run in a isolated runspace
|
[scriptblock]::Create($src).Invoke() > $null
|
||||||
# easily because they require more than just a single
|
|
||||||
# execution
|
|
||||||
if ( $Timeout -eq 0 )
|
|
||||||
{
|
|
||||||
[scriptblock]::Create($src).Invoke() > $null
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ps = [powershell]::Create()
|
|
||||||
$ps.AddScript($src) > $null
|
|
||||||
$ar = $ps.BeginInvoke()
|
|
||||||
# give it 250 milliseconds to complete
|
|
||||||
start-sleep -mill 250
|
|
||||||
if ( $ar.IsCompleted ) {
|
|
||||||
$ps.EndInvoke($ar)
|
|
||||||
}
|
|
||||||
# wait another ${Timeout} seconds, then give up
|
|
||||||
else {
|
|
||||||
Start-Sleep -sec $Timeout
|
|
||||||
if ( $ar.IsCompleted ) {
|
|
||||||
# this can throw, which will be picked up below
|
|
||||||
$ps.EndInvoke($ar)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# if it didn't throw, then return a constructed error
|
|
||||||
$ER = Write-Error "Operation Timed Out ('$src')" 2>&1
|
|
||||||
return $ER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return $_.Exception.InnerException.ErrorRecord
|
return $_.Exception.InnerException.ErrorRecord
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if ( $ps -ne $null ) {
|
|
||||||
$ps.dispose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function position_message
|
function position_message
|
||||||
|
@ -114,7 +75,7 @@ function ShouldBeParseError
|
||||||
if ($SkipAndCheckRuntimeError)
|
if ($SkipAndCheckRuntimeError)
|
||||||
{
|
{
|
||||||
It "error should happen at parse time, not at runtime" -Skip {}
|
It "error should happen at parse time, not at runtime" -Skip {}
|
||||||
$errors = Get-RuntimeError -Src $src -Timeout 10
|
$errors = Get-RuntimeError -Src $src
|
||||||
# for runtime errors we will only get the first one
|
# for runtime errors we will only get the first one
|
||||||
$expectedErrors = ,$expectedErrors[0]
|
$expectedErrors = ,$expectedErrors[0]
|
||||||
$expectedOffsets = ,$expectedOffsets[0]
|
$expectedOffsets = ,$expectedOffsets[0]
|
||||||
|
|
Loading…
Reference in a new issue