diff options
author | Stan Lo <stan.lo@shopify.com> | 2022-12-08 21:05:33 +0000 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-12-08 21:05:37 +0000 |
commit | 12b7c129bf8ed3a113e2cc73f817868507504268 (patch) | |
tree | bc7840e980895d55b39cdf79ac2aab86538fcef1 /test | |
parent | 234c3a056ea71c8e1011e2e3f1b600d2550d6305 (diff) |
[ruby/irb] Gracefully handle missing command argument
(https://github.com/ruby/irb/pull/473)
* Handle file loading commands' argument error gracefully
Currently, if users don't provide an argument to `source`,
`irb_load`, and `irb_require`, IRB raises `ArgumentError` with full
stacktrace. This is confusing because it looks similar to when IRB has
internal issues. The message also isn't helpful on helping users avoid
the error.
So in this commit, I add a new `CommandArgumentError` for commands to
raise explicitly when users' input doesn't satisfy a command's argument
requirement.
* Gracefully handle `fg` command's argument requirement
Diffstat (limited to 'test')
-rw-r--r-- | test/irb/test_cmd.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index ac0c115339..31cd786ffe 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -368,6 +368,14 @@ module TestIRB ], out) end + def test_irb_source_without_argument + out, err = execute_lines( + "irb_source\n", + ) + assert_empty err + assert_match(/Please specify the file name./, out) + end + def test_help out, _ = execute_lines( "help 'String#gsub'\n", @@ -416,6 +424,15 @@ module TestIRB ], out) end + def test_irb_load_without_argument + out, err = execute_lines( + "irb_load\n", + ) + + assert_empty err + assert_match(/Please specify the file name./, out) + end + def test_ls out, err = execute_lines( "class P\n", |