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' |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 5 | |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame^] | 6 | desc 'Run Rubocop to check for style violations' |
| 7 | RuboCop::RakeTask.new |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 8 | |
| 9 | Rake::ExtensionTask.new 'grpc' do |ext| |
| 10 | ext.lib_dir = File.join('lib', 'grpc') |
| 11 | end |
| 12 | |
| 13 | SPEC_SUITES = [ |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame^] | 14 | { 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' } |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 19 | ] |
| 20 | |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame^] | 21 | desc 'Run all RSpec tests' |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 22 | namespace :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 Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame^] | 28 | suite[:files].each { |f| spec_files += Dir[f] } if suite[:files] |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 29 | |
| 30 | if suite[:dirs] |
| 31 | suite[:dirs].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] } |
| 32 | end |
| 33 | |
| 34 | t.pattern = spec_files |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame^] | 35 | t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag] |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 36 | end |
| 37 | end |
| 38 | end |
| 39 | end |
| 40 | |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame^] | 41 | task default: 'spec:suite:idiomatic' # this should be spec:suite:bidi |
| 42 | task 'spec:suite:wrapper' => :compile |
| 43 | task 'spec:suite:idiomatic' => 'spec:suite:wrapper' |
| 44 | task 'spec:suite:bidi' => 'spec:suite:idiomatic' |