Skip to content

Commit 351a129

Browse files
committed
Automatically install and run the version specified by REDIS_BRANCH.
1 parent 13cfce9 commit 351a129

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Rakefile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@ require 'rubygems'
22
require 'rubygems/package_task'
33
require 'rake/testtask'
44

5+
ENV["REDIS_BRANCH"] ||= "unstable"
6+
57
$:.unshift File.join(File.dirname(__FILE__), 'lib')
68
require 'redis/version'
79

810
REDIS_DIR = File.expand_path(File.join("..", "test"), __FILE__)
911
REDIS_CNF = File.join(REDIS_DIR, "test.conf")
1012
REDIS_PID = File.join(REDIS_DIR, "db", "redis.pid")
13+
BINARY = "tmp/redis-#{ENV["REDIS_BRANCH"]}/src/redis-server"
1114

1215
task :default => :run
1316

1417
desc "Run tests and manage server start/stop"
1518
task :run => [:start, :test, :stop]
1619

1720
desc "Start the Redis server"
18-
task :start do
21+
task :start => BINARY do
22+
sh "#{BINARY} --version"
23+
1924
redis_running = \
2025
begin
2126
File.exists?(REDIS_PID) && Process.kill(0, File.read(REDIS_PID).to_i)
@@ -25,11 +30,7 @@ task :start do
2530
end
2631

2732
unless redis_running
28-
unless system("which redis-server > /dev/null")
29-
abort "redis-server not in PATH"
30-
end
31-
32-
unless system("redis-server #{REDIS_CNF}")
33+
unless system("#{BINARY} #{REDIS_CNF}")
3334
abort "could not start redis-server"
3435
end
3536
end
@@ -43,6 +44,19 @@ task :stop do
4344
end
4445
end
4546

47+
file BINARY do
48+
branch = ENV.fetch("REDIS_BRANCH")
49+
50+
sh <<-SH
51+
mkdir -p tmp;
52+
cd tmp;
53+
wget https://github.com/antirez/redis/archive/#{branch}.tar.gz -O #{branch}.tar.gz;
54+
tar xf #{branch}.tar.gz;
55+
cd redis-#{branch};
56+
make
57+
SH
58+
end
59+
4660
Rake::TestTask.new do |t|
4761
t.options = "-v"
4862
t.test_files = FileList["test/*_test.rb"]

0 commit comments

Comments
 (0)