@@ -104,16 +104,17 @@ defmodule ExUnit.CaptureIO do
104
104
do_capture_io ( map_dev ( device ) , options , fun )
105
105
end
106
106
107
- defp map_dev ( :stdio ) , do: :standard_io
107
+ defp map_dev ( :stdio ) , do: :standard_io
108
108
defp map_dev ( :stderr ) , do: :standard_error
109
- defp map_dev ( other ) , do: other
109
+ defp map_dev ( other ) , do: other
110
110
111
111
defp do_capture_io ( :standard_io , options , fun ) do
112
112
prompt_config = Keyword . get ( options , :capture_prompt , true )
113
113
input = Keyword . get ( options , :input , "" )
114
114
115
115
original_gl = Process . group_leader ( )
116
116
{ :ok , capture_gl } = StringIO . open ( input , capture_prompt: prompt_config )
117
+
117
118
try do
118
119
Process . group_leader ( self ( ) , capture_gl )
119
120
do_capture_io ( capture_gl , fun )
@@ -125,19 +126,22 @@ defmodule ExUnit.CaptureIO do
125
126
defp do_capture_io ( device , options , fun ) do
126
127
input = Keyword . get ( options , :input , "" )
127
128
{ :ok , string_io } = StringIO . open ( input )
129
+
128
130
case ExUnit.CaptureServer . device_capture_on ( device , string_io ) do
129
131
{ :ok , ref } ->
130
132
try do
131
133
do_capture_io ( string_io , fun )
132
134
after
133
135
ExUnit.CaptureServer . device_capture_off ( ref )
134
136
end
137
+
135
138
{ :error , :no_device } ->
136
139
_ = StringIO . close ( string_io )
137
- raise "could not find IO device registered at #{ inspect device } "
140
+ raise "could not find IO device registered at #{ inspect ( device ) } "
141
+
138
142
{ :error , :already_captured } ->
139
143
_ = StringIO . close ( string_io )
140
- raise "IO device registered at #{ inspect device } is already captured"
144
+ raise "IO device registered at #{ inspect ( device ) } is already captured"
141
145
end
142
146
end
143
147
0 commit comments