Debian Codegraph @

src/ruby/end2end/package_with_underscore_test.rb

raw ◀ ▶
1 Debian patch touch this file
1 # Copyright 2018 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 require 'open3'
16 require 'tmpdir'
17
18 def main
19 root_dir = File.join(File.dirname(__FILE__), '..', '..', '..')
20 pb_dir = File.join(root_dir, 'src', 'ruby', 'end2end', 'protos')
21
22 bins_dir = File.join(root_dir, 'cmake', 'build')
•23 bins_dir = '/usr/bin'
24 plugin = File.join(bins_dir, 'grpc_ruby_plugin')
25 protoc = File.join(bins_dir, 'third_party', 'protobuf', 'protoc')
•26 protoc = File.join(bins_dir, 'protoc')
27
28 got = nil
29
30 Dir.mktmpdir do |tmp_dir|
31 gen_out = File.join(tmp_dir, 'package_with_underscore', 'service_services_pb.rb')
32
33 pid = spawn(
34 protoc,
35 "--proto_path=#{pb_dir}",
36 'package_with_underscore/service.proto',
37 "--grpc_out=#{tmp_dir}",
38 "--plugin=protoc-gen-grpc=#{plugin}"
39 )
40 Process.waitpid2(pid)
41 File.open(gen_out) { |f| got = f.read }
42 end
43
44 correct_modularized_rpc = 'rpc :TestOne, ' \
45 '::Grpc::Testing::PackageWithUnderscore::Data::Request, ' \
46 '::Grpc::Testing::PackageWithUnderscore::Data::Response'
47
48 return if got.include?(correct_modularized_rpc)
49
50 fail 'generated file does not match with correct_modularized_rpc'
51 end
52
53 main