From d801b75d353ddb6363dfae40b21977cb15dadb09 Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Wed, 15 Feb 2017 16:39:30 -0800 Subject: [PATCH] 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 --- .../Language/LanguageTestSupport.psm1 | 45 ++----------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/test/powershell/Language/LanguageTestSupport.psm1 b/test/powershell/Language/LanguageTestSupport.psm1 index 426bae8a5..75b4ae60d 100644 --- a/test/powershell/Language/LanguageTestSupport.psm1 +++ b/test/powershell/Language/LanguageTestSupport.psm1 @@ -23,57 +23,18 @@ function Get-RuntimeError { [CmdletBinding()] param( - [Parameter(ValueFromPipeline=$True,Mandatory=$True)] - [string]$src, - [Parameter()] - [int]$Timeout = 0 + [Parameter(ValueFromPipeline=$True,Mandatory=$True)][string]$src ) $errors = $null try { - # some tests cannot be run in a isolated runspace - # 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 - } - } - } + [scriptblock]::Create($src).Invoke() > $null } catch { return $_.Exception.InnerException.ErrorRecord } - finally - { - if ( $ps -ne $null ) { - $ps.dispose() - } - } } function position_message @@ -114,7 +75,7 @@ function ShouldBeParseError if ($SkipAndCheckRuntimeError) { 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 $expectedErrors = ,$expectedErrors[0] $expectedOffsets = ,$expectedOffsets[0]