Skip to content

Commit

Permalink
tests: sync "kill test server" code with resque
Browse files Browse the repository at this point in the history
Copy the logic from Resque's test/legacy/test_helper.rb.This allows
Travis CI to properly kill the test redis server.
  • Loading branch information
ktdreyer committed May 27, 2014
1 parent bb2b214 commit b6119d9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/test_helper.rb
Expand Up @@ -18,6 +18,8 @@
require 'resque'
require 'resque_cleaner'

$TEST_PID = Process.pid

#
# make sure we can run redis
#
Expand All @@ -34,11 +36,14 @@
# kill it when they end
#
MiniTest.after_run {
pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0]
puts "Killing test redis server..."
Process.kill("KILL", pid.to_i)
dump = "test/dump.rdb"
File.delete(dump) if File.exist?(dump)
if Process.pid == $TEST_PID
processes = `ps -A -o pid,command | grep [r]edis-test`.split($/)
pids = processes.map { |process| process.split(" ")[0] }
puts "Killing test redis server..."
pids.each { |pid| Process.kill("TERM", pid.to_i) }
dump = "test/dump.rdb"
File.delete(dump) if File.exist?(dump)
end
}

puts "Starting redis for testing at localhost:9736..."
Expand Down

0 comments on commit b6119d9

Please sign in to comment.