@@ -23,57 +23,18 @@ function Get-RuntimeError
2323{
2424 [CmdletBinding ()]
2525 param (
26- [Parameter (ValueFromPipeline = $True , Mandatory = $True )]
27- [string ]$src ,
28- [Parameter ()]
29- [int ]$Timeout = 0
26+ [Parameter (ValueFromPipeline = $True , Mandatory = $True )][string ]$src
3027 )
3128
3229 $errors = $null
3330 try
3431 {
35- # some tests cannot be run in a isolated runspace
36- # easily because they require more than just a single
37- # execution
38- if ( $Timeout -eq 0 )
39- {
40- [scriptblock ]::Create($src ).Invoke() > $null
41- }
42- else
43- {
44- $ps = [powershell ]::Create()
45- $ps.AddScript ($src ) > $null
46- $ar = $ps.BeginInvoke ()
47- # give it 250 milliseconds to complete
48- start-sleep - mill 250
49- if ( $ar.IsCompleted ) {
50- $ps.EndInvoke ($ar )
51- }
52- # wait another ${Timeout} seconds, then give up
53- else {
54- Start-Sleep - sec $Timeout
55- if ( $ar.IsCompleted ) {
56- # this can throw, which will be picked up below
57- $ps.EndInvoke ($ar )
58- }
59- else {
60- # if it didn't throw, then return a constructed error
61- $ER = Write-Error " Operation Timed Out ('$src ')" 2>&1
62- return $ER
63- }
64- }
65- }
32+ [scriptblock ]::Create($src ).Invoke() > $null
6633 }
6734 catch
6835 {
6936 return $_.Exception.InnerException.ErrorRecord
7037 }
71- finally
72- {
73- if ( $ps -ne $null ) {
74- $ps.dispose ()
75- }
76- }
7738}
7839
7940function position_message
@@ -114,7 +75,7 @@ function ShouldBeParseError
11475 if ($SkipAndCheckRuntimeError )
11576 {
11677 It " error should happen at parse time, not at runtime" - Skip {}
117- $errors = Get-RuntimeError - Src $src - Timeout 10
78+ $errors = Get-RuntimeError - Src $src
11879 # for runtime errors we will only get the first one
11980 $expectedErrors = , $expectedErrors [0 ]
12081 $expectedOffsets = , $expectedOffsets [0 ]
0 commit comments