blob: 5fc325ef0eb2b6f15ca53d3d8d4008bdc6a554cc [file] [log] [blame]
nnoble097ef9b2014-12-01 17:06:10 -08001# -*- ruby -*-
2require 'rake/extensiontask'
3require 'rspec/core/rake_task'
Tim Emiolae2860c52015-01-16 02:58:41 -08004require 'rubocop/rake_task'
nnoble097ef9b2014-12-01 17:06:10 -08005
Tim Emiolae2860c52015-01-16 02:58:41 -08006desc 'Run Rubocop to check for style violations'
7RuboCop::RakeTask.new
nnoble097ef9b2014-12-01 17:06:10 -08008
9Rake::ExtensionTask.new 'grpc' do |ext|
10 ext.lib_dir = File.join('lib', 'grpc')
11end
12
13SPEC_SUITES = [
Tim Emiolae2860c52015-01-16 02:58:41 -080014 { id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) },
15 { id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic),
Tim Emiola397fda02015-01-29 13:26:21 -080016 tags: ['~bidi', '~server'] },
Tim Emiolae2860c52015-01-16 02:58:41 -080017 { id: :bidi, title: 'bidi tests', dir: %w(spec/generic),
Tim Emiola397fda02015-01-29 13:26:21 -080018 tag: 'bidi' },
19 { id: :server, title: 'rpc server thread tests', dir: %w(spec/generic),
20 tag: 'server' }
nnoble097ef9b2014-12-01 17:06:10 -080021]
22
Tim Emiolae2860c52015-01-16 02:58:41 -080023desc 'Run all RSpec tests'
nnoble097ef9b2014-12-01 17:06:10 -080024namespace :spec do
25 namespace :suite do
26 SPEC_SUITES.each do |suite|
27 desc "Run all specs in #{suite[:title]} spec suite"
28 RSpec::Core::RakeTask.new(suite[:id]) do |t|
29 spec_files = []
Tim Emiolae2860c52015-01-16 02:58:41 -080030 suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
nnoble097ef9b2014-12-01 17:06:10 -080031
32 if suite[:dirs]
33 suite[:dirs].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
34 end
35
36 t.pattern = spec_files
Tim Emiolae2860c52015-01-16 02:58:41 -080037 t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
Tim Emiola397fda02015-01-29 13:26:21 -080038 t.rspec_opts = suite[:tags].map{ |t| "--tag #{t}" }.join(' ') if suite[:tags]
nnoble097ef9b2014-12-01 17:06:10 -080039 end
40 end
41 end
42end
43
Tim Emiola397fda02015-01-29 13:26:21 -080044desc 'Run compiles the extension, runs all the tests'
45task :all
46
47task default: :all
Tim Emiolae2860c52015-01-16 02:58:41 -080048task 'spec:suite:wrapper' => :compile
49task 'spec:suite:idiomatic' => 'spec:suite:wrapper'
Tim Emiola397fda02015-01-29 13:26:21 -080050task 'spec:suite:bidi' => 'spec:suite:wrapper'
51task 'spec:suite:server' => 'spec:suite:wrapper'
52task :all => ['spec:suite:idiomatic', 'spec:suite:bidi', 'spec:suite:server']