Skip to content

Commit 6124d6a

Browse files
committed
make debug messages in display_manager toggleable
1 parent 78fca73 commit 6124d6a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/arduino_ci/display_manager.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ module ArduinoCI
1111
class DisplayManager
1212
include Singleton
1313
attr_reader :enabled
14+
attr_accessor :debug
1415

1516
def initialize
1617
@existing = existing_display?
1718
@enabled = false
1819
@pid = nil
20+
@debug = false
1921

2022
@xv_pipe_out_wr = nil
2123
@xv_pipe_err_wr = nil
@@ -58,7 +60,7 @@ def xvfb_launched?(display, pid, timeout)
5860
return false
5961
end
6062
x = xserver_exist? display
61-
puts "xdpyinfo reports X server status as #{x}"
63+
puts "xdpyinfo reports X server status as #{x}" if debug
6264
return true if x
6365
sleep(0.1)
6466
end
@@ -70,7 +72,7 @@ def xvfb_launched?(display, pid, timeout)
7072
# enable a virtual display
7173
def enable
7274
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
7476
@enabled = true
7577
return
7678
end
@@ -88,7 +90,7 @@ def enable
8890
"-screen", "0",
8991
"1280x1024x16",
9092
]
91-
puts "Xvfb launching"
93+
puts "Xvfb launching" if debug
9294

9395
@xv_pipe_out, @xv_pipe_out_wr = IO.pipe
9496
@xv_pipe_err, @xv_pipe_err_wr = IO.pipe
@@ -100,7 +102,7 @@ def enable
100102
# disable the virtual display
101103
def disable
102104
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
104106
return @enabled = false
105107
end
106108

@@ -110,11 +112,11 @@ def disable
110112
begin
111113
Timeout.timeout(30) do
112114
Process.kill("TERM", @pid)
113-
puts "Xvfb TERMed"
115+
puts "Xvfb TERMed" if debug
114116
end
115117
rescue Timeout::Error
116118
Process.kill(9, @pid)
117-
puts "Xvfb KILLed"
119+
puts "Xvfb KILLed" if debug
118120
ensure
119121
Process.wait @pid
120122
@enabled = false

0 commit comments

Comments
 (0)