Rakefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. spec_files = []
  27. suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
  28. if suite[:dir]
  29. suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
  30. end
  31. helper = 'spec/spec_helper.rb'
  32. spec_files << helper unless spec_files.include?(helper)
  33. t.pattern = spec_files
  34. t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
  35. if suite[:tags]
  36. t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
  37. end
  38. end
  39. end
  40. end
  41. # Define dependencies between the suites.
  42. task 'suite:wrapper' => [:compile, :rubocop]
  43. task 'suite:idiomatic' => 'suite:wrapper'
  44. task 'suite:bidi' => 'suite:wrapper'
  45. task 'suite:server' => 'suite:wrapper'
  46. desc 'Compiles the gRPC extension then runs all the tests'
  47. task all: ['suite:idiomatic', 'suite:bidi', 'suite:server']
  48. task default: :all