diff --git a/test/helper.rb b/test/helper.rb index 0ab6f2fa0..ef5af88d3 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -37,10 +37,6 @@ ENV['REDIS_SOCKET_PATH'] = sock_file end -def driver(*drivers, &blk) - class_eval(&blk) if drivers.map(&:to_s).include?(ENV["DRIVER"]) -end - Dir[File.expand_path('lint/**/*.rb', __dir__)].sort.each do |f| require f end diff --git a/test/redis/fork_safety_test.rb b/test/redis/fork_safety_test.rb index 66326a649..4e45a801d 100644 --- a/test/redis/fork_safety_test.rb +++ b/test/redis/fork_safety_test.rb @@ -9,49 +9,47 @@ def setup skip("Fork unavailable") unless Process.respond_to?(:fork) end - driver(:ruby, :hiredis) do - def test_fork_safety - redis = Redis.new(OPTIONS) - redis.set "foo", 1 - - child_pid = fork do - # InheritedError triggers a reconnect, - # so we need to disable reconnects to force - # the exception bubble up - redis.without_reconnect do - redis.set "foo", 2 - end - exit! 0 - rescue Redis::InheritedError - exit! 127 + def test_fork_safety + redis = Redis.new(OPTIONS) + redis.set "foo", 1 + + child_pid = fork do + # InheritedError triggers a reconnect, + # so we need to disable reconnects to force + # the exception bubble up + redis.without_reconnect do + redis.set "foo", 2 end + exit! 0 + rescue Redis::InheritedError + exit! 127 + end - _, status = Process.wait2(child_pid) + _, status = Process.wait2(child_pid) - assert_equal 127, status.exitstatus - assert_equal "1", redis.get("foo") - end + assert_equal 127, status.exitstatus + assert_equal "1", redis.get("foo") + end - def test_fork_safety_with_enabled_inherited_socket - redis = Redis.new(OPTIONS.merge(inherit_socket: true)) - redis.set "foo", 1 - - child_pid = fork do - # InheritedError triggers a reconnect, - # so we need to disable reconnects to force - # the exception bubble up - redis.without_reconnect do - redis.set "foo", 2 - end - exit! 0 - rescue Redis::InheritedError - exit! 127 + def test_fork_safety_with_enabled_inherited_socket + redis = Redis.new(OPTIONS.merge(inherit_socket: true)) + redis.set "foo", 1 + + child_pid = fork do + # InheritedError triggers a reconnect, + # so we need to disable reconnects to force + # the exception bubble up + redis.without_reconnect do + redis.set "foo", 2 end + exit! 0 + rescue Redis::InheritedError + exit! 127 + end - _, status = Process.wait2(child_pid) + _, status = Process.wait2(child_pid) - assert_equal 0, status.exitstatus - assert_equal "2", redis.get("foo") - end + assert_equal 0, status.exitstatus + assert_equal "2", redis.get("foo") end end diff --git a/test/redis/internals_test.rb b/test/redis/internals_test.rb index a3dcb513e..93d5bdb2c 100644 --- a/test/redis/internals_test.rb +++ b/test/redis/internals_test.rb @@ -214,18 +214,16 @@ def test_connecting_to_unix_domain_socket Redis.new(OPTIONS.merge(path: ENV.fetch("REDIS_SOCKET_PATH"))).ping end - driver(:ruby, :hiredis) do - def test_bubble_timeout_without_retrying - serv = TCPServer.new(6380) + def test_bubble_timeout_without_retrying + serv = TCPServer.new(6380) - redis = Redis.new(port: 6380, timeout: 0.1) + redis = Redis.new(port: 6380, timeout: 0.1) - assert_raises(Redis::TimeoutError) do - redis.ping - end - ensure - serv&.close + assert_raises(Redis::TimeoutError) do + redis.ping end + ensure + serv&.close end def test_client_options @@ -282,19 +280,15 @@ def af_test(host) redis_mock(commands, host: host, &:ping) end - driver(:ruby) do - af_family_supported(Socket::AF_INET) do - def test_connect_ipv4 - af_test("127.0.0.1") - end + af_family_supported(Socket::AF_INET) do + def test_connect_ipv4 + af_test("127.0.0.1") end end - driver(:ruby) do - af_family_supported(Socket::AF_INET6) do - def test_connect_ipv6 - af_test("::1") - end + af_family_supported(Socket::AF_INET6) do + def test_connect_ipv6 + af_test("::1") end end diff --git a/test/redis/thread_safety_test.rb b/test/redis/thread_safety_test.rb index c5de0375c..57ec5e9c4 100644 --- a/test/redis/thread_safety_test.rb +++ b/test/redis/thread_safety_test.rb @@ -5,27 +5,25 @@ class TestThreadSafety < Minitest::Test include Helper::Client - driver(:ruby, :hiredis) do - def test_thread_safety - redis = Redis.new(OPTIONS) - redis.set "foo", 1 - redis.set "bar", 2 + def test_thread_safety + redis = Redis.new(OPTIONS) + redis.set "foo", 1 + redis.set "bar", 2 - sample = 100 + sample = 100 - t1 = Thread.new do - @foos = Array.new(sample) { redis.get "foo" } - end + t1 = Thread.new do + @foos = Array.new(sample) { redis.get "foo" } + end - t2 = Thread.new do - @bars = Array.new(sample) { redis.get "bar" } - end + t2 = Thread.new do + @bars = Array.new(sample) { redis.get "bar" } + end - t1.join - t2.join + t1.join + t2.join - assert_equal ["1"], @foos.uniq - assert_equal ["2"], @bars.uniq - end + assert_equal ["1"], @foos.uniq + assert_equal ["2"], @bars.uniq end end