test/test_helper.rb in resque-lock-timeout-0.3.3 vs test/test_helper.rb in resque-lock-timeout-0.4.0
- old
+ new
@@ -3,38 +3,41 @@
$TESTING = true
require 'rubygems'
require 'minitest/unit'
require 'minitest/pride'
-require 'simplecov'
-SimpleCov.start do
- add_filter '/test/'
-end unless RUBY_PLATFORM == 'java'
+# Run code coverage in MRI 1.9 only.
+if RUBY_VERSION >= '1.9' && RUBY_ENGINE == 'ruby'
+ require 'simplecov'
+ SimpleCov.start do
+ add_filter '/test/'
+ end
+end
require 'resque-lock-timeout'
require dir + '/test_jobs'
-# make sure we can run redis
+# make sure we can run redis-server
if !system('which redis-server')
- puts '', "** can't find `redis-server` in your path"
- puts '** try running `sudo rake install`'
+ puts '', "** `redis-server` was not found in your PATH"
abort ''
end
-# start our own redis when the tests start,
-# kill it when they end
+# make sure we can shutdown the server using cli.
+if !system('which redis-cli')
+ puts '', "** `redis-cli` was not found in your PATH"
+ abort ''
+end
+
+# This code is run `at_exit` to setup everything before running the tests.
+# Redis server is started before this code block runs.
at_exit do
next if $!
exit_code = MiniTest::Unit.new.run(ARGV)
-
- pid = `ps -e -o pid,command | grep [r]edis-test`.split(' ')[0]
- puts 'Killing test redis server...'
- `rm -f #{dir}/dump.rdb`
- `kill -9 #{pid}`
- exit(exit_code)
+ `redis-cli -p 9737 shutdown nosave`
end
-puts 'Starting redis for testing at localhost:9736...'
+puts "Starting redis for testing at localhost:9737..."
`redis-server #{dir}/redis-test.conf`
-Resque.redis = '127.0.0.1:9736'
\ No newline at end of file
+Resque.redis = '127.0.0.1:9737'