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

Fix TestPuma::HOST4 #3254

Merged
merged 1 commit into from
Oct 11, 2023
Merged

Fix TestPuma::HOST4 #3254

merged 1 commit into from
Oct 11, 2023

Conversation

casperisfine
Copy link
Contributor

Array#sort takes a block that accept 2 parameters.

The intent here was to use sort_by.

test/helpers/test_puma.rb:14:in `length': wrong number of arguments (given 1, expected 0) (ArgumentError)

      .uniq.sort(&:length)
                 ^^^^^^^^
	from puma/test/helpers/test_puma.rb:14:in `sort'
	from puma/test/helpers/test_puma.rb:14:in `<module:TestPuma>'
	from puma/test/helpers/test_puma.rb:5:in `<top (required)>'
	from puma/test/helpers/test_puma/puma_socket.rb:4:in `require_relative'
	from puma/test/helpers/test_puma/puma_socket.rb:4:in `<top (required)>'
	from puma/test/test_cli.rb:4:in `require_relative'
	from puma/test/test_cli.rb:4:in `<top (required)>'
	from /rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `require'
	from /rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
	from /rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
	from /rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'

@MSP-Greg
Copy link
Member

MSP-Greg commented Oct 9, 2023

@casperisfine

Thanks for the PR.

  1. I do/will make mistakes/typos.
  2. I was unaware of it, but Ruby (at least back to 2.4) seems to short-circuits calls to sort/sort_by if the array has one member. My systems all have only one address returned by Socket.ip_address_list.select(&:ipv*_loopback?), so there is no error locally or in CI.

The code for HOST6 should also be changed, and the line t.include?('::1') ? +'[::1]' : "[#{t.first}]" should be removed, as that was leftover from when the define_singleton_method(:ip) didn't exist. And, that method should be added to to HOST4 so they behave the same. I added it since some code wants [::1], and other code wants ::1...

Thanks.

`Array#sort` takes a block that accept 2 parameters.

The intent here was to use `sort_by`.
@casperisfine
Copy link
Contributor Author

@MSP-Greg I updated the PR, not 100% sure I got all your suggestions though.

@MSP-Greg
Copy link
Member

@casperisfine

Sorry, I've been working on some other test issues. This code is part of a test suite update, and a goal was to be able to flip IPv4 tests to IPv6. The code is still 'converging' on how granular the control should be...

Sorry for the bad code

@MSP-Greg MSP-Greg merged commit ba4ece4 into puma:master Oct 11, 2023
61 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants