@@ -11,11 +11,13 @@ module ArduinoCI
11
11
class DisplayManager
12
12
include Singleton
13
13
attr_reader :enabled
14
+ attr_accessor :debug
14
15
15
16
def initialize
16
17
@existing = existing_display?
17
18
@enabled = false
18
19
@pid = nil
20
+ @debug = false
19
21
20
22
@xv_pipe_out_wr = nil
21
23
@xv_pipe_err_wr = nil
@@ -58,7 +60,7 @@ def xvfb_launched?(display, pid, timeout)
58
60
return false
59
61
end
60
62
x = xserver_exist? display
61
- puts "xdpyinfo reports X server status as #{ x } "
63
+ puts "xdpyinfo reports X server status as #{ x } " if debug
62
64
return true if x
63
65
sleep ( 0.1 )
64
66
end
@@ -70,7 +72,7 @@ def xvfb_launched?(display, pid, timeout)
70
72
# enable a virtual display
71
73
def enable
72
74
if @existing
73
- puts "DisplayManager enable: no-op for what appears to be an existing display"
75
+ puts "DisplayManager enable: no-op for what appears to be an existing display" if debug
74
76
@enabled = true
75
77
return
76
78
end
@@ -88,7 +90,7 @@ def enable
88
90
"-screen" , "0" ,
89
91
"1280x1024x16" ,
90
92
]
91
- puts "Xvfb launching"
93
+ puts "Xvfb launching" if debug
92
94
93
95
@xv_pipe_out , @xv_pipe_out_wr = IO . pipe
94
96
@xv_pipe_err , @xv_pipe_err_wr = IO . pipe
@@ -100,7 +102,7 @@ def enable
100
102
# disable the virtual display
101
103
def disable
102
104
if @existing
103
- puts "DisplayManager disable: no-op for what appears to be an existing display"
105
+ puts "DisplayManager disable: no-op for what appears to be an existing display" if debug
104
106
return @enabled = false
105
107
end
106
108
@@ -110,11 +112,11 @@ def disable
110
112
begin
111
113
Timeout . timeout ( 30 ) do
112
114
Process . kill ( "TERM" , @pid )
113
- puts "Xvfb TERMed"
115
+ puts "Xvfb TERMed" if debug
114
116
end
115
117
rescue Timeout ::Error
116
118
Process . kill ( 9 , @pid )
117
- puts "Xvfb KILLed"
119
+ puts "Xvfb KILLed" if debug
118
120
ensure
119
121
Process . wait @pid
120
122
@enabled = false
0 commit comments