diff options
Diffstat (limited to 'spec/ruby/core/io/read_spec.rb')
-rw-r--r-- | spec/ruby/core/io/read_spec.rb | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb index a829ffd18c..bd22fb6d6e 100644 --- a/spec/ruby/core/io/read_spec.rb +++ b/spec/ruby/core/io/read_spec.rb @@ -165,12 +165,19 @@ describe "IO.read from a pipe" do platform_is :windows do cmd = "|cmd.exe /C echo hello" end - IO.read(cmd).should == "hello\n" + + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + IO.read(cmd).should == "hello\n" + end end platform_is_not :windows do it "opens a pipe to a fork if the rest is -" do - str = IO.read("|-") + str = nil + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + str = IO.read("|-") + end + if str # parent str.should == "hello from child\n" else #child @@ -185,13 +192,18 @@ describe "IO.read from a pipe" do platform_is :windows do cmd = "|cmd.exe /C echo hello" end - IO.read(cmd, 1).should == "h" + + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + IO.read(cmd, 1).should == "h" + end end platform_is_not :windows do it "raises Errno::ESPIPE if passed an offset" do -> { - IO.read("|sh -c 'echo hello'", 1, 1) + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + IO.read("|sh -c 'echo hello'", 1, 1) + end }.should raise_error(Errno::ESPIPE) end end @@ -202,11 +214,23 @@ quarantine! do # The process tried to write to a nonexistent pipe. # once https://bugs.ruby-lang.org/issues/12230 is fixed. it "raises Errno::EINVAL if passed an offset" do -> { - IO.read("|cmd.exe /C echo hello", 1, 1) + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + IO.read("|cmd.exe /C echo hello", 1, 1) + end }.should raise_error(Errno::EINVAL) end end end + + ruby_version_is "3.3" do + # https://bugs.ruby-lang.org/issues/19630 + it "warns about deprecation given a path with a pipe" do + cmd = "|echo ok" + -> { + IO.read(cmd) + }.should complain(/IO process creation with a leading '\|'/) + end + end end describe "IO.read on an empty file" do |