summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-18 04:32:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-18 04:32:54 +0000
commit2ad35b31bb844bee95bc29d85a0508c10f99d428 (patch)
tree258e5fc527f9e1b41df5b5e9da12417fa298b264 /test/ruby/test_io.rb
parent570642bf154a2366506202821584ac38e5a8c4ff (diff)
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 <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb9
1 files changed, 9 insertions, 0 deletions
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|