diff options
Diffstat (limited to 'spec/ruby/core/io/foreach_spec.rb')
-rw-r--r-- | spec/ruby/core/io/foreach_spec.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/ruby/core/io/foreach_spec.rb b/spec/ruby/core/io/foreach_spec.rb index c2276cf544..c361d27879 100644 --- a/spec/ruby/core/io/foreach_spec.rb +++ b/spec/ruby/core/io/foreach_spec.rb @@ -20,7 +20,10 @@ describe "IO.foreach" do platform_is :windows do cmd = "|cmd.exe /C echo hello&echo line2" end - IO.foreach(cmd) { |l| ScratchPad << l } + + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + IO.foreach(cmd) { |l| ScratchPad << l } + end ScratchPad.recorded.should == ["hello\n", "line2\n"] end @@ -28,7 +31,9 @@ describe "IO.foreach" do it "gets data from a fork when passed -" do parent_pid = $$ - IO.foreach("|-") { |l| ScratchPad << l } + suppress_warning do # https://bugs.ruby-lang.org/issues/19630 + IO.foreach("|-") { |l| ScratchPad << l } + end if $$ == parent_pid ScratchPad.recorded.should == ["hello\n", "from a fork\n"] @@ -39,6 +44,16 @@ describe "IO.foreach" do 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.foreach(cmd).to_a + }.should complain(/IO process creation with a leading '\|'/) + end + end end end |