Skip to content

Commit 5a50b7a

Browse files
committed
Use MiniTest's built in after-test hooks
In 2fa18ac I made the following change: -require 'test/unit' +require 'minitest/unit' This had the unintended consequence of running the test suite twice! (Even weirder, that *only* happened on 1.9.2 and JRuby in 1.9 mode o_O) Since the tests don't presently clean up after themselves or initialize Redis into a clean state, this broke the build because the second test run would fail. Tenderlove recommened replacing the existing wonky at_exit handler with a proper MiniTest::Unit.after_test hook and it fixed the problem. Plus it's waaaay less wonky ;)
1 parent f79aef4 commit 5a50b7a

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

test/test_helper.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require 'rubygems'
2+
require 'bundler/setup'
3+
require 'minitest/autorun'
4+
require 'redis/namespace'
25

36
$dir = File.dirname(File.expand_path(__FILE__))
47
$LOAD_PATH.unshift $dir + '/../lib'
5-
$TESTING = true
6-
require 'minitest/unit'
7-
8-
require 'redis/namespace'
98
require 'resque'
9+
$TESTING = true
1010

1111
begin
1212
require 'leftright'
@@ -30,21 +30,12 @@
3030
# kill it when they end
3131
#
3232

33-
at_exit do
34-
next if $!
35-
36-
if defined?(MiniTest)
37-
exit_code = MiniTest::Unit.new.run(ARGV)
38-
else
39-
exit_code = Test::Unit::AutoRunner.run
40-
end
41-
33+
MiniTest::Unit.after_tests do
4234
processes = `ps -A -o pid,command | grep [r]edis-test`.split("\n")
4335
pids = processes.map { |process| process.split(" ")[0] }
4436
puts "Killing test redis server..."
4537
pids.each { |pid| Process.kill("TERM", pid.to_i) }
4638
system("rm -f #{$dir}/dump.rdb #{$dir}/dump-cluster.rdb")
47-
exit exit_code
4839
end
4940

5041
if ENV.key? 'RESQUE_DISTRIBUTED'

0 commit comments

Comments
 (0)