Commit graph

18546 commits

Author SHA1 Message Date
Jun Aruga
f370c4dc03 [ruby/openssl] test_pkey.rb: Refactor the test_ed25519 on FIPS.
* Split the test in the FIPS case as another test.
* test/openssl/utils.rb: Add omit_on_fips and omit_on_non_fips methods.

4d64c38ed0
2023-09-21 18:04:55 +00:00
Jun Aruga
3123b2fa0e [ruby/openssl] test_fips.rb: Fix the OpenSSL.fips_mode affecting other tests.
Run the test with `assert_separately` for the `false` value of the
`OpenSSL.fips_mode` not to affect other tests.

2fe3438d8a
2023-09-21 18:04:55 +00:00
Samuel Giddins
0a423d4c4e [rubygems/rubygems] Aggressively optimize allocations in SafeMarshal
Reduces allocations in a bundle install --full-index by an order of magnitude

Main wins are (a) getting rid of exessive string allocations for exception message stack

(b) Avoiding hash allocations caused by kwargs for #initialize

(c) avoid using unpack to do bit math, its easy enough to do by hand

(d) special case the most common elements so they can be read without an allocation

(e) avoid string allocations every time a symbol->string lookup is done by using symbol#name

7d2ee51402
2023-09-21 07:40:58 +00:00
Kouhei Yanagita
7e350f5310 Optimize Range#bsearch for beginless/endless ranges within Fixnum 2023-09-21 10:30:58 +09:00
Nobuyoshi Nakada
ab637cad2b [Bug #19624] Clean up backquote IO
It should not be hidden, since it can be grabbed by a fiber scheduler.
2023-09-21 10:23:14 +09:00
Jemma Issroff
d6abca459f [ruby/yarp] Print locations using line / col instead of offsets
This commit changes printing of locations to use the format
(start_line,start_column)-(end_line,end_column) instead of using
offsets.

c078696e22
2023-09-20 18:30:34 +00:00
Haldun Bayhantopcu
0a630fa461 [ruby/yarp] Check whether the conditional predicate is closed
5022b51db2
2023-09-20 17:50:32 +00:00
Peter Zhu
96c5a4be7b Fix memory leak in complemented method entries
[Bug #19894]

When a copy of a complemented method entry is created, there are two
issues:

1. IMEMO_FL_USER3 is not copied, so the complemented status is not
   copied over.
2. In rb_method_entry_clone we increment both alias_count and
   complemented_count. However, when we free the method entry in
   rb_method_definition_release, we only decrement one of the two
   counters, resulting in the rb_method_definition_t being leaked.

Co-authored-by: Adam Hess <adamhess1991@gmail.com>
2023-09-20 10:19:24 -04:00
Samuel Giddins
843c83ee5f [rubygems/rubygems] Give up, load Time via Marshal.load
6c92ba2ba3
2023-09-20 02:03:04 +00:00
Samuel Giddins
f4a5fac0d2 [rubygems/rubygems] Ruby 2.6 compat
1a84960af3
2023-09-20 02:03:04 +00:00
Samuel Giddins
cadca9f67e [rubygems/rubygems] All rubies working with different time zones
Tested with:

`ruby -e 'trap("INT") { exit 1 }; TZ=%w[UTC +0000 -0000]; RUBY=%w[ruby-2.7 ruby-3.2.2 jruby-9.4 truffleruby-22 truffleruby-23]; TZ.product(RUBY).each { |t, r| puts ?**120, "TZ=#{t} RUBY=#{r}", "*"*120; system({"TZ"=>t,"RUBY"=>r}, *ARGV) }' zsh -lic 'chruby $RUBY; ruby -vw -Ilib test/rubygems/test_gem_safe_marshal.rb --verbose=progress'`

6192005afb
2023-09-20 02:03:03 +00:00
Samuel Giddins
c65c88e65c [rubygems/rubygems] Tests passing on truffleruby 22 in addition to 23
8065530d43
2023-09-20 02:03:03 +00:00
Samuel Giddins
d3628e6ac4 [rubygems/rubygems] safe_load tests passing on jruby & truffleruby
a64b21b052
2023-09-20 02:03:02 +00:00
Samuel Giddins
1fff3e44ff [rubygems/rubygems] Verified working on mri/jruby/truffleruby with specs on rubygems.org
4f51741cc6
2023-09-20 02:03:00 +00:00
Samuel Giddins
cdcc760dc0 [rubygems/rubygems] Broader version compatibility in marshal tests
6ec518c563
2023-09-20 02:02:59 +00:00
Samuel Giddins
c80a4d453a [rubygems/rubygems] Fix UTC time loading
2a4d0a44b0
2023-09-20 02:02:58 +00:00
Samuel Giddins
d182d83ce9 [rubygems/rubygems] Add a Marshal.load replacement that walks an AST to safely load permitted classes/symbols
7e4478fe73
2023-09-20 02:02:58 +00:00
Matt Valentine-House
7dee7e6116 [YARP] Implement GlobalVariableTargetNode 2023-09-19 19:52:32 +01:00
Benoit Daloze
3fadb66bf1 [ruby/yarp] Only use Ripper on CRuby
9c23f53d7b
2023-09-19 17:20:15 +00:00
Jemma Issroff
a71001d341 [ruby/yarp] Ignore parseing specific files on TruffleRuby to make CI green
CI is currently failing due to an issue with Ripper on the latest
TruffleRuby version. This commit removes the offending tests from
running, to ensure CI is green again.

dae2c80c42
2023-09-19 16:43:24 +00:00
Mike Dalessio
0cda3ac454 [ruby/yarp] fix: handling escaped whitespace in a %w list
Introduces a new flavor of unescaping, YP_UNESCAPE_WHITESPACE, which
is the same as MINIMAL but also unescapes whitespace.

Note that a spanning_heredoc.txt fixture test is updated to be less
wrong, but YARP's behavior doesn't yet fully match Ruby in this case.

Fixes https://github.com/ruby/yarp/pull/1505

0af69bdeb1
2023-09-19 16:14:31 +00:00
Kevin Newton
2531ba4ba0 [ruby/yarp] Consistently place block arguments on block slot for call
fe208302e5
2023-09-19 16:13:08 +00:00
Matt Valentine-House
5c5391f444 [YARP] Implement ClassVariableTargetNode 2023-09-19 14:54:15 +01:00
Matt Valentine-House
2f8daa5f51 [YARP] Implement InstanceVariableTargetNode, LocalVariableTargetNode 2023-09-19 14:53:58 +01:00
Matt Valentine-House
91b10c0b77 [YARP] Implement ConstantTargetNode 2023-09-19 14:53:39 +01:00
Hiroshi SHIBATA
b33e9f637d [ruby/securerandom] Removed extra argument for build failure of ruby/ruby
1690982915

f60582432c
2023-09-19 02:22:15 +00:00
nick evans
dfb2b4cbc9 [ruby/securerandom] Add support for UUID version 7
Although the specification for UUIDv7 is still in draft, the UUIDv7
algorithm has been relatively stable as it progresses to completion.

Version 7 UUIDs can be very useful, because they are lexographically
sortable, which can improve e.g: database index locality.  See section
6.10 of the draft specification for further explanation:

  https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/

The specification allows up to 12 bits of extra timestamp precision, to
make UUID generation closer to monotonically increasing.  This provides
between 1ms and ~240ns of timestamp precision.  At the cost of some code
complexity and a small performance penalty, a kwarg may specify any
arbitrary precision between 0 and 12 extra bits.  Any stronger
guarantees of monotonicity have considerably larger tradeoffs, so
nothing more is implemented.  This limitation is documented.

Ruby issue: https://bugs.ruby-lang.org/issues/19735

34ed1a2ec3
2023-09-19 01:55:27 +00:00
Kevin Newton
1636f6abd6 [ruby/yarp] Use compact_child_nodes where possible
c1911fa9b1
2023-09-18 17:48:52 +00:00
Jemma Issroff
54e676a88b
[YARP] Restructure tests to compare YARP evaluation to CRuby evaluation (#8467)
Previously, we were hardcoding the expected evaluation value. Now,
instead, we structure it so that we compare the YARP evaluation value
against CRuby's evaluation value.
2023-09-18 12:34:20 -04:00
Nobuyoshi Nakada
c87f2a4f15
[Bug #19887] RUBYOPT should work without leading - 2023-09-18 10:14:46 +09:00
Nobuyoshi Nakada
5c6e00b090
Simplify restoring ENV 2023-09-18 09:55:07 +09:00
tomoya ishida
8b4e54f979 [ruby/irb] Test should not depend on user's irbrc file specified by
ENV['IRBRC']
(https://github.com/ruby/irb/pull/717)

1d2d35dd33
2023-09-17 21:25:49 +00:00
tomoya ishida
cd67c0d204 [ruby/irb] Test should not depend on user's irbrc file
(https://github.com/ruby/irb/pull/714)

02703c46f9
2023-09-16 22:27:04 +00:00
Jeremy Evans
25711683e8 Fix regression when testing inclusion in unbounded ranges
Caused by 04a92a6764.  This treats
unbounded ranges of arbitrary objects the same as how unbounded
string ranges are treated:

  (..x)  === y  # (y <=> x) <= 0
  (...x) === y  # (y <=> x) <  0
  (x..)  === y  # (x <=> y) <= 0

Fixes [Bug #19864]
2023-09-16 16:02:31 +01:00
Chad Schroeder
a8afedce6d [ruby/irb] Handle Concurrent Sessions and Saving Readline::HISTORY
(https://github.com/ruby/irb/pull/651)

* handle concurrent sessions and saving Readline::HISTORY, fixes https://github.com/ruby/irb/pull/510

* separate tests

* don't mutate the HISTORY object on the class

* avoid repeated .to_i calls

* remove intermediary history array

* work with array, fix test comment

---------

1681ada328

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-09-16 12:48:32 +00:00
Nobuyoshi Nakada
b4213a73b8 [Feature #19839] Fix Range#overlap? for empty ranges
Empty ranges do not overlap with any range.

Regarding benchmarks, PR#8242 is significantly faster in some cases,
but one of these two cases is a wrong result.

|                           |ActiveSupport| PR#8242|built-ruby|
|:--------------------------|------------:|-------:|---------:|
|(2..3).overlap?(1..1)      |       7.761M| 15.053M|   32.368M|
|                           |            -|   1.94x|     4.17x|
|(2..3).overlap?(2..4)      |      25.720M| 55.070M|   21.981M|
|                           |        1.17x|   2.51x|         -|
|(2..3).overlap?(4..5)      |       7.616M| 15.048M|   21.730M|
|                           |            -|   1.98x|     2.85x|
|(2..3).overlap?(2..1)      |      25.585M| 56.545M|   32.786M|
|                           |            -|   2.21x|     1.28x|
|(2..3).overlap?(0..1)      |       7.554M| 14.755M|   32.545M|
|                           |            -|   1.95x|     4.31x|
|(2..3).overlap?(...1)      |       6.681M|  5.843M|   32.255M|
|                           |        1.14x|       -|     5.52x|
|(2...3).overlap?(..2)      |       6.676M|  5.817M|   21.572M|
|                           |        1.15x|       -|     3.71x|
|(2...3).overlap?(3...)     |       7.392M| 14.755M|   31.805M|
|                           |            -|   2.00x|     4.30x|
|(2..3).overlap?('a'..'d')  |       3.675M|  3.482M|   17.009M|
|                           |        1.06x|       -|     4.89x|
2023-09-16 17:24:21 +09:00
Shouichi Kamiya
e9b503f1bb [Feature #19839] Add Range#overlap?
Add a method that returns true if two range overlap, otherwise false.

```
(0..10).overlap?(5..15) #=> true
(0..10).overlap?(20..30) #=> false
```
2023-09-16 14:57:19 +09:00
Kevin Newton
cb686b9ccc [ruby/yarp] Handle missing clauses in case statement
1ad7fba5ef
2023-09-15 23:32:05 +00:00
Kevin Newton
4c28a61e83 [ruby/yarp] Ensure multi targets are only in valid locations
8bffb8a762
2023-09-15 23:21:36 +00:00
Kevin Newton
1be64e34d0 [ruby/yarp] Alnum cannot be %-literal delimiters
4ba6d5ca70
2023-09-15 22:59:48 +00:00
Kevin Newton
18780c22f6 [ruby/yarp] Properly handle invalid underscores in number literals
35da3d1a4c
2023-09-15 22:38:58 +00:00
Kevin Newton
b848700ccf [ruby/yarp] Extract test listener to its own class
c8caa997c0
2023-09-15 22:36:22 +00:00
Vinicius Stock
35960ce65e [ruby/yarp] Add node event dispatcher
This commit changes the node template to create a dispatcher class,
which can be used to walk an AST an emit events to all registered
listeners

03a45f85e6

Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
2023-09-15 22:36:22 +00:00
Kevin Newton
c2f7dae317 [ruby/yarp] Handle unterminated interpolated symbol
9222faa1c6
2023-09-15 22:24:50 +00:00
Kevin Newton
d2c75bb937 [ruby/yarp] Handle missing terminators in parenthesized expression
a8b54e8ed0
2023-09-15 22:24:38 +00:00
Kevin Newton
ffe77c022c [ruby/yarp] Handle infinite opt terms after missing case predicate
d931e258d1
2023-09-15 22:24:25 +00:00
Andy Waite
bbf9f11ce6 [ruby/yarp] Fix behaviour of locations for comments
b1ced67fba
2023-09-15 22:22:24 +00:00
Tim Morgan
101ac364a5 [ruby/yarp] Return Regexp options that match MRI for e, u, s, and n
17dbf4ec46
2023-09-15 21:47:27 +00:00
Jemma Issroff
4012ba4ecf [ruby/yarp] Fix string delimiter with "@" confused for embedded
variable
(https://github.com/ruby/yarp/pull/1521)

3ec0699622
2023-09-15 18:02:04 +00:00
Kevin Newton
28fe88468d [ruby/yarp] Add more tests for implicit hash values
1ddd74dc11
2023-09-15 15:41:02 +00:00