Skip to content

Commit 6c2119a

Browse files
committed
Explicitly skip tests that don't match the Redis version.
1 parent 0c76a9f commit 6c2119a

16 files changed

+52
-48
lines changed

test/commands_on_strings_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_msetnx_mapped
8282
end
8383

8484
def test_bitop
85-
return if version < "2.5.10"
85+
target_version "2.5.10"
8686

8787
r.set("foo", "a")
8888
r.set("bar", "b")

test/distributed_commands_on_strings_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_msetnx_mapped
4747
end
4848

4949
def test_bitop
50-
return if version < "2.5.10"
50+
target_version "2.5.10"
5151

5252
assert_raise Redis::Distributed::CannotDistribute do
5353
r.set("foo", "a")

test/distributed_commands_requiring_clustering_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_sort_with_store
147147
end
148148

149149
def test_bitop
150-
return if version < "2.5.10"
150+
target_version "2.5.10"
151151

152152
r.set("{qux}foo", "a")
153153
r.set("{qux}bar", "b")

test/distributed_remote_server_control_commands_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_info
2828
end
2929

3030
def test_info_commandstats
31-
return if version < "2.5.7"
31+
target_version "2.5.7"
3232

3333
r.nodes.each { |n| n.config(:resetstat) }
3434
r.ping # Executed on every node
@@ -52,7 +52,7 @@ def test_echo
5252
end
5353

5454
def test_time
55-
return if version < "2.5.4"
55+
target_version "2.5.4"
5656

5757
# Test that the difference between the time that Ruby reports and the time
5858
# that Redis reports is minimal (prevents the test from being racy).

test/distributed_scripting_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def to_sha(script)
1111
end
1212

1313
def test_script_exists
14-
return if version < "2.5.9" # 2.6-rc1
14+
target_version "2.5.9" # 2.6-rc1
1515

1616
a = to_sha("return 1")
1717
b = a.succ
@@ -24,7 +24,7 @@ def test_script_exists
2424
end
2525

2626
def test_script_flush
27-
return if version < "2.5.9" # 2.6-rc1
27+
target_version "2.5.9" # 2.6-rc1
2828

2929
sha = to_sha("return 1")
3030
assert r.script(:exists, sha).first
@@ -33,15 +33,15 @@ def test_script_flush
3333
end
3434

3535
def test_script_kill
36-
return if version < "2.5.9" # 2.6-rc1
36+
target_version "2.5.9" # 2.6-rc1
3737

3838
redis_mock(:script => lambda { |arg| "+#{arg.upcase}" }) do |redis|
3939
assert_equal ["KILL"], redis.script(:kill)
4040
end
4141
end
4242

4343
def test_eval
44-
return if version < "2.5.9" # 2.6-rc1
44+
target_version "2.5.9" # 2.6-rc1
4545

4646
assert_raises(Redis::Distributed::CannotDistribute) do
4747
r.eval("return #KEYS")
@@ -56,7 +56,7 @@ def test_eval
5656
end
5757

5858
def test_eval_with_options_hash
59-
return if version < "2.5.9" # 2.6-rc1
59+
target_version "2.5.9" # 2.6-rc1
6060

6161
assert_raises(Redis::Distributed::CannotDistribute) do
6262
r.eval("return #KEYS", {})
@@ -71,7 +71,7 @@ def test_eval_with_options_hash
7171
end
7272

7373
def test_evalsha
74-
return if version < "2.5.9" # 2.6-rc1
74+
target_version "2.5.9" # 2.6-rc1
7575

7676
assert_raises(Redis::Distributed::CannotDistribute) do
7777
r.evalsha(to_sha("return #KEYS"))
@@ -86,7 +86,7 @@ def test_evalsha
8686
end
8787

8888
def test_evalsha_with_options_hash
89-
return if version < "2.5.9" # 2.6-rc1
89+
target_version "2.5.9" # 2.6-rc1
9090

9191
assert_raises(Redis::Distributed::CannotDistribute) do
9292
r.evalsha(to_sha("return #KEYS"), {})

test/helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ def redis_mock_with_handler(handler, options = {}, &blk)
153153
def assert_in_range(range, value)
154154
assert range.include?(value), "expected #{value} to be in #{range.inspect}"
155155
end
156+
157+
def target_version(target)
158+
skip("Requires Redis > #{target}") if version < target
159+
end
156160
end
157161

158162
module Client

test/internals_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_tcp_keepalive
128128
end
129129

130130
def test_time
131-
return if version < "2.5.4"
131+
target_version "2.5.4"
132132

133133
# Test that the difference between the time that Ruby reports and the time
134134
# that Redis reports is minimal (prevents the test from being racy).

test/lint/hashes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_hdel
3131
end
3232

3333
def test_variadic_hdel
34-
return if version < "2.3.9"
34+
target_version "2.3.9"
3535

3636
r.hset("foo", "f1", "s1")
3737
r.hset("foo", "f2", "s2")
@@ -144,7 +144,7 @@ def test_hincrby
144144
end
145145

146146
def test_hincrbyfloat
147-
return if version < "2.5.4"
147+
target_version "2.5.4"
148148

149149
r.hincrbyfloat("foo", "f1", 1.23)
150150

test/lint/lists.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_lpush
1111
end
1212

1313
def test_variadic_lpush
14-
return if version < "2.3.9" # 2.4-rc6
14+
target_version "2.3.9" # 2.4-rc6
1515

1616
assert_equal 3, r.lpush("foo", ["s1", "s2", "s3"])
1717
assert_equal 3, r.llen("foo")
@@ -36,7 +36,7 @@ def test_rpush
3636
end
3737

3838
def test_variadic_rpush
39-
return if version < "2.3.9" # 2.4-rc6
39+
target_version "2.3.9" # 2.4-rc6
4040

4141
assert_equal 3, r.rpush("foo", ["s1", "s2", "s3"])
4242
assert_equal 3, r.llen("foo")

test/lint/sets.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_sadd
1111
end
1212

1313
def test_variadic_sadd
14-
return if version < "2.3.9" # 2.4-rc6
14+
target_version "2.3.9" # 2.4-rc6
1515

1616
assert_equal 2, r.sadd("foo", ["s1", "s2"])
1717
assert_equal 1, r.sadd("foo", ["s1", "s2", "s3"])
@@ -30,7 +30,7 @@ def test_srem
3030
end
3131

3232
def test_variadic_srem
33-
return if version < "2.3.9" # 2.4-rc6
33+
target_version "2.3.9" # 2.4-rc6
3434

3535
r.sadd("foo", "s1")
3636
r.sadd("foo", "s2")

0 commit comments

Comments
 (0)