Commit 92cc8d1b authored by Jordan Sissel's avatar Jordan Sissel

Use IO.popen because JRuby doesn't have fork (and IO.popen does what I need anyway

parent 2f998581
......@@ -20,14 +20,10 @@ describe "lumberjack" do
:ssl_certificate => @ssl_cert.path,
:ssl_key => @ssl_key.path
)
reader, @writer = IO::pipe
@lumberjack_pid = fork do
@writer.close
$stdin.reopen(reader)
exec("build/bin/lumberjack --host localhost --port #{@server.port} " \
"--ssl-ca-path #{@ssl_cert.path} -")
end
reader.close
@lumberjack = IO.popen("build/bin/lumberjack --host localhost " \
"--port #{@server.port} " \
"--ssl-ca-path #{@ssl_cert.path} -",
"r+")
@event_queue = Queue.new
@server_thread = Thread.new do
......@@ -41,8 +37,8 @@ describe "lumberjack" do
@ssl_cert.close
@ssl_key.close
@ssl_csr.close
Process::kill("KILL", @lumberjack_pid)
Process::wait(@lumberjack_pid)
Process::kill("KILL", @lumberjack.pid)
Process::wait(@lumberjack.pid)
end
it "should follow stdin" do
......@@ -50,12 +46,12 @@ describe "lumberjack" do
message = "hello world foo bar baz fizz=lkjwelfkj"
Thread.new do
count.times do |i|
@writer.puts("#{message} #{i}")
@lumberjack.puts("#{message} #{i}")
# random sleep 0.01% of the time
sleep(rand) if rand < 0.0001
end
@writer.close
@lumberjack.close
end
# Now verify that we have all the data and in the correct order.
......
......@@ -21,10 +21,10 @@ describe "lumberjack" do
:ssl_certificate => @ssl_cert.path,
:ssl_key => @ssl_key.path
)
@lumberjack_pid = fork do
exec("build/bin/lumberjack --host localhost --port #{@server.port} " \
"--ssl-ca-path #{@ssl_cert.path} #{@file.path}")
end
@lumberjack = IO.popen("build/bin/lumberjack --host localhost " \
"--port #{@server.port} " \
"--ssl-ca-path #{@ssl_cert.path} #{@file.path}",
"r")
@event_queue = Queue.new
@server_thread = Thread.new do
......@@ -39,8 +39,8 @@ describe "lumberjack" do
@ssl_cert.close
@ssl_key.close
@ssl_csr.close
Process::kill("KILL", @lumberjack_pid)
Process::wait(@lumberjack_pid)
Process::kill("KILL", @lumberjack.pid)
Process::wait(@lumberjack.pid)
end
it "should follow a file and emit lines as events" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment