blob: 6ba9a97c893fb3692c8abe91718d75fa1d11bacf [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),
16 tag: '~bidi' },
17 { id: :bidi, title: 'bidi tests', dir: %w(spec/generic),
18 tag: 'bidi' }
nnoble097ef9b2014-12-01 17:06:10 -080019]
20
Tim Emiolae2860c52015-01-16 02:58:41 -080021desc 'Run all RSpec tests'
nnoble097ef9b2014-12-01 17:06:10 -080022namespace :spec do
23 namespace :suite do
24 SPEC_SUITES.each do |suite|
25 desc "Run all specs in #{suite[:title]} spec suite"
26 RSpec::Core::RakeTask.new(suite[:id]) do |t|
27 spec_files = []
Tim Emiolae2860c52015-01-16 02:58:41 -080028 suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
nnoble097ef9b2014-12-01 17:06:10 -080029
30 if suite[:dirs]
31 suite[:dirs].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
32 end
33
34 t.pattern = spec_files
Tim Emiolae2860c52015-01-16 02:58:41 -080035 t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
nnoble097ef9b2014-12-01 17:06:10 -080036 end
37 end
38 end
39end
40
Tim Emiolae2860c52015-01-16 02:58:41 -080041task default: 'spec:suite:idiomatic' # this should be spec:suite:bidi
42task 'spec:suite:wrapper' => :compile
43task 'spec:suite:idiomatic' => 'spec:suite:wrapper'
44task 'spec:suite:bidi' => 'spec:suite:idiomatic'