1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix exception type in option type checker

* lib/shell/system-command.rb (SystemCommand#initialize):
  `def_e2message` wraps error message, but does not define new exception

* test/shell/test_command_processor.rb: add a test

This patch is authored by Kenichi Kamiya <kachick1@gmail.com>
close #1657

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
glass 2017-06-22 10:56:49 +00:00
parent eb3ca69935
commit b906f78855
2 changed files with 14 additions and 1 deletions

View file

@ -16,7 +16,7 @@ class Shell
class SystemCommand < Filter
def initialize(sh, command, *opts)
if t = opts.find{|opt| !opt.kind_of?(String) && opt.class}
Shell.Fail Error::TypeError, t.class, "String"
Shell.Fail TypeError, t.class, "String"
end
super(sh)
@command = command

View file

@ -66,4 +66,17 @@ class TestShell::CommandProcessor < Test::Unit::TestCase
Process.waitall
Dir.rmdir(path)
end
def test_option_type
name = 'foo'
path = File.join(@tmpdir, name)
open(path, 'w', 0755) {}
assert_raise(TypeError) {
catch(catch_command_start) {@shell.system(name, 42)}
}
ensure
Process.waitall
File.unlink(path)
end
end