Commit graph

20692 commits

Author SHA1 Message Date
Hiroshi SHIBATA
6bd5a51ab5 Removed Solaris conditions from test files
We no longer execute those files with Solaris platforms.
2025-04-02 16:24:47 +09:00
Naoto Ono
a671b25525
[Bug #21203] Skip TestGc#test_gc_parameter_init_slots since it is flaky (#13025)
https://bugs.ruby-lang.org/issues/21203

TestGc#test_gc_parameter_init_slots is a flaky test that fails intermittently. Until the issue with flakiness is resolved, I will skip it.
2025-04-01 09:20:13 +00:00
Hiroshi SHIBATA
67a7d4a0a8 [rubygems/rubygems] Bump up minimum required version for cmake 4
3e77caeddf
2025-04-01 15:58:24 +09:00
Jean Boussier
5e421ce8d9 ractor: don't inherit the default thread group
[Bug #17506]

`Thread.current.group` isn't shareable so it shouldn't be inherited
by the main thread of a new Ractor.

This cause an extra allocation when spawning a ractor, which could
be elided with a bit of extra work, but not sure if it's worth
the effort.
2025-03-31 10:25:52 +02:00
Jean Boussier
f8720b01d9
[ruby/json] Remove caller location assertions
Fix: https://github.com/ruby/json/pull/781

Tests are ran a bit differently in ruby/ruby
and this assertion breaks.

0d4fc669ed
2025-03-31 09:39:22 +09:00
Hiroshi SHIBATA
a7ab156d94
Revert "Relax assertion pattern for ruby repo"
This reverts commit 09b9468873.
2025-03-31 09:39:22 +09:00
Earlopain
d7e46543b5 [ruby/prism] Fix parser translator when pinning hash with string keys
`StringNode` and `SymbolNode` don't have the same shape
(`content` vs `value`) and that wasn't handled.

I believe the logic for the common case can be reused.
I simply left the special handling for implicit nodes in pattern matching
and fall through otherwise.

NOTE: patterns.txt is not actually tested at the moment,
because it contains syntax that `parser` mistakenly rejects.
But I checked manually that this doesn't introduce other failures.
https://github.com/whitequark/parser/pull/1060

55adfaa895
2025-03-30 17:24:05 +00:00
Kevin Newton
052794bfe1 [ruby/prism] Accept a newline after the defined? keyword
[Bug #21197]

22be955ce9
2025-03-30 13:22:41 -04:00
Samuel Chiang
6b5aa43291 [ruby/openssl] Skip PKCS7 with indefinite length test in AWS-LC
AWS-LC had been decoding the indefinite BER to an unusable output. We
should skip the test until indefinite BER decoding in AWS-LC is
properly fixed.

Changes:
1. AWS-LC will be looking to fix the parsing for indefinite BER
constructed strings in AWS-LC soon, so I've marked the test as `pend`
for now and removed the AWS-LC specific logic at the end.
2. I've added an assertion to verify that `OpenSSL::PKCS7.verify`
behaves correctly before doing content comparisons. I noticed this was
failing initially in AWS-LC, but that will be fixed soon as well. This
shouldn't effect OpenSSL/LibreSSL builds and should improve the test.

69fd7f8863
2025-03-30 13:46:28 +00:00
tomoya ishida
a4a6019550
[Bug #21202] Fix wrong token concat while tokenizing nested unterminated heredoc (#13000) 2025-03-29 20:46:43 +09:00
Yusuke Endoh
c3ca931304 TestRegexp#test_match_cache_positive_look_ahead_complex: Extend the timeout limit 2025-03-28 14:07:40 +09:00
Naoto Ono
8582d93194 [ruby/etc] Skip TestEtc#test_ractor_parallel on ModGC workflow
(https://github.com/ruby/etc/pull/55)

https://bugs.ruby-lang.org/issues/21204

TestEtc#test_ractor_parallel is only failing intermittently on ModGC workflow after 87fb0c4. So, we'll skip this test on ModGC workflow.

fb037c5162
2025-03-28 03:58:14 +00:00
Hiroshi SHIBATA
09b9468873 Relax assertion pattern for ruby repo 2025-03-28 12:44:53 +09:00
Jean Boussier
3bbb52f5c5 [ruby/json] Add missing assert_deprecated_warning
1b16a82980
2025-03-28 12:44:53 +09:00
Jean Boussier
ec171b4075 [ruby/json] Move create_addtions logic in Ruby.
By leveraging the `on_load` callback we can move all this logic
out of the parser. Which mean we no longer have to duplicate
that logic in both parser and that we'll later be able to extract
it entirely from the gem.

f411ddf1ce
2025-03-28 12:44:53 +09:00
Jean Boussier
e8c46f4ca5 [ruby/json] JSON.load invoke the proc callback directly from the parser.
And substitute the return value like `Marshal.load` doesm
which I can only assume was the intent.

This also open the door to re-implement all the `create_addition`
logic in `json/common.rb`.

73d2137fd3
2025-03-28 12:44:53 +09:00
Jean Boussier
756b75f242 [ruby/json] Remove Class#json_creatable? monkey patch.
1ca7efed1f
2025-03-28 12:44:53 +09:00
Jean Boussier
26e55562ce [ruby/json] Cleanup JSON.pretty_generate
01c47a0555
2025-03-28 12:44:53 +09:00
Jean Boussier
2b9a9300ac [ruby/json] Deprecate JSON.fast_generate
6508455d82
2025-03-28 12:44:53 +09:00
Jeremy Evans
43683e1e9d Avoid allocation for anonymous positional splat with no arguments
Anonymous positional splats cannot be directly accessed, they can
only be passed as splats to other methods.  So if an anonymous
positional splat would be empty, you can use a shared frozen
empty array to save an allocation.

```ruby
def a(*) end
a()
```

This is similar to how anonymous empty keyword splats are optimized,
except those use `nil` instead of a shared empty frozen hash.

This updates the allocation tests to check that the array allocations
are avoided where possible.

It also makes a small change to test_iseq.rb to ensure an unfrozen
hash is passed as the value of an anonymous splat parameter.
2025-03-27 13:59:03 -07:00
Benoit Daloze
72cb68972c [ruby/etc] Attempt to re-enable TestEtc#test_ractor_parallel
* If this fails, please revert this commit in ruby/etc
  to keep the repos sync'ed.

87fb0c4a83
2025-03-27 20:39:38 +00:00
Benoit Daloze
0581947af5 [ruby/etc] Speedup TestEtc#test_ractor_parallel
18c12c084c
2025-03-27 20:39:38 +00:00
Benoit Daloze
2f1ac3fea3 [ruby/etc] Increase timeout for test_ractor_parallel
* It seems much slower on macOS (locally on Linux it's always < 1 second).

9e46857011
2025-03-27 20:21:21 +00:00
Kevin Newton
d49483a747 [ruby/prism] Move snapshots
This is messing up the CRuby sync, so moving them out of the test
directory will make this easier.

7ba13bfb68
2025-03-27 20:14:36 +00:00
Jeremy Evans
67d1dd2ebd Avoid array allocation for *nil, by not calling nil.to_a
The following method call:

```ruby
a(*nil)
```

A method call such as `a(*nil)` previously allocated an array, because
it calls `nil.to_a`, but I have determined this array allocation is
unnecessary.  The instructions in this case are:

```
0000 putself                                                          (   1)[Li]
0001 putnil
0002 splatarray                             false
0004 opt_send_without_block                 <calldata!mid:a, argc:1, ARGS_SPLAT|FCALL>
0006 leave
```

The method call uses `ARGS_SPLAT` without `ARGS_SPLAT_MUT`, so the
returned array doesn't need to be mutable.  I believe all cases where
`splatarray false` are used allow the returned object to be frozen,
since the `false` means to not duplicate the array.  The optimization
in this case is to have `splatarray false` push a shared empty frozen
array, instead of calling `nil.to_a` to return a newly allocated array.

There is a slightly backwards incompatibility with this optimization,
in that `nil.to_a` is not called.  However, I believe the new behavior
of `*nil` not calling `nil.to_a` is more consistent with how `**nil`
does not call `nil.to_hash`.  Also, so much Ruby code would break if
`nil.to_a` returned something different from the empty hash, that it's
difficult to imagine anyone actually doing that in real code, though
we have a few tests/specs for that.

I think it would be bad for consistency if `*nil` called `nil.to_a`
in some cases and not others, so this changes other cases to not
call `nil.to_a`:

For `[*nil]`, this uses `splatarray true`, which now allocates a
new array for a `nil` argument without calling `nil.to_a`.

For `[1, *nil]`, this uses `concattoarray`, which now returns
the first array if the second array is `nil`.

This updates the allocation tests to check that the array allocations
are avoided where possible.

Implements [Feature #21047]
2025-03-27 11:17:40 -07:00
Nobuyoshi Nakada
49d49d5985 [ruby/psych] Format Date in ISO-8601 explicitly
Fix https://github.com/ruby/psych/pull/644

b1ade765ba
2025-03-27 14:56:49 +00:00
Naoto Ono
5adb2591da
Skip TestThreadInstrumentation#test_sleeping_inside_ractor on ModGC workflow (#12996)
TestThreadInstrumentation#test_sleeping_inside_ractor is a flaky and failing intermittently. Additionally, Launchable reported this test as a top flaky test. (Link: https://app.launchableinc.com/organizations/ruby/workspaces/ruby/insights/unhealthy-tests)

It failed only failed intermittently on ModGC workflow, so I'm gonna skip this test on ModGC workflow.
2025-03-27 21:22:38 +09:00
Ellen Marie Dash
af594f5166 [rubygems/rubygems] Have "gem exec" sort executable names in error message.
This decouples `gem exec` behavior (and tests) from the sort order of
the gemspec.

911cd29159
2025-03-27 13:57:25 +09:00
Yusuke Endoh
1b8e6568e4 Pend a test for ractor in etc
... because it is flaky
2025-03-27 12:28:28 +09:00
Hiroshi SHIBATA
ee85745c61 Removed trailing spaces 2025-03-27 11:37:27 +09:00
eno
d1f3c81258 Faster integer formatting
This commit provides an alternative implementation for a
long → decimal conversion.

The main difference is that it uses an algorithm pulled from
https://github.com/jeaiii/itoa.
The source there is C++, it was converted by hand to C for
inclusion with this gem.
jeaiii's algorithm is covered by the MIT License, see source code.

On addition this version now also generates the string directly into
the fbuffer, foregoing the need to run a separate memory copy.

As a result, I see a speedup of 32% on Apple Silicon M1 for an
integer set of benchmarks.
2025-03-27 11:37:27 +09:00
Jean Boussier
f4529ecbe7 [ruby/json] Deprecate all *_default_options
Globally changing the behavior of the library is a bad idea, as
many different libraries may rely on `json` and may not expect it
and likely never tested that a different default config works for them.

If you need to change the behavior of JSON, it's best to do it only
locally, and not globally.

In addition the new `JSON::Coder` interface is much more suited for
that.

Another reason for the deprecation is that it's impossible to
make `JSON.load` and `JSON.dump` Ractor-safe with such API.

172762c6e4
2025-03-27 11:37:27 +09:00
John Hawthorn
46ee73f4f6 Add additional Ractor.make_shareable tests 2025-03-26 16:05:02 -07:00
Benoit Daloze
bfc5b8305d [ruby/etc] Etc.sysconfdir does not work in a Ractor
* Because it uses RbConfig::CONFIG.
* See 3939950214 (step):12:947

12dbe03b6a
2025-03-25 21:27:16 +00:00
Benoit Daloze
b9e9a1034a [ruby/etc] Most Etc methods are not Ractor-safe currently
* See https://bugs.ruby-lang.org/issues/21115

ae62b7619c
2025-03-25 20:17:01 +00:00
eno
528c08cc5f [ruby/json] Adjust fpconv to add ".0" to integers
Adds a test case

fix

fa5bdf87cb
2025-03-24 14:35:04 +09:00
Ellen Marie Dash
6982b80a8b [rubygems/rubygems] Default to a SOURCE_DATE_EPOCH of 315619200, to simplify reproducible builds.
1d5a627398
2025-03-24 13:25:07 +09:00
David Rodríguez
4fe882e2c9 [rubygems/rubygems] Let gem exec raise an error in ambiguous cases
When `gem exec foo` is run, and "foo" is a gem that has multiple
executables, none of them named "foo", raise an error explaining the
situation and telling user to be more specific.

Currently the first command in the executables array is run, but this
may come as surprising sometimes, so better raise an error.

acda5d8f6e
2025-03-24 13:25:07 +09:00
Mohamed Hafez
7e0dac4cb1
Add test for Ractor safety (#11762) 2025-03-23 10:45:23 +00:00
Samuel Williams
5f77f9bea6
Fix handling of error/errno in io_internal_wait. (#12961)
[Bug #21195]
2025-03-23 13:42:04 +13:00
Nobuyoshi Nakada
d868922ea8
Fix regexp when non-ruby thread received the signal
A space is added only when the source path is found.
2025-03-21 15:17:15 +09:00
Nobuyoshi Nakada
edabdd95a8
Run cleanup code in ensure 2025-03-21 11:05:57 +09:00
Benoit Daloze
65bc0ec62d [ruby/prism] Fix fork check in ractor_test.rb
0073266cad
2025-03-20 21:24:19 +00:00
Kevin Newton
e47078fb30 [ruby/prism] Update ractor_test.rb per review
fd96a6821f
2025-03-20 17:23:36 -04:00
Earlopain
ab8b199be8 [ruby/prism] Add Prism::Translation::ParserCurrent
It's not my favorite api but for users that currently use the same thing
from `parser`, moving over is more difficult
than it needs to be.

If you plan to support both old and new ruby versions, you definitly need to
branch somewhere on the ruby version
to either choose prism or parser.
But with prism you then need to enumerate all the versions again and choose the correct one.

Also, don't recommend to use `Prism::Translation::Parser` in docs. It's version-less
but actually always just uses Ruby 3.4 which is probably
not what the user intended.

Note: parser also warns when the patch version doesn't match what it expects. But I don't think prism has such a concept,
and anyways it would require releases anytime ruby releases, which I don't think is very desirable

77177f9e92
2025-03-20 21:20:23 +00:00
Aaron Patterson
62cc3464d9 Remove leading nop from block when we don't need it
Blocks insert a leading `nop` instruction in order to execute a "block
call" tracepoint. Block compilation unconditionally inserts a leading
`nop` plus a label after the instruction:

  641f15b1c6/prism_compile.c (L6867-L6869)

This `nop` instruction is used entirely for firing the block entry
tracepoint.  The label exists so that the block can contain a loop but
the block entry tracepoint is executed only once.

For example, the following code is an infinite loop, but should only
execute the b_call tracepoint once:

```ruby
-> { redo }.call
```

Previous to this commit, we would eliminate the `nop` instruction, but
only if there were no other jump instructions inside the block.  This
means that the following code would still contain a leading `nop` even
though the label following the `nop` is unused:

```ruby
-> { nil if bar }
```

```
== disasm: #<ISeq:block in <main>@test.rb:1 (1,2)-(1,17)> (catch: FALSE)
0000 nop                                                              (   1)[Bc]
0001 putself                                [Li]
0002 opt_send_without_block                 <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0004 branchunless                           8
0006 putnil
0007 leave                                  [Br]
0008 putnil
0009 leave                                  [Br]
```

This commit checks to see if the label inserted after the `nop` is
actually a jump target.  If it's not a jump target, then we should be
safe to eliminate the leading `nop`:

```
> build-master/miniruby --dump=insns test.rb
== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(1,17)>
0000 putspecialobject                       1                         (   1)[Li]
0002 send                                   <calldata!mid:lambda, argc:0, FCALL>, block in <main>
0005 leave

== disasm: #<ISeq:block in <main>@test.rb:1 (1,2)-(1,17)>
0000 putself                                                          (   1)[LiBc]
0001 opt_send_without_block                 <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 branchunless                           7
0005 putnil
0006 leave                                  [Br]
0007 putnil
0008 leave                                  [Br]
```

We have a test for b_call tracepoints that use `redo` here:

  aebf96f371/test/ruby/test_settracefunc.rb (L1728-L1736)
2025-03-20 11:49:13 -07:00
Sam Bostock
f07af59a2f [ruby/prism] Dynamically register events to dispatch
Instead of requiring the consumer to provide a list of all events which
they wish to handle, we can give them to option of dynamically detecting
them, by scanning the listener's public methods.

This approach is similar to that used by Minitest (scanning for `test_`
methods) and Rails generators (running all public methods in the order
they are defined).

While this is slower than specifying a hard coded list, the penalty is
only during registration. There is no change the the behaviour of
dispatching the events.

781ebed743
2025-03-20 17:28:59 +00:00
Nobuyoshi Nakada
a51364f54b
Close reader pipes 2025-03-20 20:59:42 +09:00
Nobuyoshi Nakada
820c541671 [Bug #21026] no singleton method on pseudo variable literal 2025-03-20 17:32:26 +09:00
Kevin Newton
641f15b1c6 [ruby/prism] Mark Prism as ractor-safe
c02429765b
2025-03-19 21:11:57 +00:00