Skip to content

Commit da0ca58

Browse files
committed
Merge pull request #443 from redis/issue-439/use-absolute-paths-for-redis-config-directives
test-config: dynamically build test.conf to provide absolute paths
2 parents bb119a3 + cbe30a5 commit da0ca58

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ Gemfile.lock
1313
/rdsrv
1414
/redis/*
1515
/test/db
16+
/test/test.conf

Rakefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ ENV["REDIS_BRANCH"] ||= "unstable"
44

55
REDIS_DIR = File.expand_path(File.join("..", "test"), __FILE__)
66
REDIS_CNF = File.join(REDIS_DIR, "test.conf")
7+
REDIS_CNF_TEMPLATE = File.join(REDIS_DIR, "test.conf.erb")
78
REDIS_PID = File.join(REDIS_DIR, "db", "redis.pid")
9+
REDIS_LOG = File.join(REDIS_DIR, "db", "redis.log")
10+
REDIS_SOCKET = File.join(REDIS_DIR, "db", "redis.sock")
811
BINARY = "tmp/redis-#{ENV["REDIS_BRANCH"]}/src/redis-server"
912

1013
task :default => :run
@@ -13,7 +16,7 @@ desc "Run tests and manage server start/stop"
1316
task :run => [:start, :test, :stop]
1417

1518
desc "Start the Redis server"
16-
task :start => BINARY do
19+
task :start => [BINARY, REDIS_CNF] do
1720
sh "#{BINARY} --version"
1821

1922
redis_running = \
@@ -46,6 +49,7 @@ end
4649
desc "Clean up testing artifacts"
4750
task :clean do
4851
FileUtils.rm_f(BINARY)
52+
FileUtils.rm_f(REDIS_CNF)
4953
end
5054

5155
file BINARY do
@@ -62,6 +66,21 @@ file BINARY do
6266
SH
6367
end
6468

69+
file REDIS_CNF => [REDIS_CNF_TEMPLATE, __FILE__] do |t|
70+
require 'erb'
71+
72+
erb = t.prerequisites[0]
73+
template = File.read(erb)
74+
75+
File.open(REDIS_CNF, 'w') do |file|
76+
file.puts "\# This file was auto-generated at #{Time.now}",
77+
"\# from (#{erb})",
78+
"\#"
79+
conf = ERB.new(template).result
80+
file << conf
81+
end
82+
end
83+
6584
Rake::TestTask.new do |t|
6685
t.options = "-v" if $VERBOSE
6786
t.test_files = FileList["test/*_test.rb"]

test/test.conf

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/test.conf.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dir <%= REDIS_DIR %>
2+
pidfile <%= REDIS_PID %>
3+
port 6381
4+
unixsocket <%= REDIS_SOCKET %>
5+
timeout 300
6+
loglevel debug
7+
logfile <%= REDIS_LOG %>
8+
databases 16
9+
daemonize yes

0 commit comments

Comments
 (0)