blob: cc7832b12d2e26e8c3dd23de637b2a4a6ec0b800 [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),
Tim Emiola975d0cb2015-08-14 10:44:17 -070023 tag: 'server' },
24 { id: :pb, title: 'protobuf service tests', dir: %w(spec/pb) }
nnoble097ef9b2014-12-01 17:06:10 -080025]
Tim Emiolaf20d7602015-03-24 08:11:47 -070026namespace :suite do
27 SPEC_SUITES.each do |suite|
28 desc "Run all specs in the #{suite[:title]} spec suite"
29 RSpec::Core::RakeTask.new(suite[:id]) do |t|
Tim Emiolac85c1ae2015-04-17 18:12:32 -070030 ENV['COVERAGE_NAME'] = suite[:id].to_s
Tim Emiolaf20d7602015-03-24 08:11:47 -070031 spec_files = []
32 suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
nnoble097ef9b2014-12-01 17:06:10 -080033
Tim Emiolaf20d7602015-03-24 08:11:47 -070034 if suite[:dir]
35 suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
36 end
37 helper = 'spec/spec_helper.rb'
38 spec_files << helper unless spec_files.include?(helper)
nnoble097ef9b2014-12-01 17:06:10 -080039
Tim Emiolaf20d7602015-03-24 08:11:47 -070040 t.pattern = spec_files
41 t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
42 if suite[:tags]
43 t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
nnoble097ef9b2014-12-01 17:06:10 -080044 end
45 end
46 end
47end
48
Tim Emiolaf20d7602015-03-24 08:11:47 -070049# Define dependencies between the suites.
50task 'suite:wrapper' => [:compile, :rubocop]
51task 'suite:idiomatic' => 'suite:wrapper'
52task 'suite:bidi' => 'suite:wrapper'
53task 'suite:server' => 'suite:wrapper'
Tim Emiola975d0cb2015-08-14 10:44:17 -070054task 'suite:pb' => 'suite:server'
Tim Emiola397fda02015-01-29 13:26:21 -080055
Tim Emiolaf20d7602015-03-24 08:11:47 -070056desc 'Compiles the gRPC extension then runs all the tests'
Tim Emiola975d0cb2015-08-14 10:44:17 -070057task all: ['suite:idiomatic', 'suite:bidi', 'suite:pb', 'suite:server']
Tim Emiola397fda02015-01-29 13:26:21 -080058task default: :all