Commit graph

80 commits

Author SHA1 Message Date
Stan Lo
295fc59eda [ruby/irb] Add tests for workspaces commands
(https://github.com/ruby/irb/pull/512)

874dbcad81
2023-02-04 22:31:17 +00:00
Stan Lo
207f8d0027 [ruby/irb] Avoid calling private methods on the main object
(https://github.com/ruby/irb/pull/498)

When the main object is frozen, `IRB` wraps a `SimpleDelegator` around it.
But because `SimpleDelegator` doesn't delegate private methods, methods like
`require_relative` or `const_get` would cause error, which are needed for
lazily loading commands.

This commit works around this limitation by avoiding those private method calls
when setting up command execution.
2023-01-12 11:49:16 +00:00
Stan Lo
f9148d1580 [ruby/irb] Group command test cases with class
(https://github.com/ruby/irb/pull/491)

Currently, IRB has 35 test cases for 10 non-debugging commands, with the
rest 10 commands untested. So in the long-term, it could have around 70
test cases for all existing commands.

With this number of test cases, I think it's easier to manage them by grouping
them in classes (by command).
2023-01-05 13:06:23 +00:00
Takashi Kokubun
d5985049c7 Sync IRB master: tool/sync_default_gems.rb irb
It looks like tool/sync_default_gems.rb is not capable of cherry-picking
commits from ruby/irb. I just executed `tool/sync_default_gems.rb irb`
to fix the sync status.

I'm not sure if what's the cause. It could be related to some diff that
doesn't exist in ruby/ruby, or it might be related to non-linear history
due to merge commits. For next time, I'd like to at least exclude the
second possibility, so I disabled merge commits in ruby/irb.
2022-12-26 13:10:37 -08:00
Nobuyoshi Nakada
d01bcf378b [ruby/irb] Suppress "switching inspect mode" messages
565eeb3c19
2022-12-26 13:04:04 -08:00
Stan Lo
87988756d0 [ruby/irb] Remove unnecessary warning check on help command
It's not an intentional behavior of the command and it behaves
differently in different environments. So checking it actually brings
more problem than benefit.

b3203bc784
2022-12-26 13:04:04 -08:00
Stan Lo
148eb05ec1 [ruby/irb] Remove unnecessary test setup
cc6e6d26b6
2022-12-26 13:04:03 -08:00
st0012
8038bf239a [ruby/irb] Add test for the help command
9cacb5f352
2022-12-26 13:04:03 -08:00
Stan Lo
f88f2bd92f [ruby/irb] Group show_doc tests and update the expectation
(https://github.com/ruby/irb/pull/479)

bede04c14a
2022-12-12 21:05:03 +00:00
Stan Lo
223d4448c8 [ruby/irb] show_doc command should take non-string argument too
(https://github.com/ruby/irb/pull/478)

Given that `show_doc` already supports syntax like `String#gsub`, it
should be able to take it in non-string form too, like `edit` and
`show_source` do. This ensures users can have a consistent syntax on
argument between different commands.
2022-12-12 17:35:48 +00:00
Stan Lo
c9076d546a [ruby/irb] Add show_doc as an alias to the help command
(https://github.com/ruby/irb/pull/475)

In the long-term, we want to align with `Pry`, `byebug` and `debug` to
use the `help` command to list all commands, which is what `show_cmds`
currently does. And `show_doc` will be the command to look up Ruby APIs.

By aliasing `show_doc` to the current `help` now, users will have time
to get use to it.
2022-12-08 21:46:55 +00:00
Stan Lo
12b7c129bf [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
2022-12-08 21:05:37 +00:00
Stan Lo
3956bb859c [ruby/irb] Add "show_cmds" command to list all commands'
descriptions
(https://github.com/ruby/irb/pull/463)

7e857655ac
2022-12-08 19:10:23 +00:00
Yusuke Endoh
730b841f8d Prevent a "warning: ambiguity between regexp and two divisions" 2022-11-21 16:13:15 +09:00
Takashi Kokubun
66ac288ae2 [ruby/irb] Push an accidentally uncommitted diff
7e9f27afd7
2022-11-20 05:38:43 +00:00
Takashi Kokubun
fa2e0cc018 [ruby/irb] Try using a different file name
hoping to address:
5873689640

de9a6b9d00
2022-11-20 05:31:56 +00:00
Takashi Kokubun
f47251671d [ruby/irb] Require rubygems for ruby/ruby
You can't take rubygems for granted in a default gem.
5873689466

58bb3954d0
2022-11-20 05:19:50 +00:00
Takashi Kokubun
e0f0367ab5 [ruby/irb] Fix CI failure on ruby/ruby
ea8c716922
2022-11-20 05:06:07 +00:00
Stan Lo
180ed611b2 [ruby/irb] Add edit command (https://github.com/ruby/irb/pull/453)
* Add edit command

* Make find_source a public singleton method

* Add document for the edit command

* Make find_end private

* Remove duplicated private

4321674aa7
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-11-20 04:47:54 +00:00
Yusuke Endoh
ca1aa7afea Prevent a "method redefined" warning
20221118T033003Z.log.html.gz
```
[21350/22024] TestIRB::ExtendCommandTest#test_show_source_end_finder/home/chkbuild/chkbuild/tmp/build/20221118T033003Z/ruby/test/irb/test_cmd.rb:523: warning: method redefined; discarding old show_source_test_method
/home/chkbuild/chkbuild/tmp/build/20221118T033003Z/ruby/test/irb/test_cmd.rb:523: warning: previous definition of show_source_test_method was here
 ```
2022-11-18 15:39:50 +09:00
st0012
1eae15142f [ruby/irb] Remove duplicated TestInputMethod definitions
4b831d02e1
2022-11-15 10:07:32 +00:00
Stan Lo
14a1394bcd [ruby/irb] Simplify info command's tests
(https://github.com/ruby/irb/pull/440)

5942949226
2022-11-11 21:05:35 +00:00
Takashi Kokubun
8fa83fa0b2 [ruby/irb] Transform ls's --grep/-G option to keyword args
(https://github.com/ruby/irb/pull/437)

* Transform ls's --grep/-G option to keyword args

* Make --grep less flexible

* Support -g instead of --grep

* Suppress warnings from symbol aliases
2022-11-10 22:55:15 +00:00
Takashi Kokubun
0de3bc92b4 [ruby/irb] Make $ and @ default aliases
(https://github.com/ruby/irb/pull/438)

0613589476
2022-11-10 17:31:15 +00:00
Stan Lo
b7b78f062f [ruby/irb] Add execute_lines to reduce command tests' boilerplate
code
(https://github.com/ruby/irb/pull/436)

1595337149
2022-11-08 17:19:59 +00:00
Takashi Kokubun
9001e53e68 [ruby/irb] Support non-string input in show_source
(https://github.com/ruby/irb/pull/430)

* Support non-string input in show_source

* Test show_source as a method
2022-11-07 17:29:28 +00:00
Nobuyoshi Nakada
b83074dac7 [ruby/irb] Suppress "switching inspect mode" messages
ee068d039b
2022-11-04 11:43:21 +00:00
Stan Lo
a923203811 [ruby/irb] Provide a base test class and let tests restore encodings
conveniently
(https://github.com/ruby/irb/pull/429)

* Create a base TestIRB::TestCase class

* Save/restore encodings for tests that initializes InputMethod classes

Because `RelineInputMethod#initializes` calls `set_encoding`, which
changes stdio/out/err and Encoding's default encoding values, we need to
make sure any test that directly or indirectly (e.g. through Context)
initializes `RelineInputMethod` restores encodings.

`ReadlineInputMethod` also changes encodings but currently no tests
cover it.

* Remove unnecessary TestHelper module

Since we now have a base TestCase, without_rdoc can just live there.

c2874ec121
2022-11-03 22:13:11 +00:00
Takashi Kokubun
a13836e70d [ruby/irb] Allow non-identifier aliases like Pry's @ and $
(https://github.com/ruby/irb/pull/426)

* Allow non-identifier aliases

* Move the configuration to IRB.conf

* Avoid abusing method lookup for symbol aliases

* Add more alias tests

* A small optimization

* Assume non-nil Context

* Load IRB.conf earlier

e23db5132e
2022-11-03 22:09:55 +00:00
Nobuyoshi Nakada
13e968c1cd [ruby/irb] Suppress sequence to inspect asian ambiguous width
a7097c5b80
2022-10-28 08:29:38 +00:00
Nobuyoshi Nakada
7440fc3eb4 [ruby/irb] Suppress "switching inspect mode" messages
565eeb3c19
2022-10-28 08:29:37 +00:00
Peter Zhu
ea5972572b [ruby/irb] Fix warnings in test_cmd.rb
Fixes this warning:

    warning: assigned but unused variable - err

298fcb57a3
2022-10-27 15:29:52 -04:00
Stan Lo
b260c1e8c8 [ruby/irb] Remove unnecessary test setup 2022-10-27 15:29:11 -04:00
Stan Lo
0dc2e1a764 [ruby/irb] Remove unnecessary warning check on help command
It's not an intentional behavior of the command and it behaves
differently in different environments. So checking it actually brings
more problem than benefit.

b3203bc784
2022-10-26 15:15:30 +00:00
Peter Zhu
73a0223f95 [ruby/irb] Rename test_helper.rb to helper.rb
The name test_helper.rb conflicts with the test_helper.rb in JSON,
causing build failures. This commit renames test_helper.rb to helper.rb.

b6a92bf6b3

Co-Authored-By: Stan Lo <stan001212@gmail.com>
2022-10-26 15:13:44 +00:00
st0012
cb95d834cc [ruby/irb] Don't insert new methods to Test::Unit::TestCase
Ruby CI runs irb and other Ruby core/stdlib tests in the same process.
So adding irb-specific helper to Test::Unit::TestCase could potentially
pollute other components' tests and should be avoided.
2022-10-26 10:44:29 -04:00
Stan Lo
2022470a95 [ruby/irb] Suppress warnings
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2022-10-26 10:44:26 -04:00
st0012
d889e810f3 [ruby/irb] Add test for the help command 2022-10-26 10:44:23 -04:00
aycabta
7b0f2d618e [ruby/irb] Remove unnecessary space in regexp
c24a8e2483
2021-12-20 16:19:37 +09:00
aycabta
b96ef7684c [ruby/irb] Add East Asian Ambiguous Width to irb_info command
4cade4b7e5
2021-12-20 16:19:36 +09:00
Takashi Kokubun
82b87a8dc4 [ruby/irb] Clean up a duplicated definition
I simply forgot deleting it.

65399d5e9f
2021-10-11 15:25:05 +09:00
Takashi Kokubun
2e183c6273 [ruby/irb] trufflruby fails on the show_source test
460bd12b87
2021-10-10 23:23:48 -07:00
Takashi Kokubun
b33caa5bbc [ruby/irb] Add a test of find_end for show_source command
68e6ca95a0
2021-10-10 23:23:47 -07:00
aycabta
f1035248af [ruby/irb] Show code page by irb_info on Windows
6160d74199
2021-07-16 01:55:25 +09:00
aycabta
456d0019dd [ruby/irb] Escape space in free-spacing mode
085ac42947
2021-07-16 01:55:16 +09:00
aycabta
947d0198e0 [ruby/irb] Show LANG and LC_ALL env by irb_info
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

b431742430
2021-07-11 06:12:07 +09:00
Masataka Pocke Kuwabara
e8c2b03ee1 [ruby/irb] Fix error on ls object_cant_define_singleton
such as `ls 42`, `ls :sym` and so on

b1d436a853
2021-06-30 20:55:18 +09:00
Nobuyoshi Nakada
3b615f4353
Strip trailing spaces 2021-06-23 10:08:51 +09:00
Keiko Kaneko
de779f4a62 [ruby/irb] Sort ls result ordered by anscestry
fdd5c0a71e
2021-06-22 22:32:42 +09:00
Nobuyoshi Nakada
c7601fb9ed [ruby/irb] Deal with different screen sizes
7118b3322f
2021-05-08 15:29:36 +09:00