Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 1 | require 'rubygems' |
| 2 | require 'rake' |
| 3 | require 'spec/rake/spectask' |
| 4 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 5 | THRIFT = '../../compiler/cpp/thrift' |
| 6 | |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 7 | task :default => [:spec, :test] |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 8 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 9 | Spec::Rake::SpecTask.new do |t| |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 10 | t.spec_files = FileList['spec/**/*_spec.rb'] |
| 11 | t.spec_opts = ['--color'] |
| 12 | end |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 13 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 14 | Spec::Rake::SpecTask.new(:'spec:rcov') do |t| |
Kevin Clark | eb0dd7f | 2008-06-18 01:12:15 +0000 | [diff] [blame] | 15 | t.spec_files = FileList['spec/**/*_spec.rb'] |
| 16 | t.spec_opts = ['--color'] |
| 17 | t.rcov = true |
| 18 | t.rcov_opts = ['--exclude', '^spec,/gems/'] |
| 19 | end |
| 20 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 21 | desc 'Run the compiler tests (requires full thrift checkout)' |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 22 | task :test do |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 23 | # 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 Clark | a7613dd | 2008-06-18 01:13:48 +0000 | [diff] [blame] | 26 | sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb" |
| 27 | end |
| 28 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 29 | desc 'Compile the .thrift files for the specs' |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 30 | task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark'] |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 31 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 32 | namespace :'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 Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 37 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame^] | 38 | task :'benchmark' do |
| 39 | dir = File.dirname(__FILE__) + '/benchmark' |
| 40 | sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift" |
| 41 | end |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 42 | end |
| 43 | |
| 44 | desc 'Run benchmarking of NonblockingServer' |
| 45 | task :benchmark do |
Kevin Clark | d3cee02 | 2008-06-18 01:19:09 +0000 | [diff] [blame] | 46 | ruby 'benchmark/benchmark.rb' |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 47 | end |