ruby-changes:47030
From: glass <ko1@a...>
Date: Thu, 22 Jun 2017 19:56:54 +0900 (JST)
Subject: [ruby-changes:47030] glass:r59145 (trunk): Fix exception type in option type checker
glass 2017-06-22 19:56:49 +0900 (Thu, 22 Jun 2017) New Revision: 59145 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59145 Log: 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@g...> close #1657 Modified files: trunk/lib/shell/system-command.rb trunk/test/shell/test_command_processor.rb Index: test/shell/test_command_processor.rb =================================================================== --- test/shell/test_command_processor.rb (revision 59144) +++ test/shell/test_command_processor.rb (revision 59145) @@ -66,4 +66,17 @@ class TestShell::CommandProcessor < Test https://github.com/ruby/ruby/blob/trunk/test/shell/test_command_processor.rb#L66 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 Index: lib/shell/system-command.rb =================================================================== --- lib/shell/system-command.rb (revision 59144) +++ lib/shell/system-command.rb (revision 59145) @@ -16,7 +16,7 @@ class Shell https://github.com/ruby/ruby/blob/trunk/lib/shell/system-command.rb#L16 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/