blob: 02af9a84b8e6d2337cecfbd3d15f6cd99d6793a9 [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'
Tim Emiolaf20d7602015-03-24 08:11:47 -07005require 'bundler/gem_tasks'
nnoble097ef9b2014-12-01 17:06:10 -08006
Tim Emiolaf20d7602015-03-24 08:11:47 -07007# Add rubocop style checking tasks
Tim Emiolae2860c52015-01-16 02:58:41 -08008RuboCop::RakeTask.new
nnoble097ef9b2014-12-01 17:06:10 -08009
Tim Emiolaf20d7602015-03-24 08:11:47 -070010# Add the extension compiler task
nnoble097ef9b2014-12-01 17:06:10 -080011Rake::ExtensionTask.new 'grpc' do |ext|
12 ext.lib_dir = File.join('lib', 'grpc')
13end
14
Tim Emiolaf20d7602015-03-24 08:11:47 -070015# Define the test suites
nnoble097ef9b2014-12-01 17:06:10 -080016SPEC_SUITES = [
Tim Emiolae2860c52015-01-16 02:58:41 -080017 { id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) },
18 { id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic),
Tim Emiola397fda02015-01-29 13:26:21 -080019 tags: ['~bidi', '~server'] },
Tim Emiolae2860c52015-01-16 02:58:41 -080020 { id: :bidi, title: 'bidi tests', dir: %w(spec/generic),
Tim Emiola397fda02015-01-29 13:26:21 -080021 tag: 'bidi' },
22 { id: :server, title: 'rpc server thread tests', dir: %w(spec/generic),
23 tag: 'server' }
nnoble097ef9b2014-12-01 17:06:10 -080024]
Tim Emiolaf20d7602015-03-24 08:11:47 -070025namespace :suite do
26 SPEC_SUITES.each do |suite|
27 desc "Run all specs in the #{suite[:title]} spec suite"
28 RSpec::Core::RakeTask.new(suite[:id]) do |t|
Tim Emiolac85c1ae2015-04-17 18:12:32 -070029 ENV['COVERAGE_NAME'] = suite[:id].to_s
Tim Emiolaf20d7602015-03-24 08:11:47 -070030 spec_files = []
31 suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
nnoble097ef9b2014-12-01 17:06:10 -080032
Tim Emiolaf20d7602015-03-24 08:11:47 -070033 if suite[:dir]
34 suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
35 end
36 helper = 'spec/spec_helper.rb'
37 spec_files << helper unless spec_files.include?(helper)
nnoble097ef9b2014-12-01 17:06:10 -080038
Tim Emiolaf20d7602015-03-24 08:11:47 -070039 t.pattern = spec_files
40 t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
41 if suite[:tags]
42 t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
nnoble097ef9b2014-12-01 17:06:10 -080043 end
44 end
45 end
46end
47
Tim Emiolaf20d7602015-03-24 08:11:47 -070048# Define dependencies between the suites.
49task 'suite:wrapper' => [:compile, :rubocop]
50task 'suite:idiomatic' => 'suite:wrapper'
51task 'suite:bidi' => 'suite:wrapper'
52task 'suite:server' => 'suite:wrapper'
Tim Emiola397fda02015-01-29 13:26:21 -080053
Tim Emiolaf20d7602015-03-24 08:11:47 -070054desc 'Compiles the gRPC extension then runs all the tests'
55task all: ['suite:idiomatic', 'suite:bidi', 'suite:server']
Tim Emiola397fda02015-01-29 13:26:21 -080056task default: :all