Commit graph

3217 commits

Author SHA1 Message Date
TangRufus
f1512bfa55 [rubygems/rubygems] Extract before blocks
ff51a51d1a
2025-06-03 08:05:17 +09:00
TangRufus
959bde8643 [rubygems/rubygems] Suffix .circleci with / in spec.files in the .gemspec template
e48c6beaf6
2025-06-03 08:05:07 +09:00
TangRufus
3691c5409d [rubygems/rubygems] Suffix .github with / in spec.files in the .gemspec template
edf13f7e60
2025-06-03 08:04:59 +09:00
TangRufus
6b2088cf90 [rubygems/rubygems] Exclude .rspec from spec.files in the .gemspec template
331901941d
2025-06-03 08:04:39 +09:00
TangRufus
a7be563d0b [rubygems/rubygems] Exclude .rubocop.yml and .standard.yml from spec.files in the .gemspec template
9d937d4f7f
2025-06-03 08:04:32 +09:00
TangRufus
04a396409d [rubygems/rubygems] Refactor spec.files ignore list generation
c11539f325
2025-06-03 08:04:04 +09:00
TangRufus
b34959b497 [rubygems/rubygems] Fix English grammar
160938e75c
2025-06-03 08:03:52 +09:00
Matthew Hively
21a14ea230
[rubygems/rubygems] Moved the REMEMBERING OPTIONS section to be after CONFIGURATION KEYS
Since the remembering options are discouraged, the preferred method should be explained first.

Slight tweak to wording

Fix documentation spec test as per suggested patch

9f082ccf31
2025-06-03 07:47:14 +09:00
Nicholas La Roux
1f894fa2cc
[rubygems/rubygems] Remove unnecessary duplicate x64-mingw-ucrt entry
d6f1f96585
2025-06-03 07:47:14 +09:00
Nicholas La Roux
869a52f33a
[rubygems/rubygems] Partially phase out x64-mingw32 in favour of x64-mingw-ucrt (platforms)
- the x64-mingw32 platform has been superseded by x64-mingw-ucrt
- the mingw-ucrt platform is present as of Windows 10, which was released 10 years ago in 2015 and all versions prior to 10 are end-of-life and 10 will be by mid October 2025
- newer rubies use the mingw-ucrt platform instead of the mingw32 platform, meaning using the deprecated platform can cause issues during gem installation

b9d871022e
2025-06-03 07:47:14 +09:00
Andrew Konchin
d6aa1714fe Update to ruby/spec@4d2fc4d 2025-06-02 21:54:48 +02:00
Hiroshi SHIBATA
20d7db8cba
Handle test failure of mock object
Fixup 4c26a38ed3

20250601T213003Z.fail.html.gz

```
1)
An exception occurred during: Mock.verify_count
File.birthtime accepts an object that has a #to_path method FAILED
Mock 'path' expected to receive to_path(:any_args) exactly 1 times
but received it 0 times
/home/chkbuild/chkbuild/tmp/build/20250601T213003Z/ruby/spec/ruby/core/file/birthtime_spec.rb:4:in 'block in <top (required)>'
/home/chkbuild/chkbuild/tmp/build/20250601T213003Z/ruby/spec/ruby/core/file/birthtime_spec.rb:3:in '<top (required)>'
```
2025-06-02 08:50:54 +09:00
Nobuyoshi Nakada
4c26a38ed3
Skip birthtime failures on old linux
`statx(2)` is available since Linux 4.11 and glibc 2.28.
2025-06-01 14:22:51 +09:00
Nobuyoshi Nakada
63617a6ce1
Update rake version in bundler tests 2025-05-31 20:56:00 +09:00
Nobuyoshi Nakada
f2ddd923ed
Update rake version in lock files 2025-05-31 19:21:14 +09:00
git
32c708efbd Update bundled gems list as of 2025-05-31 2025-05-31 09:43:52 +00:00
tomoya ishida
49f35c917b
Bump bundled bigdecimal to 3.2.1 (#13482) 2025-05-31 09:31:17 +00:00
Koichi Sasada
e8b31c273c rake 13.3.0 -> 13.2.1
`make test-bundler-parallel` prints many errors, so try to
downgrade rake version.

```
  219) bundle install --standalone run in a subdirectory with --binstubs creates stubs that can be symlinked
       Failure/Error:
               raise <<~ERROR
                 #{error_header}

                 ----------------------------------------------------------------------
                 #{stdboth}
                 ----------------------------------------------------------------------
               ERROR

       RuntimeError:

         Commands:
         $ /home/ko1/ruby/build/trunk/ruby -I/home/ko1/ruby/src/trunk/spec/bundler -r/home/ko1/ruby/src/trunk/spec/bundler/support/artifice/compact_index.rb -r/home/ko1/ruby/src/trunk/spec/bundler/support/hax.rb /home/ko1/ruby/src/trunk/tmp/2.13/gems/system/bin/bundle config set --local path /home/ko1/ruby/src/trunk/tmp/2.13/bundled_app/bundle
         # $? => 0
         Invoking `/home/ko1/ruby/build/trunk/ruby -I/home/ko1/ruby/src/trunk/spec/bundler -r/home/ko1/ruby/src/trunk/spec/bundler/support/artifice/compact_index.rb -r/home/ko1/ruby/src/trunk/spec/bundler/support/hax.rb /home/ko1/ruby/src/trunk/tmp/2.13/gems/system/bin/bundle install --standalone --binstubs` failed with output:

         ----------------------------------------------------------------------
         [DEPRECATED] The --binstubs option will be removed in favor of `bundle binstubs --all`
         Could not find compatible versions

         Because every version of rails depends on rake = 13.3.0
           and rake = 13.3.0 could not be found in rubygems repository https://gem.repo1/ or installed locally,
           rails cannot be used.
         So, because Gemfile depends on rails >= 0,
           version solving has failed.
         Fetching gem metadata from https://gem.repo1/...
         Resolving dependencies...
         ----------------------------------------------------------------------
       Shared Example Group: "bundle install --standalone" called from ./spec/bundler/install/gems/standalone_spec.rb:532
       # /home/ko1/ruby/src/trunk/spec/bundler/support/command_execution.rb:26:in 'Spec::CommandExecution#raise_error!'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/subprocess.rb:66:in 'Spec::Subprocess#sh'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:216:in 'Spec::Helpers#sys_exec'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:107:in 'Spec::Helpers#bundle'
       # /home/ko1/ruby/src/trunk/spec/bundler/install/gems/standalone_spec.rb:482:in 'block (3 levels) in <top (required)>'
       # /home/ko1/ruby/src/trunk/spec/bundler/spec_helper.rb:107:in 'block (4 levels) in <top (required)>'
       # /home/ko1/ruby/src/trunk/spec/bundler/spec_helper.rb:107:in 'block (3 levels) in <top (required)>'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:355:in 'block in Spec::Helpers#with_gem_path_as'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:369:in 'Spec::Helpers#without_env_side_effects'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:350:in 'Spec::Helpers#with_gem_path_as'
       # /home/ko1/ruby/src/trunk/spec/bundler/spec_helper.rb:106:in 'block (2 levels) in <top (required)>'
```
2025-05-31 17:15:44 +09:00
git
e577edb12e Update bundled gems list as of 2025-05-30 2025-05-30 19:14:14 +00:00
Koichi Sasada
49b7a092fa skip tests for BigDecimal 3.2.0 2025-05-31 04:01:33 +09:00
Nobuyoshi Nakada
8872d3e10b
[Feature #21205] Fix up birthtime in ruby/spec 2025-05-30 20:55:12 +09:00
David Rodríguez
1a8d338337 Initialize gems tmp when initializing bundled_gems_spec suite
That way it works even if no Bundler specs have run before.
2025-05-29 10:09:28 +09:00
Tang Rufus
f88d67db34 [rubygems/rubygems] Fix example name typo
2d0cf3c31e
2025-05-28 13:34:39 +09:00
Samuel Giddins
c9ba3d0bac
[rubygems/rubygems] Bump required_ruby_version to 3.2
Ruby 3.1 was EOL March 2025

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

29c21b1e78
2025-05-26 11:46:12 +09:00
Jeremy Evans
c52f4eea56 Remove SortedSet autoload and set/sorted_set
Implements [Feature #21287]
2025-05-20 13:34:31 +09:00
David Rodríguez
57e4176649
[rubygems/rubygems] Fix test warnings introduced by recent CGI changes
They read like this:

```
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:13: warning: method redefined; discarding old rfc1123_date
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:225: warning: previous definition of rfc1123_date was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:34: warning: method redefined; discarding old pretty
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:246: warning: previous definition of pretty was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:16: warning: method redefined; discarding old escape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:29: warning: method redefined; discarding old unescape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:13: warning: method redefined; discarding old rfc1123_date
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:225: warning: previous definition of rfc1123_date was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:34: warning: method redefined; discarding old pretty
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:246: warning: previous definition of pretty was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:16: warning: method redefined; discarding old escape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:29: warning: method redefined; discarding old unescape
```

The problem is that `rspec` loads `erb` for its configuration, which
loads `cgi/util` from system gems.

Then our tests change the `$LOAD_PATH` to make test gems installed in
tmp visible to `require`, and then they all require `cgi` as a
transitive dependency of `rack-test`, this time from `tmp` gems. This
causes system and test specific copies to be mixed together and these
warnings to be printed, but we have also observed failures in some tests
with errors like

> class variable @@accept_charset of CGI::Util is overtaken by CGI::Escape

This changes should also fix those failures.

The fix is to require all of `rack-test` (including `cgi`) before we
have changed the `$LOAD_PATH`. Because the `$LOAD_PATH` is unchanged,
RubyGems respects the version of `cgi` activated by RSpec, avoiding the
double loads.

34e75465c6
2025-05-19 11:19:17 +09:00
David Rodríguez
0f867d97ab
Rename a couple of spec files
Generally are "realworld" specs are the ones using VCR cassettes of real
requests. These files don't use that, so I moved them to a different
place.
2025-05-19 11:19:17 +09:00
David Rodríguez
6e8be3a634 [rubygems/rubygems] Test JRuby 10
Necessary changes to get tests passing are:

* Rewrite one "out of memory" error spec to not define a subclass inside
  a RSpec context block. Due to some [JRuby issue], that's failing in
  JRuby 10, so I rewrote the test so that the Bundler process really
  goes OOM and that class definition is not necessary.
* JRuby 10, even if Ruby 3.4-compatible, has not yet adapted backtraces
  to include receivers, so our tests need an special case for JRuby when
  detecting a test method call inside backtraces.
* Warbler test is upgraded to use JRuby 10. Getting it to pass needs [a
  PR] to warbler, so our test is temporarily pointing to that PR.

[JRuby issue]: https://github.com/jruby/jruby/issues/8838
[a PR]: https://github.com/jruby/warbler/pull/557

edec85d4c3
2025-05-19 11:15:33 +09:00
David Rodríguez
bfab76abe6 [rubygems/rubygems] Normalize platforms in warbler lockfile
c7c50343bb
2025-05-19 11:15:31 +09:00
Vít Ondruch
0dfe427cba [rubygems/rubygems] Fix typo "shippped" => "shipped"
1762d18d7b
2025-05-19 11:15:31 +09:00
Nobuyoshi Nakada
097d742a1e [Bug #20009] Support marshaling non-ASCII name class/module 2025-05-16 21:22:33 +09:00
Nobuyoshi Nakada
9cec38c160
"binary" is not valid encoding name in Emacs 2025-05-16 20:04:34 +09:00
Jean Boussier
b6698114e6 Add specs for Set mutation during iteration 2025-05-13 22:30:50 +02:00
Jean Boussier
1ee4b43a56 Set#merge: raise if called during iteration
[Bug #21332]
2025-05-13 22:27:42 +02:00
Randy Stauner
4464cbe5cd [rubygems/rubygems] Fix doctor command parsing of otool output
I have several gem dylibs that have a line matching "(compatibility "
with no file path preceding it.

de9dc2bdc4
2025-05-12 11:09:22 +09:00
Yusuke Endoh
e7e517499b spec/ruby/core/module/ancestors_spec.rb: Add a guard for Namespace feat. 2025-05-11 23:32:50 +09:00
Satoshi Tagomori
382645d440 namespace on read 2025-05-11 23:32:50 +09:00
Nobuyoshi Nakada
c75202c57e
[Feature #15408] Fix up _id2ref_spec.rb 2025-05-10 15:41:30 +09:00
Benoit Daloze
4a2f489ca6 Fix rb_range_beg_len() and rb_arithmetic_sequence_beg_len_step() spec
* The begp, lenp and stepp might not be written to, so they need default values.
2025-05-09 23:22:15 +02:00
Andrew Konchin
78a2ffa000 Fix digest specs when run in CRuby via make test-spec 2025-05-09 23:22:15 +02:00
Andrew Konchin
cb4a441819 Fix formatting in digest_spec.c 2025-05-09 23:22:15 +02:00
Andrew Konchin
269ad29de9 Update to ruby/spec@d8bacef 2025-05-09 23:22:15 +02:00
Hiroshi SHIBATA
5e1c90675e Added cgi for bundler testing. rack depends cgi/cookie.rb 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
ce6c1778fb Guard CGI examples with Ruby 3.5 and use cgi/escape for related examples 2025-05-09 14:27:28 +09:00
Jean Boussier
0ea210d1ea Rename ivptr -> fields, next_iv_index -> next_field_index
Ivars will longer be the only thing stored inline
via shapes, so keeping the `iv_index` and `ivptr` names
would be confusing.

Instance variables won't be the only thing stored inline
via shapes, so keeping the `ivptr` name would be confusing.

`field` encompass anything that can be stored in a VALUE array.

Similarly, `gen_ivtbl` becomes `gen_fields_tbl`.
2025-05-08 07:58:05 +02:00
Jeremy Evans
e4f85bfc31 Implement Set as a core class
Set has been an autoloaded standard library since Ruby 3.2.
The standard library Set is less efficient than it could be, as it
uses Hash for storage, which stores unnecessary values for each key.

Implementation details:

* Core Set uses a modified version of `st_table`, named `set_table`.
  than `s/st_/set_/`, the main difference is that the stored records
  do not have values, making them 1/3 smaller. `st_table_entry` stores
  `hash`, `key`, and `record` (value), while `set_table_entry` only
  stores `hash` and `key`.  This results in large sets using ~33% less
  memory compared to stdlib Set.  For small sets, core Set uses 12% more
  memory (160 byte object slot and 64 malloc bytes, while stdlib set
  uses 40 for Set and 160 for Hash).  More memory is used because
  the set_table is embedded and 72 bytes in the object slot are
  currently wasted. Hopefully we can make this more efficient and have
  it stored in an 80 byte object slot in the future.

* All methods are implemented as cfuncs, except the pretty_print
  methods, which were moved to `lib/pp.rb` (which is where the
  pretty_print methods for other core classes are defined).  As is
  typical for core classes, internal calls call C functions and
  not Ruby methods.  For example, to check if something is a Set,
  `rb_obj_is_kind_of` is used, instead of calling `is_a?(Set)` on the
  related object.

* Almost all methods use the same algorithm that the pure-Ruby
  implementation used.  The exception is when calling `Set#divide` with a
  block with 2-arity.  The pure-Ruby method used tsort to implement this.
  I developed an algorithm that only allocates a single intermediate
  hash and does not need tsort.

* The `flatten_merge` protected method is no longer necessary, so it
  is not implemented (it could be).

* Similar to Hash/Array, subclasses of Set are no longer reflected in
  `inspect` output.

* RDoc from stdlib Set was moved to core Set, with minor updates.

This includes a comprehensive benchmark suite for all public Set
methods.  As you would expect, the native version is faster in the
vast majority of cases, and multiple times faster in many cases.
There are a few cases where it is significantly slower:

* Set.new with no arguments (~1.6x)
* Set#compare_by_identity for small sets (~1.3x)
* Set#clone for small sets (~1.5x)
* Set#dup for small sets (~1.7x)

These are slower as Set does not currently use the AR table
optimization that Hash does, so a new set_table is initialized for
each call.  I'm not sure it's worth the complexity to have an AR
table-like optimization for small sets (for hashes it makes sense,
as small hashes are used everywhere in Ruby).

The rbs and repl_type_completor bundled gems will need updates to
support core Set.  The pull request marks them as allowed failures.

This passes all set tests with no changes.  The following specs
needed modification:

* Modifying frozen set error message (changed for the better)
* `Set#divide` when passed a 2-arity block no longer yields the same
  object as both the first and second argument (this seems like an issue
  with the previous implementation).
* Set-like objects that override `is_a?` such that `is_a?(Set)` return
  `true` are no longer treated as Set instances.
* `Set.allocate.hash` is no longer the same as `nil.hash`
* `Set#join` no longer calls `Set#to_a` (it calls the underlying C
   function).
* `Set#flatten_merge` protected method is not implemented.

Previously, `set.rb` added a `SortedSet` autoload, which loads
`set/sorted_set.rb`.  This replaces the `Set` autoload in `prelude.rb`
with a `SortedSet` autoload, but I recommend removing it and
`set/sorted_set.rb`.

This moves `test/set/test_set.rb` to `test/ruby/test_set.rb`,
reflecting that switch to a core class.  This does not move the spec
files, as I'm not sure how they should be handled.

Internally, this uses the st_* types and functions as much as
possible, and only adds set_* types and functions as needed.
The underlying set_table implementation is stored in st.c, but
there is no public C-API for it, nor is there one planned, in
order to keep the ability to change the internals going forward.

For internal uses of st_table with Qtrue values, those can
probably be replaced with set_table.  To do that, include
internal/set_table.h.  To handle symbol visibility (rb_ prefix),
internal/set_table.h uses the same macro approach that
include/ruby/st.h uses.

The Set class (rb_cSet) and all methods are defined in set.c.
There isn't currently a C-API for the Set class, though C-API
functions can be added as needed going forward.

Implements [Feature #21216]

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Co-authored-by: Oliver Nutter <mrnoname1000@riseup.net>
2025-04-26 10:31:11 +09:00
Aaron Patterson
3552d446ca update allocation location tests 2025-04-25 13:46:05 -07:00
Hiroshi SHIBATA
a8aa83cc7b all of examples at commands/newgem_spec.rb are working on ruby repo 2025-04-23 18:09:55 +09:00
Xavier Noria
5f3fb35a14 Add a new spec for inherited 2025-04-23 07:07:18 +02:00
Xavier Noria
80cf292c79 Add a new spec for const_added 2025-04-23 07:07:18 +02:00