aboutsummaryrefslogtreecommitdiffhomepage
path: root/Rakefile
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-12-18 11:16:16 -0800
committerGravatar murgatroid99 <mlumish@google.com>2015-12-18 11:18:34 -0800
commitd7e1a10628b87d9437f15ffb44d74499345ba757 (patch)
treef4951a040546449bf5649d7bcf9827c13c4f9caf /Rakefile
parent08ae945aac08bc36f77304ea06f826a4cf52b091 (diff)
Bundled C core with Ruby library
Diffstat (limited to 'Rakefile')
-rwxr-xr-xRakefile63
1 files changed, 63 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100755
index 0000000000..079df67996
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,63 @@
+# -*- ruby -*-
+require 'rake/extensiontask'
+require 'rspec/core/rake_task'
+require 'rubocop/rake_task'
+require 'bundler/gem_tasks'
+
+# Add rubocop style checking tasks
+RuboCop::RakeTask.new(:rubocop) do |task|
+ task.options = ['-c', 'src/ruby/.rubocop.yml']
+ task.patterns = ['src/ruby/{lib,spec}/**/*.rb']
+end
+
+# Add the extension compiler task
+Rake::ExtensionTask.new 'grpc' do |ext|
+ ext.source_pattern = '**/*.{c,h}'
+ ext.ext_dir = File.join('src', 'ruby', 'ext', 'grpc')
+ ext.lib_dir = File.join('src', 'ruby', 'lib', 'grpc')
+end
+
+# Define the test suites
+SPEC_SUITES = [
+ { id: :wrapper, title: 'wrapper layer', files: %w(src/ruby/spec/*.rb) },
+ { id: :idiomatic, title: 'idiomatic layer', dir: %w(src/ruby/spec/generic),
+ tags: ['~bidi', '~server'] },
+ { id: :bidi, title: 'bidi tests', dir: %w(src/ruby/spec/generic),
+ tag: 'bidi' },
+ { id: :server, title: 'rpc server thread tests', dir: %w(src/ruby/spec/generic),
+ tag: 'server' },
+ { id: :pb, title: 'protobuf service tests', dir: %w(src/ruby/spec/pb) }
+]
+namespace :suite do
+ SPEC_SUITES.each do |suite|
+ desc "Run all specs in the #{suite[:title]} spec suite"
+ RSpec::Core::RakeTask.new(suite[:id]) do |t|
+ ENV['COVERAGE_NAME'] = suite[:id].to_s
+ spec_files = []
+ suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
+
+ if suite[:dir]
+ suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
+ end
+ helper = 'src/ruby/spec/spec_helper.rb'
+ spec_files << helper unless spec_files.include?(helper)
+
+ t.pattern = spec_files
+ t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
+ if suite[:tags]
+ t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
+ end
+ end
+ end
+end
+
+# Define dependencies between the suites.
+task 'suite:wrapper' => [:compile, :rubocop]
+task 'suite:idiomatic' => 'suite:wrapper'
+task 'suite:bidi' => 'suite:wrapper'
+task 'suite:server' => 'suite:wrapper'
+task 'suite:pb' => 'suite:server'
+
+desc 'Compiles the gRPC extension then runs all the tests'
+task all: ['suite:idiomatic', 'suite:bidi', 'suite:pb', 'suite:server']
+task default: :all