blob: 9a8019589c9e16313face20977965db96f248bd0 [file] [log] [blame]
Kevin Clark5a7103a2008-06-18 00:55:11 +00001require 'rubygems'
2require 'rake'
3require 'spec/rake/spectask'
4
Kevin Clarkc06b0152008-06-24 01:05:57 +00005THRIFT = '../../compiler/cpp/thrift'
6
Kevin Clarkc2a07b12008-06-18 00:57:06 +00007task :default => [:spec, :test]
Kevin Clark5a7103a2008-06-18 00:55:11 +00008
Kevin Clarkc06b0152008-06-24 01:05:57 +00009Spec::Rake::SpecTask.new do |t|
Kevin Clark5a7103a2008-06-18 00:55:11 +000010 t.spec_files = FileList['spec/**/*_spec.rb']
11 t.spec_opts = ['--color']
12end
Kevin Clarkc2a07b12008-06-18 00:57:06 +000013
Kevin Clarkc06b0152008-06-24 01:05:57 +000014Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
Kevin Clarkeb0dd7f2008-06-18 01:12:15 +000015 t.spec_files = FileList['spec/**/*_spec.rb']
16 t.spec_opts = ['--color']
17 t.rcov = true
18 t.rcov_opts = ['--exclude', '^spec,/gems/']
19end
20
Kevin Clarkc06b0152008-06-24 01:05:57 +000021desc 'Run the compiler tests (requires full thrift checkout)'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000022task :test do
Kevin Clarkc06b0152008-06-24 01:05:57 +000023 # ensure this is a full thrift checkout and not a tarball of the ruby libs
24 cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
25 system(cmd) or fail "rake test requires a full thrift checkout"
Kevin Clarka7613dd2008-06-18 01:13:48 +000026 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb"
27end
28
Kevin Clarkca8a1b32008-06-18 01:17:06 +000029desc 'Compile the .thrift files for the specs'
Kevin Clarkc06b0152008-06-24 01:05:57 +000030task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark']
Kevin Clarkca8a1b32008-06-18 01:17:06 +000031
Kevin Clarkc06b0152008-06-24 01:05:57 +000032namespace :'gen-rb' do
33 task :'spec' do
34 dir = File.dirname(__FILE__) + '/spec'
35 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/ThriftSpec.thrift"
36 end
Kevin Clarkca8a1b32008-06-18 01:17:06 +000037
Kevin Clarkc06b0152008-06-24 01:05:57 +000038 task :'benchmark' do
39 dir = File.dirname(__FILE__) + '/benchmark'
40 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
41 end
Kevin Clarkca8a1b32008-06-18 01:17:06 +000042end
43
44desc 'Run benchmarking of NonblockingServer'
45task :benchmark do
Kevin Clarkd3cee022008-06-18 01:19:09 +000046 ruby 'benchmark/benchmark.rb'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000047end