Skip to content

Polish the exit! command and its tests - #867

Merged
tompng merged 6 commits into
masterfrom
followup-#851
Feb 11, 2024
Merged

tompng merged 6 commits into
masterfrom
followup-#851

Conversation

@st0012

@st0012 st0012 commented Feb 10, 2024

Copy link
Copy Markdown
Member

I splitted the changes into individual commits with explanation.

It's not necessary to introduce a new method just for the exit! command
at this moment.
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.
This prevents setup warnings from being printed to test output
while allowing those output to be tested.
@st0012 st0012 self-assigned this Feb 10, 2024
@tompng
tompng merged commit 899d10a into master Feb 11, 2024
@tompng
tompng deleted the followup-#851 branch February 11, 2024 05:17
matzbot pushed a commit to ruby/ruby that referenced this pull request Feb 11, 2024
(ruby/irb#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

ruby/irb@899d10ade1
Comment thread lib/irb.rb
context.io.save_history if save_history
end
context.io.save_history if save_history
Kernel.exit(0) if forced_exit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend exit or exit(true) instead of exit(0).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Address it in #868

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants