@@ -16,6 +16,11 @@ def initialize
16
16
@existing = existing_display?
17
17
@enabled = false
18
18
@pid = nil
19
+
20
+ # @xv_pipe_out_wr = nil
21
+ # @xv_pipe_err_wr = nil
22
+ # @xv_pipe_out = nil
23
+ # @xv_pipe_err = nil
19
24
end
20
25
21
26
# attempt to determine if the machine is running a graphical display (i.e. not Travis)
@@ -71,6 +76,8 @@ def enable
71
76
end
72
77
73
78
return unless @pid . nil? # TODO: disable first?
79
+ # @xv_pipe_out.close unless @xv_pipe_out.nil?
80
+ # @xv_pipe_err.close unless @xv_pipe_err.nil?
74
81
75
82
# open Xvfb
76
83
xvfb_cmd = [
@@ -81,7 +88,15 @@ def enable
81
88
"-screen" , "0" ,
82
89
"1280x1024x16" ,
83
90
]
84
- puts "pipeline_start for Xvfb"
91
+ puts "Xvfb launching"
92
+
93
+ # # seems to cause a hang, not sure why
94
+ # @xv_pipe_out, @xv_pipe_out_wr = IO.pipe
95
+ # @xv_pipe_err, @xv_pipe_err_wr = IO.pipe
96
+ # puts "xv_pipe_out_wr: #{@xv_pipe_out_wr}"
97
+ # puts "xv_pipe_err_wr: #{@xv_pipe_err_wr}"
98
+ # pipe = IO.popen(xvfb_cmd, stdout: @xv_pipe_out_wr, err: @xv_pipe_err_wr)
99
+
85
100
pipe = IO . popen ( xvfb_cmd )
86
101
@pid = pipe . pid
87
102
@enabled = xvfb_launched? ( DESIRED_DISPLAY , @pid , 30 )
@@ -109,6 +124,9 @@ def disable
109
124
Process . wait @pid
110
125
@enabled = false
111
126
@pid = nil
127
+
128
+ # @xv_pipe_out_wr.close
129
+ # @xv_pipe_err_wr.close
112
130
end
113
131
end
114
132
@@ -133,14 +151,11 @@ def run(*args, **kwargs)
133
151
env_vars . merge! ( args [ 0 ] ) if has_env
134
152
actual_args = has_env ? args [ 1 ..-1 ] : args # need to shift over if we extracted args
135
153
full_cmd = env_vars . empty? ? actual_args : [ env_vars ] + actual_args
136
-
137
- puts "Running #{ env_vars } $ #{ actual_args . join ( ' ' ) } "
138
- puts "Full_cmd is #{ full_cmd } "
139
- puts "kwargs is #{ kwargs } "
154
+ shell_vars = env_vars . map { |k , v | "#{ k } =#{ v } " } . join ( " " )
155
+ puts " $ #{ shell_vars } #{ actual_args . join ( ' ' ) } "
140
156
ret = system ( *full_cmd , **kwargs )
141
- puts "system call to #{ actual_args [ 0 ] } has completed"
157
+ puts "#{ actual_args [ 0 ] } has completed"
142
158
end
143
- puts "with_display has completed"
144
159
ret
145
160
end
146
161
0 commit comments