forked from ZhangHanDong/rhosync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
executable file
·91 lines (77 loc) · 2.34 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'rubygems'
require 'bundler/setup'
# Bundler.setup (:default, :development)
require 'yaml'
$:.unshift File.join(File.dirname(__FILE__),'lib')
require 'rhosync'
task :default => 'spec:all'
task :spec => 'spec:spec'
begin
require 'rspec/core/rake_task'
require 'rcov/rcovtask'
TYPES = {
:spec => 'spec/*_spec.rb',
:perf => 'spec/perf/*_spec.rb',
:server => 'spec/server/*_spec.rb',
:api => 'spec/api/*_spec.rb',
:bulk => 'spec/bulk_data/*_spec.rb',
:jobs => 'spec/jobs/*_spec.rb',
:stats => 'spec/stats/*_spec.rb',
:ping => 'spec/ping/*_spec.rb',
:generator => 'spec/generator/*_spec.rb',
:bench => 'bench/spec/*_spec.rb'
}
TYPES.each do |type,files|
desc "Run specs in #{files}"
RSpec::Core::RakeTask.new("spec:#{type}") do |t|
t.rspec_opts = ["-b", "-c", "-fd"]
t.pattern = FileList[TYPES[type]]
end
end
desc "Run specs in spec/**/*_spec.rb "
RSpec::Core::RakeTask.new('spec:all') do |t|
t.rspec_opts = ["-b", "-c", "-fd"]
t.pattern = FileList[TYPES.values]
t.rcov = true
t.rcov_opts = ['--exclude', 'spec/*,gems/*,apps/*,bench/spec/*,json/*']
end
desc "Run doc generator - dumps out doc/protocol.html"
RSpec::Core::RakeTask.new('doc') do |t|
t.pattern = FileList['spec/doc/*_spec.rb']
t.rcov = false
end
rescue LoadError => e
puts "rspec / rcov not available. Install with: "
puts "gem install rspec rcov\n\n"
end
# desc "Build rhosync gem"
# task :gem => [ 'spec:all', 'clobber_spec:all', :gemspec, :build ]
desc "Load console environment"
task :console do
if RedisRunner.running?
sh "irb -rubygems -r #{File.join(File.dirname(__FILE__),'lib','rhosync','server.rb')}"
else
puts "Redis is not running. Please start it by running 'rake redis:start' command."
end
end
desc "Run benchmark scripts"
task :bench do
login = ask "login: "
password = ask "password: "
prefix = 'bench/scripts/'
suffix = '_script.rb'
list = ask "scripts(default is '*'): "
file_list = list.empty? ? FileList[prefix+'*'+suffix] : FileList[prefix+list+suffix]
file_list.each do |script|
sh "bench/bench start #{script} #{login} #{password}"
end
end
def ask(msg)
print msg
STDIN.gets.chomp
end
# def bundle_exec(cmd)
# system "bundle exec #{cmd}"
# end
load 'tasks/redis.rake'
Bundler::GemHelper.install_tasks