Rakefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- ruby -*-
  2. require 'rake/extensiontask'
  3. require 'rspec/core/rake_task'
  4. require 'rubocop/rake_task'
  5. require 'bundler/gem_tasks'
  6. # Add rubocop style checking tasks
  7. RuboCop::RakeTask.new
  8. # Add the extension compiler task
  9. Rake::ExtensionTask.new 'grpc' do |ext|
  10. ext.lib_dir = File.join('lib', 'grpc')
  11. end
  12. # Define the test suites
  13. SPEC_SUITES = [
  14. { id: :wrapper, title: 'wrapper layer', files: %w(spec/*.rb) },
  15. { id: :idiomatic, title: 'idiomatic layer', dir: %w(spec/generic),
  16. tags: ['~bidi', '~server'] },
  17. { id: :bidi, title: 'bidi tests', dir: %w(spec/generic),
  18. tag: 'bidi' },
  19. { id: :server, title: 'rpc server thread tests', dir: %w(spec/generic),
  20. tag: 'server' }
  21. ]
  22. namespace :suite do
  23. SPEC_SUITES.each do |suite|
  24. desc "Run all specs in the #{suite[:title]} spec suite"
  25. RSpec::Core::RakeTask.new(suite[:id]) do |t|
  26. ENV['COVERAGE_NAME'] = suite[:id].to_s
  27. spec_files = []
  28. suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
  29. if suite[:dir]
  30. suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
  31. end
  32. helper = 'spec/spec_helper.rb'
  33. spec_files << helper unless spec_files.include?(helper)
  34. t.pattern = spec_files
  35. t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
  36. if suite[:tags]
  37. t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
  38. end
  39. end
  40. end
  41. end
  42. # Define dependencies between the suites.
  43. task 'suite:wrapper' => [:compile, :rubocop]
  44. task 'suite:idiomatic' => 'suite:wrapper'
  45. task 'suite:bidi' => 'suite:wrapper'
  46. task 'suite:server' => 'suite:wrapper'
  47. desc 'Compiles the gRPC extension then runs all the tests'
  48. task all: ['suite:idiomatic', 'suite:bidi', 'suite:server']
  49. task default: :all