Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish the exit! command and its tests #867

Merged
merged 6 commits into from Feb 11, 2024
Merged

Polish the exit! command and its tests #867

merged 6 commits into from Feb 11, 2024

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Feb 10, 2024

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
57 checks passed
@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
context.io.save_history if save_history
end
context.io.save_history if save_history
Kernel.exit(0) if forced_exit
Copy link
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
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
Development

Successfully merging this pull request may close these issues.

None yet

3 participants