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), |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame^] | 16 | tags: ['~bidi', '~server'] }, |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 17 | { id: :bidi, title: 'bidi tests', dir: %w(spec/generic), |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame^] | 18 | tag: 'bidi' }, |
| 19 | { id: :server, title: 'rpc server thread tests', dir: %w(spec/generic), |
| 20 | tag: 'server' } |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 21 | ] |
| 22 | |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 23 | desc 'Run all RSpec tests' |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 24 | namespace :spec do |
| 25 | namespace :suite do |
| 26 | SPEC_SUITES.each do |suite| |
| 27 | desc "Run all specs in #{suite[:title]} spec suite" |
| 28 | RSpec::Core::RakeTask.new(suite[:id]) do |t| |
| 29 | spec_files = [] |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 30 | suite[:files].each { |f| spec_files += Dir[f] } if suite[:files] |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 31 | |
| 32 | if suite[:dirs] |
| 33 | suite[:dirs].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] } |
| 34 | end |
| 35 | |
| 36 | t.pattern = spec_files |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 37 | t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag] |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame^] | 38 | t.rspec_opts = suite[:tags].map{ |t| "--tag #{t}" }.join(' ') if suite[:tags] |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 39 | end |
| 40 | end |
| 41 | end |
| 42 | end |
| 43 | |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame^] | 44 | desc 'Run compiles the extension, runs all the tests' |
| 45 | task :all |
| 46 | |
| 47 | task default: :all |
Tim Emiola | e2860c5 | 2015-01-16 02:58:41 -0800 | [diff] [blame] | 48 | task 'spec:suite:wrapper' => :compile |
| 49 | task 'spec:suite:idiomatic' => 'spec:suite:wrapper' |
Tim Emiola | 397fda0 | 2015-01-29 13:26:21 -0800 | [diff] [blame^] | 50 | task 'spec:suite:bidi' => 'spec:suite:wrapper' |
| 51 | task 'spec:suite:server' => 'spec:suite:wrapper' |
| 52 | task :all => ['spec:suite:idiomatic', 'spec:suite:bidi', 'spec:suite:server'] |