Skip to content

Migrate pathname.c to pathname_builtin.rb#14303

Merged
hsbt merged 7 commits intoruby:masterfrom
hsbt:pathname-gh-57
Aug 25, 2025
Merged

Migrate pathname.c to pathname_builtin.rb#14303
hsbt merged 7 commits intoruby:masterfrom
hsbt:pathname-gh-57

Conversation

@hsbt
Copy link
Copy Markdown
Member

@hsbt hsbt commented Aug 22, 2025

Import from ruby/pathname#57

Comment thread pathname_builtin.rb Fixed
Comment thread pathname_builtin.rb Fixed
Comment thread pathname_builtin.rb Fixed
Comment thread pathname_builtin.rb Fixed
Comment thread pathname_builtin.rb Fixed
Comment thread pathname_builtin.rb Fixed
@launchable-app

This comment has been minimized.

```
Error: test_join(PathnameInstanceTest): NoMethodError: undefined method 'respond_to?' for an instance of RBS::UnitTest::Convertibles::ToStr
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/rbs/lib/rbs/unit_test/spy.rb:94:in 'Pathname#join'
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/rbs/lib/rbs/unit_test/spy.rb:94:in 'block (2 levels) in wrapped_object'
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/rbs/lib/rbs/unit_test/type_assertions.rb:152:in 'block in RBS::UnitTest::TypeAssertions#send_setup'
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/rbs/lib/rbs/unit_test/type_assertions.rb:150:in 'Kernel#catch'
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/rbs/lib/rbs/unit_test/type_assertions.rb:150:in 'RBS::UnitTest::TypeAssertions#send_setup'
/Users/hsbt/Documents/github.com/ruby/ruby/gems/src/rbs/lib/rbs/unit_test/type_assertions.rb:172:in 'RBS::UnitTest::TypeAssertions#assert_send_type'
test/stdlib/Pathname_test.rb:389:in 'PathnameInstanceTest#test_join'
     386:                      Pathname('.'), :join, 'foo'
     387:     assert_send_type '(String, String) -> Pathname',
     388:                      Pathname('.'), :join, 'foo', 'bar'
  => 389:     assert_send_type '(ToStr) -> Pathname',
     390:                      Pathname('.'), :join, ToStr.new('foo')
     391:     assert_send_type '(Pathname) -> Pathname',
     392:                      Pathname('.'), :join, Pathname('foo')
```
@hsbt
Copy link
Copy Markdown
Member Author

hsbt commented Aug 22, 2025

I could reproduce the failures of test_allocation.rb and confirmed failure number is changed with code size of pathname_builtin.rb. So that is similar with #13906.

@eregon
Copy link
Copy Markdown
Member

eregon commented Aug 22, 2025

Thank you for this, regarding the extra commits I think it would be best to have all/some of them in ruby/pathname too.
I can help with that.

  • realdirpath should be trivial to define in Ruby.
  • the TypeError is good to add in ruby/pathname too
  • Does anything rely on Kernel.Pathname do be public?

# Windows platforms may allocate an extra array after https://github.com/ruby/ruby/pull/14303
unless ($allocations[0] - num_arrays == 1 && RUBY_PLATFORM =~ /mswin|mingw/)
failures << "Expected \#{num_arrays} array allocations for \#{check_code.inspect}, but \#{$allocations[0]} arrays allocated"
end
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.

This is really surprising, how is this possible given this file doesn't seem to use Pathname at all?

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.

Ah probably because of #14303 (comment). I don't quite understand how having a bigger pathname_builtin.rb can cause that though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because I requested to separate the original PR of ruby/pathname#57 (comment).

But you ignored my suggestions and stubbornly refuse to accept them. As a result, Windows platform is broken and I waste a many of investigation time.

Copy link
Copy Markdown
Member

@eregon eregon Aug 27, 2025

Choose a reason for hiding this comment

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

Because I requested to separate the original PR of ruby/pathname#57 (comment).

As far as I can tell smaller PRs would not have helped or changed anything about that.
This PR revealed that ruby/pathname did not test against ruby/spec, which I fixed in ruby/pathname#60.
I also found significant bugs in test_pathname.rb which I fixed in that PR too.

But you ignored my suggestions and stubbornly refuse to accept them.

I asked you to make concrete suggestions on the PR in ruby/pathname#57 (comment), you did not in one month, so I couldn't understand what you wanted.
I also explained why I couldn't see how to meaningfully make smaller PRs for that change.

I did not understand precisely what you meant by #13906 since that seemed unrelated to Pathname as far as I could tell.
It turns out a related issue happened on this PR, but that is clearly a bug of ObjectSpace.count_objects, not of Pathname. BTW I tried to fix that bug #14329 to help move things forward.
Excluding the test like you did here seems fine to me, it was a bug unrelated to Pathname, basically a transient test failure waiting to happen (it even already failed before I guess as the reason for #13906) due to a bug in ObjectSpace.count_objects.

As a result, Windows platform is broken

No CI was broken. Only failures on this PR when updating to latest ruby/pathname.
As far as I understand there was no urgency to merge this PR or make it green.

and I waste a many of investigation time.

I am sorry about that, I sympathize with that feeling, it's always annoying when unexpected failures happen.
I tried to react here and on https://bugs.ruby-lang.org/issues/21532 as fast as possible and offer help.
If such a situation would happen again, please ask help and let others help, rather than spending too much of your time on it and getting frustrated.

I would also like to help with the sync of ruby/pathname <-> ruby/ruby in future, if you would like so.

@eregon
Copy link
Copy Markdown
Member

eregon commented Aug 22, 2025

I would like to help with "upstreaming" these commits to ruby/pathname this weekend, if that's OK.
I think the changes needed here are mostly revealing missing tests in test_pathname.rb.

@eregon
Copy link
Copy Markdown
Member

eregon commented Aug 22, 2025

Looking at https://github.com/ruby/ruby/actions/runs/17144600559/job/48638223862 (failures on the first commit) that's what showed the differences, so ruby/spec has extra tests that test_pathname.rb is missing. We should either run that part of ruby/spec in ruby/pathname, or port those specs to test_pathname.rb.

@eregon
Copy link
Copy Markdown
Member

eregon commented Aug 23, 2025

@hsbt hsbt merged commit 6ab2cd0 into ruby:master Aug 25, 2025
85 checks passed
@hsbt hsbt deleted the pathname-gh-57 branch August 25, 2025 08:40
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