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

improve test framework in backlog #73

Merged
merged 3 commits into from
Jun 9, 2021
Merged

improve test framework in backlog #73

merged 3 commits into from
Jun 9, 2021

Conversation

ono-max
Copy link
Member

@ono-max ono-max commented Jun 8, 2021

  • rename 'lines' to 'backlog'
  • use "last_backlog" instead of "internal_info[:backlog]"
  • define create_message method to output backlog when assertion failed

@@ -54,37 +52,41 @@ def create_pseudo_terminal(boot_options: "-r debug/run")
timeout_sec = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i

PTY.spawn("#{RUBY} #{boot_options} #{temp_file_path}") do |read, write, pid|
lines = []
backlog = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't you make @backlog instead of backlog local variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ko1
In my opinion, local variable is better than instance variable to keep the scope of the variable small.
What do you think about this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case, @last_backlog and @internal_info are already used and I don't have any good reason why only @backlog is passed as an argument.

Copy link
Collaborator

Choose a reason for hiding this comment

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

"All in arguments" is another reasonable option for me.

Copy link
Member Author

@ono-max ono-max Jun 8, 2021

Choose a reason for hiding this comment

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

@ko1

In this case, @last_backlog and @internal_info are already used and I don't have any good reason why only @backlog is passed as an argument.

@internal_info and @last_backlog are used in some assertions, but @backlog are used in all assertions. Does that make sense for you?

That's why I used @backlog as an argument.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't make sense to me. The visibility control is not related to frequency.

  • backlog is only visible where the value is passed. Well controlled.
  • @internal_info and @last_backlog are visible from any test class methods.

Visibility of these values should be same. At least I feel it should be same because there is no reason to change the visibility.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general, well-controlled visibility is good idea. So passing backlog as an argument is nice.
However, @internal_info and @last_backlog are already exposed, and maybe nobody modify them from test methods (in other words, we can believe test writers). In this background, there is no reason to prohibit exposing backlog and it reduces the code size.

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 fully persuaded myself of your opinion. Thanks!

@ono-max ono-max changed the title Improve test improve test framework Jun 8, 2021
@ono-max ono-max changed the title improve test framework improve test framework in backlog Jun 8, 2021
@ko1 ko1 merged commit a299c1b into ruby:master Jun 9, 2021
@ono-max ono-max deleted the improve-test branch June 17, 2021 11:16
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