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

Extract integration testing helpers out of debug command tests #660

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jul 31, 2023

The ability to run a test case in a subprocess is useful for testing many other features, like nested IRB sessions. So I think it's worth extracting them into a new test case class.

For example, I'll need it for #659

@st0012 st0012 requested a review from a team July 31, 2023 15:50
@ruby_file = Tempfile.create(%w{irb- .rb})
@ruby_file.write(program)
@ruby_file.close
end
Copy link
Member

Choose a reason for hiding this comment

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

Just an idea

I know that this code is not changed from test_debug_cmd.rb, but could it be like this?

ruby_code = <<~RUBY
  foo
  binding.irb
  bar
RUBY
run_ruby_file ruby_code do end

This helper will going to be used in several test, so it's a good opportunity to change it.

write_ruby was introduced in 976100c.
In that point, defining write_ruby like another existing method write_irbrc makes sense because it's optional. Not always used.
Now, write_ruby is always used before run_ruby_file. I think passing as an argument is more simple.

Although, my idea has a weak point. Must think how to do something like

assert_match(/Object#foo at #{@ruby_file.to_path}/, output)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with the direction, but I feel we can design the API better after seeing other use cases. Can we revisit this after we applied integration for #659's fix?

test/irb/helper.rb Outdated Show resolved Hide resolved
The ability to run a test case in a subprocess is useful for testing
many other features, like nested IRB sessions. So I think it's worth
extracting them into a new test case class.
@tompng tompng merged commit 73b7a89 into master Aug 2, 2023
47 checks passed
@tompng tompng deleted the integration-test-case branch August 2, 2023 18:33
matzbot pushed a commit to ruby/ruby that referenced this pull request Aug 2, 2023
tests
(ruby/irb#660)

The ability to run a test case in a subprocess is useful for testing
many other features, like nested IRB sessions. So I think it's worth
extracting them into a new test case class.

ruby/irb@73b7a895f8
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.

2 participants