Use ruby_cmd instead of the RUBY_EXE constant in specs

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-05-10 14:35:24 +00:00
parent 849bf24abf
commit d655f8c592
2 changed files with 17 additions and 19 deletions

View File

@ -1,8 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../fixtures/classes', __FILE__)
ruby_exe = RUBY_EXE.split
describe "IO.popen" do describe "IO.popen" do
before :each do before :each do
@io = nil @io = nil
@ -199,28 +197,28 @@ describe "IO.popen" do
end end
it "accepts an Array of command and arguments" do 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.popen({"FOO" => "bar"}, [[exe, "specfu"], *args, "-e", "puts ENV['FOO']"]) do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
end end
end end
it "accepts an Array of command and arguments, and an IO mode" do 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.popen({"FOO" => "bar"}, [[exe, "specfu"], *args, "-e", "puts ENV['FOO']"], "r") do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
end end
end end
it "accepts an Array command with a separate trailing Hash of Process.exec options" do 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| err: [:child, :out]) do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
end end
end end
it "accepts an Array command with a separate trailing Hash of Process.exec options, and an IO mode" do 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| "r", err: [:child, :out]) do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
end end
@ -229,45 +227,45 @@ describe "IO.popen" do
context "with a leading Array argument" do context "with a leading Array argument" do
it "uses the Array as command plus args for the child process" 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" io.read.should == "hello\n"
end end
end end
it "accepts a leading ENV Hash" do 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" io.read.should == "bar\n"
end end
end end
it "accepts a trailing Hash of Process.exec options" do 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/ io.read.should =~ /LoadError/
end end
end end
it "accepts an IO mode argument following the Array" do 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/ io.read.should =~ /LoadError/
end end
end end
it "accepts [env, command, arg1, arg2, ..., exec options]" do 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| err: [:child, :out]]) do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
end end
end end
it "accepts '[env, command, arg1, arg2, ..., exec options], mode'" do 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| err: [:child, :out]], "r") do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
end end
end end
it "accepts '[env, command, arg1, arg2, ..., exec options], mode, IO options'" do 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", err: [:child, :out]], "r",
internal_encoding: Encoding::EUC_JP) do |io| internal_encoding: Encoding::EUC_JP) do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
@ -276,7 +274,7 @@ describe "IO.popen" do
end end
it "accepts '[env, command, arg1, arg2, ...], mode, IO + exec options'" do 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| err: [:child, :out], internal_encoding: Encoding::EUC_JP) do |io|
io.read.should == "bar\n" io.read.should == "bar\n"
io.internal_encoding.should == Encoding::EUC_JP io.internal_encoding.should == Encoding::EUC_JP

View File

@ -32,26 +32,26 @@ module KernelSpecs
end end
def self.has_private_method(name) 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" ruby_exe("puts", args: cmd) == "true"
end end
def self.chop(str, method) 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 ruby_exe "puts", args: cmd
end end
def self.encoded_chop(file) def self.encoded_chop(file)
ruby_exe "puts", args: "| #{RUBY_EXE} -n #{file}" ruby_exe "puts", args: "| #{ruby_cmd(nil)} -n #{file}"
end end
def self.chomp(str, method, sep="\n") 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 ruby_exe "puts", args: cmd
end end
def self.encoded_chomp(file) def self.encoded_chomp(file)
ruby_exe "puts", args: "| #{RUBY_EXE} -n #{file}" ruby_exe "puts", args: "| #{ruby_cmd(nil)} -n #{file}"
end end
# kind_of?, is_a?, instance_of? # kind_of?, is_a?, instance_of?