From 2ad35b31bb844bee95bc29d85a0508c10f99d428 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 18 Dec 2017 04:32:54 +0000 Subject: io.c: opening external command * io.c (rb_io_open_generic): when external command will be invoked as other than IO singleton method, probably unintentionally, warn if it is File or raise ArgumentError. From: Nobuyoshi Nakada git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 00369365d0..89c68b6cb2 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2184,6 +2184,15 @@ class TestIO < Test::Unit::TestCase end end + def test_read_command + assert_warn(/invoke external command/) do + File.read("|#{EnvUtil.rubybin} -e puts") + end + assert_raise_with_message(ArgumentError, /invoke external command/) do + Class.new(IO).read("|#{EnvUtil.rubybin} -e puts") + end + end + def test_reopen make_tempfile {|t| open(__FILE__) do |f| -- cgit v1.2.3