nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 1 | # -*- ruby -*- |
| 2 | require 'rake/extensiontask' |
| 3 | require 'rspec/core/rake_task' |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 4 | require 'rubocop/rake_task' |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 5 | require 'bundler/gem_tasks' |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 6 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 7 | # Add rubocop style checking tasks |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 8 | RuboCop::RakeTask.new |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 9 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 10 | # Add the extension compiler task |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 11 | Rake::ExtensionTask.new 'grpc' do |ext| |
| 12 | ext.lib_dir = File.join('lib', 'grpc') |
| 13 | end |
| 14 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 15 | # Define the test suites |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 16 | SPEC_SUITES = [ |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 17 | { id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) }, |
| 18 | { id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic), |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame] | 19 | tags: ['~bidi', '~server'] }, |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 20 | { id: :bidi, title: 'bidi tests', dir: %w(spec/generic), |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame] | 21 | tag: 'bidi' }, |
| 22 | { id: :server, title: 'rpc server thread tests', dir: %w(spec/generic), |
Tim Emiola | 975d0cb | 2015-08-14 10:44:17 -0700 | [diff] [blame] | 23 | tag: 'server' }, |
| 24 | { id: :pb, title: 'protobuf service tests', dir: %w(spec/pb) } |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 25 | ] |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 26 | namespace :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 Emiola | c85c1ae | 2015-04-17 18:12:32 -0700 | [diff] [blame] | 30 | ENV['COVERAGE_NAME'] = suite[:id].to_s |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 31 | spec_files = [] |
| 32 | suite[:files].each { |f| spec_files += Dir[f] } if suite[:files] |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 33 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 34 | 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) |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 39 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 40 | 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(' ') |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 44 | end |
| 45 | end |
| 46 | end |
| 47 | end |
| 48 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 49 | # Define dependencies between the suites. |
| 50 | task 'suite:wrapper' => [:compile, :rubocop] |
| 51 | task 'suite:idiomatic' => 'suite:wrapper' |
| 52 | task 'suite:bidi' => 'suite:wrapper' |
| 53 | task 'suite:server' => 'suite:wrapper' |
Tim Emiola | 975d0cb | 2015-08-14 10:44:17 -0700 | [diff] [blame] | 54 | task 'suite:pb' => 'suite:server' |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame] | 55 | |
Tim Emiola | f20d760 | 2015-03-24 08:11:47 -0700 | [diff] [blame] | 56 | desc 'Compiles the gRPC extension then runs all the tests' |
Tim Emiola | 975d0cb | 2015-08-14 10:44:17 -0700 | [diff] [blame] | 57 | task all: ['suite:idiomatic', 'suite:bidi', 'suite:pb', 'suite:server'] |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame] | 58 | task default: :all |