summaryrefslogtreecommitdiff
path: root/test/irb/test_cmd.rb
AgeCommit message (Collapse)Author
2024-02-16[ruby/irb] Standardize command related namesStan Lo
(https://github.com/ruby/irb/pull/873) * Replace ExtendCommand with Command and standardize command related names 1. Rename lib/irb/extend-command.rb to lib/irb/command.rb 2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb 3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb 4. Rename ExtendCommand to Command * Alias ExtendCommand to Command and deprecate it * Rename Command::Nop to Command::Base * Not deprecate old constants just yet * Add lib/irb/cmd/nop.rb back https://github.com/ruby/irb/commit/462c1284af
2024-02-14[ruby/irb] Repurpose the help command to display the help messageStan Lo
(https://github.com/ruby/irb/pull/872) See #787 for more details. https://github.com/ruby/irb/commit/d9192d92d0
2024-02-12[ruby/irb] Powerup show_source by enabling RubyVM.keep_script_linestomoya ishida
(https://github.com/ruby/irb/pull/862) * Powerup show_source by enabling RubyVM.keep_script_lines * Add file_content field to avoid reading file twice while show_source * Change path passed to eval, don't change irb_path. * Encapsulate source coloring logic and binary file check insode class Source * Add edit command testcase when irb_path does not exist * Memoize irb_path existence to reduce file existence check calculating eval_path https://github.com/ruby/irb/commit/239683a937
2024-02-12[ruby/irb] Fix exit! command warning and method behaviortomoya ishida
(https://github.com/ruby/irb/pull/868) * Fix exit! command warning and method behavior * Remove arg(0) from Kernel.exit and Kernel.exit! https://github.com/ruby/irb/commit/372bc59bf5
2024-02-11[ruby/irb] Polish the exit! command and its testsStan Lo
(https://github.com/ruby/irb/pull/867) * Remove IRB.irb_exit! method It's not necessary to introduce a new method just for the exit! command at this moment. * Rename ExitForcedAction to ForceExit * Move force exit tests to a dedicated file * Fix nested history saving with exit! command Because we switched to use `Kernel#exit` instead of `exit!`, the outer session's ensure block in `Irb#run` will be run, which will save the history. This means the separate check to save history when force exiting is no longer necessary. * execute_lines helper should also capture IRB setup's output This prevents setup warnings from being printed to test output while allowing those output to be tested. * Update readme https://github.com/ruby/irb/commit/899d10ade1
2023-12-13[ruby/irb] Remove unused lvar in mesure command testtomoya ishida
(https://github.com/ruby/irb/pull/814) https://github.com/ruby/irb/commit/320178b120
2023-12-13[ruby/irb] Warn and do nothing if block is passed to measure commandtomoya ishida
(https://github.com/ruby/irb/pull/813) https://github.com/ruby/irb/commit/e79a90a1e6
2023-12-02[ruby/irb] Implement `history` commandGary Tou
(https://github.com/ruby/irb/pull/761) * Implement `history` command Lists IRB input history with indices. Also aliased as `hist`. * Add tests for `history` command * Address feedback: `puts` with multiple arguments instead of `join`ing * Address feedback: Handle nil from splitting an empty input string * Refactor line truncation * Add `-g` grep option to `history` command * Add `history` command to README * Remove unused `*args` parameter * Allow spaces to be included in grep * Allow `/` to be included in grep regex * Handle `input` being an empty string * Exclude "#{index}: " from matching the grep regex * Add new line after joining https://github.com/ruby/irb/commit/3f9eacbfa9
2023-11-28[ruby/irb] Change show_source tests into integration testsPeter Zhu
* Remove trailing spaces * Migrate show_source tests to integration tests Because show_source tests often need to define class and/or methods, they can easily leak state to other tests. Changing them to integration tests will ensure that they are run in a clean environment. * Fix NoMethodError caused by SourceFinder#method_target https://github.com/ruby/irb/commit/3c39f13397c72a8db24e50afdcb8942e6c4ea12f
2023-11-28[ruby/irb] This enhancement allows a user to add the -s flag if theypaulreece
want to access a methods origin definition. It allows for chaining of multiple esses to further go up the classes as needed. (https://github.com/ruby/irb/pull/770) https://github.com/ruby/irb/commit/eec1329d5a
2023-11-26[ruby/irb] Display aliases in help messageStan Lo
(https://github.com/ruby/irb/pull/788) Similar to Pry, it displays user-defined aliases in the help message with a dedicated section. With the current default aliases, it looks like: ``` ...other sections... Aliases $ Alias for `show_source` @ Alias for `whereami` ``` https://github.com/ruby/irb/commit/2a0eacc891
2023-11-26[ruby/irb] Support disabling pagerStan Lo
(https://github.com/ruby/irb/pull/783) With either `IRB.conf[:USE_PAGER] = false` or `--no-pager` commnad line flag. I decided use `--no-pager` instead of `--use-pager` because it matches with Pry and git's command line flags. https://github.com/ruby/irb/commit/df1c3b9042
2023-11-08[ruby/irb] Type based completion using Prism and RBStomoya ishida
(https://github.com/ruby/irb/pull/708) * Add completor using prism and rbs * Add TypeCompletion test * Switchable completors: RegexpCompletor and TypeCompletion::Completor * Add completion info to irb_info * Complete reserved words * Fix [*] (*) {**} and prism's change of KeywordParameterNode * Fix require, frozen_string_literal * Drop prism<=0.16.0 support * Add Completor.last_completion_error for debug report * Retrieve `self` and `Module.nesting` in more safe way * Support BasicObject * Handle lvar and ivar get exception correctly * Skip ivar reference test of non-self object in ruby < 3.2 * BaseScope to RootScope, move method objects constant under Methods * Remove unused Splat struct * Drop deeply nested array/hash type calculation from actual object. Now, calculation depth is 1 * Refactor loading rbs in test, change preload_in_thread not to cache Thread object * Use new option added in prism 0.17.1 to parse code with localvars * Add Prism version check and warn when :type completor cannot be enabled * build_type_completor should skip truffleruby (because endless method definition is not supported) https://github.com/ruby/irb/commit/1048c7ed7a
2023-10-21[ruby/irb] Minor refactors around irb.rbStan Lo
(https://github.com/ruby/irb/pull/736) * Remove dead method * Simplify IRB.version * Move private Irb methods together * Centralise @CONF initialization/assignment in init.rb * Move attr_* calls above initialize method https://github.com/ruby/irb/commit/cf23be4395
2023-09-26[ruby/irb] Disable pager in show-source testtomoya ishida
(https://github.com/ruby/irb/pull/720) https://github.com/ruby/irb/commit/5669efa4c1
2023-08-29[ruby/irb] Remove unused `PROMPT_N`Summer ☀️
(https://github.com/ruby/irb/pull/685) https://github.com/ruby/irb/commit/66e69fa0dc
2023-08-21[ruby/irb] Move input processing out of RubyLexStan Lo
(https://github.com/ruby/irb/pull/683) * Add a test case for Ctrl-C handling * Test symbol aliases with integration tests There are a few places that also need to check symbol aliases before `Irb#eval_input`. But since the current command test skip them, we don't have test coverage on them. * Move each_top_level_statement and readmultiline to Irb This will save RubyLex from knowning information about commands and aliases. https://github.com/ruby/irb/commit/69cb5b5615
2023-08-20[ruby/irb] Support `VISUAL` env var, and prefer it over `EDITOR`Summer ☀️
(https://github.com/ruby/irb/pull/686) * Support `VISUAL` env var, and prefer it over `EDITOR` * Update test/irb/test_cmd.rb --------- https://github.com/ruby/irb/commit/399b872c31 Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-07-26[ruby/irb] Page `ls`'s output (https://github.com/ruby/irb/pull/657)Stan Lo
* Page ls command's output * Use Pager.page_content in show_cmds too https://github.com/ruby/irb/commit/82d1687302
2023-07-25[ruby/irb] Display `show_cmds`'s output in a pager when in TTYStan Lo
environment (https://github.com/ruby/irb/pull/647) This can: - Make it easier to scroll up and down the commands list - Avoid pushing up users' previous output - Allow users to do basic search with `/<word>` https://github.com/ruby/irb/commit/f94e8a66dd
2023-06-30[ruby/irb] Reduce internal operations' exposure to benchmarkingStan Lo
(https://github.com/ruby/irb/pull/618) * Test last value is assigned with measure enabled * Remove unnecessary `result` variable `Context#evaluate` always assigns the result of the evaluation to `_` so we don't need to do it in `Irb#eval_input`. * Move benchmarking logic into `Context#evaluate` Current location of the benchmarking logic is too high up and includes operations like command loading and argument transformation, which should be excluded. So this commit moves it into `Context#evaluate` to reduce the noise. We don't move it further down to `Workspace#evaluate` because `Context` is an argument of the measure block, which is not available in `Workspace`.
2023-06-28[ruby/irb] Reduce test pend trufflerubytomoya ishida
(https://github.com/ruby/irb/pull/619) https://github.com/ruby/irb/commit/b7b071774f
2023-05-23[ruby/irb] Allow `show_source` for private methodsTSUYUSATO Kitsune
(https://github.com/ruby/irb/pull/589) * Allow `show_source` for private methods Fix https://github.com/ruby/irb/pull/577 * Pend tests on TruffleRuby It seems `eval(..., __LINE__ + 1)` does not work. Other similar tests are also pended on TruffleRuby, so I think it is acceptable. * Use `private_method_defined?` instead of `defined?`
2023-05-18[ruby/irb] Print deprecation warning for `help` commandStan Lo
(https://github.com/ruby/irb/pull/567) * Give show_doc its own command class * Print deprecation warning for `help` command
2023-04-24[ruby/irb] Simplify the help command's implementationStan Lo
(https://github.com/ruby/irb/pull/564) The current method-redefining approach brings little benefit, makes it harder to understand the code, and causes warnings like: > warning: method redefined; discarding old execute This patch simplifies it while displaying more helpful message when rdoc couldn't be loaded.
2023-04-24[ruby/irb] Filter out top-level methods when using `lsStan Lo
<Class/Module>` (https://github.com/ruby/irb/pull/562) Instead of always printing methods inherited from Class or Module, IRB by default should filter them out unless `<Class/Module>` is specified to be either of those.
2023-04-05[ruby/irb] Drop Ruby 2.6 supportStan Lo
(https://github.com/ruby/irb/pull/555) * Remove all Ruby 2.6 support * Drop Ruby 2.6 specific testing conditions * Only run Ruby 2.7+ on CI * Bump Ruby requirement to 2.7+ https://github.com/ruby/irb/commit/3f714b616c
2023-04-02[ruby/irb] Don't check RUBY_ENGINE when deciding whether to accept kargsStan Lo
Ruby implementations like JRuby and TruffleRuby already indicate their compatibility target with RUBY_VERSION. We don't need to exclude them from accepting keyword arguments as long as they target 2.7+. https://github.com/ruby/irb/commit/bf20faa4e6 Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
2023-03-31[ruby/irb] Drop unnecessary pends for trufflerubyStan Lo
https://github.com/ruby/irb/commit/2517039812
2023-02-28[ruby/irb] Display and prioritise instance methods in `lsStan Lo
<module/class>` (https://github.com/ruby/irb/pull/496) https://github.com/ruby/irb/commit/e3d21f9329
2023-02-04[ruby/irb] Add tests for workspaces commandsStan Lo
(https://github.com/ruby/irb/pull/512) https://github.com/ruby/irb/commit/874dbcad81
2023-01-12[ruby/irb] Avoid calling private methods on the main objectStan Lo
(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-05[ruby/irb] Group command test cases with classStan Lo
(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).
2022-12-26Sync IRB master: tool/sync_default_gems.rb irbTakashi Kokubun
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[ruby/irb] Suppress "switching inspect mode" messagesNobuyoshi Nakada
https://github.com/ruby/irb/commit/565eeb3c19
2022-12-26[ruby/irb] Remove unnecessary warning check on help commandStan Lo
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. https://github.com/ruby/irb/commit/b3203bc784
2022-12-26[ruby/irb] Remove unnecessary test setupStan Lo
https://github.com/ruby/irb/commit/cc6e6d26b6
2022-12-26[ruby/irb] Add test for the help commandst0012
https://github.com/ruby/irb/commit/9cacb5f352
2022-12-12[ruby/irb] Group show_doc tests and update the expectationStan Lo
(https://github.com/ruby/irb/pull/479) https://github.com/ruby/irb/commit/bede04c14a
2022-12-12[ruby/irb] `show_doc` command should take non-string argument tooStan Lo
(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-08[ruby/irb] Add show_doc as an alias to the help commandStan Lo
(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[ruby/irb] Gracefully handle missing command argumentStan Lo
(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[ruby/irb] Add "show_cmds" command to list all commands'Stan Lo
descriptions (https://github.com/ruby/irb/pull/463) https://github.com/ruby/irb/commit/7e857655ac
2022-11-21Prevent a "warning: ambiguity between regexp and two divisions"Yusuke Endoh
2022-11-20[ruby/irb] Push an accidentally uncommitted diffTakashi Kokubun
https://github.com/ruby/irb/commit/7e9f27afd7
2022-11-20[ruby/irb] Try using a different file nameTakashi Kokubun
hoping to address: https://github.com/ruby/ruby/actions/runs/3506561941/jobs/5873689640 https://github.com/ruby/irb/commit/de9a6b9d00
2022-11-20[ruby/irb] Require rubygems for ruby/rubyTakashi Kokubun
You can't take rubygems for granted in a default gem. https://github.com/ruby/ruby/actions/runs/3506561943/jobs/5873689466 https://github.com/ruby/irb/commit/58bb3954d0
2022-11-20[ruby/irb] Fix CI failure on ruby/rubyTakashi Kokubun
https://github.com/ruby/irb/commit/ea8c716922
2022-11-20[ruby/irb] Add edit command (https://github.com/ruby/irb/pull/453)Stan Lo
* Add edit command * Make find_source a public singleton method * Add document for the edit command * Make find_end private * Remove duplicated private https://github.com/ruby/irb/commit/4321674aa7 Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-11-18Prevent a "method redefined" warningYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu2004-arm/ruby-master/log/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 ```