6 unless defined?(LISTENER_DEFAULTS)
7 BEFORE_DELAY = ENV['BEFORE_DELAY'] ? ENV['BEFORE_DELAY'].to_f : 0.5
8 AFTER_DELAY = ENV['AFTER_DELAY'] ? ENV['AFTER_DELAY'].to_f : 0.5
10 :address => ENV["LWES_TEST_ADDRESS"] || "127.0.0.1",
11 :iface => ENV["LWES_TEST_IFACE"] || "0.0.0.0",
12 :port => ENV["LWES_TEST_PORT"] ? ENV["LWES_TEST_PORT"].to_i : 12345,
13 :ttl => 60, # nil for no ttl)
17 private_bin = "ext/lwes/.inst/bin"
18 if test ?d, private_bin
19 ENV['PATH'] = "#{private_bin}:#{ENV['PATH']}"
22 def lwes_listener(&block)
23 cmd = "lwes-event-printing-listener" \
24 " -m #{@options[:address]}" \
25 " -i #{@options[:iface]}" \
26 " -p #{@options[:port]}"
27 out = Tempfile.new("out")
28 err = Tempfile.new("err")
32 $stdout.reopen(out.path)
33 $stderr.reopen(err.path)
37 # since everything executes asynchronously and our messaging,
38 # we need to ensure our listener is ready, then ensure our
39 # listener has printed something...
45 Process.kill(:TERM, pid)
47 assert_equal 0, err.size