aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-22 10:56:49 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-22 10:56:49 +0000
commite860d9ecad0826cc2ddf391a31abbe766c479c54 (patch)
tree365365ae091eb352d5271ce084862ae3d473b67a
parent6b8b17740858f841acc0e36b51d98274dff00404 (diff)
downloadruby-e860d9ecad0826cc2ddf391a31abbe766c479c54.tar.gz
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
-rw-r--r--lib/shell/system-command.rb2
-rw-r--r--test/shell/test_command_processor.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
index 81456e7db3..af22ed90d7 100644
--- a/lib/shell/system-command.rb
+++ b/lib/shell/system-command.rb
@@ -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
diff --git a/test/shell/test_command_processor.rb b/test/shell/test_command_processor.rb
index 99fe1b222a..9abc75d5e6 100644
--- a/test/shell/test_command_processor.rb
+++ b/test/shell/test_command_processor.rb
@@ -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