diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-29 14:35:37 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-29 14:35:37 +0000 |
commit | 021bec087823b11e60a669ed0390096d978b893e (patch) | |
tree | 70d928d35c01b51bb9a6cdc44af4bd7cc05a669b /spec/rubyspec/core/io/popen_spec.rb | |
parent | a6c9453d869479e23ce0c0349795ea5853ac1898 (diff) | |
download | ruby-021bec087823b11e60a669ed0390096d978b893e.tar.gz |
Update to ruby/spec@abf1700
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/core/io/popen_spec.rb')
-rw-r--r-- | spec/rubyspec/core/io/popen_spec.rb | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/spec/rubyspec/core/io/popen_spec.rb b/spec/rubyspec/core/io/popen_spec.rb index f24e61032f..45bb0e2cab 100644 --- a/spec/rubyspec/core/io/popen_spec.rb +++ b/spec/rubyspec/core/io/popen_spec.rb @@ -74,10 +74,7 @@ describe "IO.popen" do end it "does not throw an exception if child exited and has been waited for" do - # Avoid the /bin/sh subshell using :options and :args to sleep. - # We don't want to kill only the subshell and leave "ruby -e sleep" - # running indefinitely - @io = IO.popen(ruby_cmd(nil, :options => '-e', :args => 'sleep')) + @io = IO.popen([*ruby_exe, '-e', 'sleep']) pid = @io.pid Process.kill "KILL", pid @io.close @@ -201,28 +198,28 @@ describe "IO.popen" do end it "accepts an Array of command and arguments" do - exe, *args = ruby_cmd(nil).split + exe, *args = ruby_exe 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_cmd(nil).split + exe, *args = ruby_exe 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_cmd(nil).split, "-e", "STDERR.puts ENV['FOO']"], + IO.popen({"FOO" => "bar"}, [*ruby_exe, "-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_cmd(nil).split, "-e", "STDERR.puts ENV['FOO']"], + IO.popen({"FOO" => "bar"}, [*ruby_exe, "-e", "STDERR.puts ENV['FOO']"], "r", err: [:child, :out]) do |io| io.read.should == "bar\n" end @@ -231,45 +228,45 @@ describe "IO.popen" do context "with a leading Array argument" do it "uses the Array as command plus args for the child process" do - IO.popen([*ruby_cmd(nil).split, "-e", "puts 'hello'"]) do |io| + IO.popen([*ruby_exe, "-e", "puts 'hello'"]) do |io| io.read.should == "hello\n" end end it "accepts a leading ENV Hash" do - IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "puts ENV['FOO']"]) do |io| + IO.popen([{"FOO" => "bar"}, *ruby_exe, "-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_cmd(nil).split, "does_not_exist", {err: [:child, :out]}]) do |io| + IO.popen([*ruby_exe, "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_cmd(nil).split, "does_not_exist", {err: [:child, :out]}], "r") do |io| + IO.popen([*ruby_exe, "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_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]", + IO.popen([{"FOO" => "bar"}, *ruby_exe, "-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_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]", + IO.popen([{"FOO" => "bar"}, *ruby_exe, "-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_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]", + IO.popen([{"FOO" => "bar"}, *ruby_exe, "-e", "STDERR.puts ENV[:FOO.to_s]", err: [:child, :out]], "r", internal_encoding: Encoding::EUC_JP) do |io| io.read.should == "bar\n" @@ -278,7 +275,7 @@ describe "IO.popen" do end it "accepts '[env, command, arg1, arg2, ...], mode, IO + exec options'" do - IO.popen([{"FOO" => "bar"}, *ruby_cmd(nil).split, "-e", "STDERR.puts ENV[:FOO.to_s]"], "r", + IO.popen([{"FOO" => "bar"}, *ruby_exe, "-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 |