Rakefile 1.6 KB

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