ruby-changes:46532
From: eregon <ko1@a...>
Date: Wed, 10 May 2017 23:35:30 +0900 (JST)
Subject: [ruby-changes:46532] eregon:r58653 (trunk): Use ruby_cmd instead of the RUBY_EXE constant in specs
eregon 2017-05-10 23:35:24 +0900 (Wed, 10 May 2017) New Revision: 58653 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58653 Log: Use ruby_cmd instead of the RUBY_EXE constant in specs Modified files: trunk/spec/rubyspec/core/io/popen_spec.rb trunk/spec/rubyspec/core/kernel/fixtures/classes.rb Index: spec/rubyspec/core/io/popen_spec.rb =================================================================== --- spec/rubyspec/core/io/popen_spec.rb (revision 58652) +++ spec/rubyspec/core/io/popen_spec.rb (revision 58653) @@ -1,8 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/io/popen_spec.rb#L1 require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../fixtures/classes', __FILE__) -ruby_exe = RUBY_EXE.split - describe "IO.popen" do before :each do @io = nil @@ -199,28 +197,28 @@ describe "IO.popen" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/io/popen_spec.rb#L197 end it "accepts an Array of command and arguments" do - exe, *args = *ruby_exe + exe, *args = ruby_cmd(nil).split IO.popen({"FOO" => "bar"}, [[exe, "specfu"], *args, "-e", "puts ENV['FOO']"]) do |io| io.read.should == "bar\n" end end it "accepts an Array of command and arguments, and an IO mode" do - exe, *args = *ruby_exe + exe, *args = ruby_cmd(nil).split IO.popen({"FOO" => "bar"}, [[exe, "specfu"], *args, "-e", "puts ENV['FOO']"], "r") do |io| io.read.should == "bar\n" end end it "accepts an Array command with a separate trailing Hash of Process.exec options" do - IO.popen({"FOO" => "bar"}, [*ruby_exe, "-e", "STDERR.puts ENV['FOO']"], + IO.popen({"FOO" => "bar"}, [*ruby_cmd(nil).split, "-e", "STDERR.puts ENV['FOO']"], err: [:child, :out]) do |io| io.read.should == "bar\n" end end it "accepts an Array command with a separate trailing Hash of Process.exec options, and an IO mode" do - IO.popen({"FOO" => "bar"}, [*ruby_exe, "-e", "STDERR.puts ENV['FOO']"], + IO.popen({"FOO" => "bar"}, [*ruby_cmd(nil).split, "-e", "STDERR.puts ENV['FOO']"], "r", err: [:child, :out]) do |io| io.read.should == "bar\n" end @@ -229,45 +227,45 @@ describe "IO.popen" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/io/popen_spec.rb#L227 context "with a leading Array argument" do it "uses the Array as command plus args for the child process" do - IO.popen([*ruby_exe, "-e", "puts 'hello'"]) do |io| + IO.popen([*ruby_cmd(nil).split, "-e", "puts 'hello'"]) do |io| io.read.should == "hello\n" end end it "accepts a leading ENV Hash" do - IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "puts ENV['FOO']"]) do |io| + IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "puts ENV['FOO']"]) do |io| io.read.should == "bar\n" end end it "accepts a trailing Hash of Process.exec options" do - IO.popen([*ruby_exe, "does_not_exist", {err: [:child, :out]}]) do |io| + IO.popen([*ruby_cmd(nil).split, "does_not_exist", {err: [:child, :out]}]) do |io| io.read.should =~ /LoadError/ end end it "accepts an IO mode argument following the Array" do - IO.popen([*ruby_exe, "does_not_exist", {err: [:child, :out]}], "r") do |io| + IO.popen([*ruby_cmd(nil).split, "does_not_exist", {err: [:child, :out]}], "r") do |io| io.read.should =~ /LoadError/ end end it "accepts [env, command, arg1, arg2, ..., exec options]" do - IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]", + IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]", err: [:child, :out]]) do |io| io.read.should == "bar\n" end end it "accepts '[env, command, arg1, arg2, ..., exec options], mode'" do - IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]", + IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]", err: [:child, :out]], "r") do |io| io.read.should == "bar\n" end end it "accepts '[env, command, arg1, arg2, ..., exec options], mode, IO options'" do - IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]", + IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]", err: [:child, :out]], "r", internal_encoding: Encoding::EUC_JP) do |io| io.read.should == "bar\n" @@ -276,7 +274,7 @@ describe "IO.popen" do https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/io/popen_spec.rb#L274 end it "accepts '[env, command, arg1, arg2, ...], mode, IO + exec options'" do - IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]"], "r", + IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]"], "r", err: [:child, :out], internal_encoding: Encoding::EUC_JP) do |io| io.read.should == "bar\n" io.internal_encoding.should == Encoding::EUC_JP Index: spec/rubyspec/core/kernel/fixtures/classes.rb =================================================================== --- spec/rubyspec/core/kernel/fixtures/classes.rb (revision 58652) +++ spec/rubyspec/core/kernel/fixtures/classes.rb (revision 58653) @@ -32,26 +32,26 @@ module KernelSpecs https://github.com/ruby/ruby/blob/trunk/spec/rubyspec/core/kernel/fixtures/classes.rb#L32 end def self.has_private_method(name) - cmd = %[| #{RUBY_EXE} -n -e "print Kernel.private_method_defined?('#{name}')"] + cmd = %[| #{ruby_cmd(nil)} -n -e "print Kernel.private_method_defined?('#{name}')"] ruby_exe("puts", args: cmd) == "true" end def self.chop(str, method) - cmd = "| #{RUBY_EXE} -n -e '$_ = #{str.inspect}; #{method}; print $_'" + cmd = "| #{ruby_cmd(nil)} -n -e '$_ = #{str.inspect}; #{method}; print $_'" ruby_exe "puts", args: cmd end def self.encoded_chop(file) - ruby_exe "puts", args: "| #{RUBY_EXE} -n #{file}" + ruby_exe "puts", args: "| #{ruby_cmd(nil)} -n #{file}" end def self.chomp(str, method, sep="\n") - cmd = "| #{RUBY_EXE} -n -e '$_ = #{str.inspect}; $/ = #{sep.inspect}; #{method}; print $_'" + cmd = "| #{ruby_cmd(nil)} -n -e '$_ = #{str.inspect}; $/ = #{sep.inspect}; #{method}; print $_'" ruby_exe "puts", args: cmd end def self.encoded_chomp(file) - ruby_exe "puts", args: "| #{RUBY_EXE} -n #{file}" + ruby_exe "puts", args: "| #{ruby_cmd(nil)} -n #{file}" end # kind_of?, is_a?, instance_of? -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/