Commit graph

20692 commits

Author SHA1 Message Date
Kevin Newton
eb08a2805c [PRISM] test_invalid_jump assertion updates for prism 2024-08-15 13:34:25 -04:00
Kevin Newton
a402b18c4e [PRISM] test_syntax_check assertion updates for prism 2024-08-15 13:34:25 -04:00
Kevin Newton
5cb6954baa [ruby/prism] Fix up lex result constants
084baca463
2024-08-15 16:50:00 +00:00
Kevin Newton
cbf508da58 [ruby/prism] Special error for too short unicode errors
9f1f7d08bd
2024-08-15 16:40:05 +00:00
Stan Lo
923e36ab21 [ruby/rdoc] Fix sidebar scroll again and add missing footer back
(https://github.com/ruby/rdoc/pull/1154)

* Add missing footers

In #1152 the footer partial was only added to the index.rhtml file.
This commit adds the footer partial to the other template files.

* Remove unnecessary middle divs in nav

* Simplify sidebar's overflow settings

Because sidebar needs to be scrollable, its overflow should default to auto.
Currently it's set to hidden and force individual elements to set overflow auto,
which overcomplicates things.

b8c2bcd8db
2024-08-15 13:33:00 +00:00
Peter Zhu
fd974f5d74 Increase timeout of test_finalizer
The test is timing out on lpi4a so a longer timeout should fix it.
2024-08-14 16:23:22 -04:00
Peter Zhu
0610f1b083 Fix crash when GC runs during finalizers at shutdown
We need to remove from the finalizer_table after running all the
finalizers because GC could trigger during the finalizer which could
reclaim the finalizer table array.

The following code crashes:

    1_000_000.times do
      o = Object.new
      ObjectSpace.define_finalizer(o, proc { })
    end
2024-08-14 13:49:52 -04:00
Naoto Ono
e7046f1f57 Increase the default timeout in assert_darwin_vm_dump_works 2024-08-14 12:24:15 +09:00
Sorah Fukumori
b20957bdfe [ruby/resolv] test_dns: Fix failure on Windows
(https://github.com/ruby/resolv/pull/58)

test_dns: Fix failure on Windows

1. Switch to #with_udp_and_tcp helper method for EACCES retries on Windows;
   the given UDP socket is unnecessary though.
2. Using 127.0.0.1 should be fine, as it must give different host:port pair.
3. On Windows, 5 retries of bind(2) appears still flaky, doubling it for sure.

follow-up: https://github.com/ruby/resolv/pull/50
follow-up: 6252914e95

0a0d57e369
2024-08-13 23:13:10 +00:00
Igor Pstyga
4be9b72fbb [ruby/resolv] Fix TCP fallback with multiple nameservers
Under the following conditions the exception
`Resolv::DNS::Requester::RequestError: host/port don't match` is raised:
- Multiple nameservers are configured for Resolv::DNS
- A nameserver falls back from UDP to TCP
- TCP request hits Resolv::DNS timeout
- Resolv::DNS retries the next nameserver

More details here https://bugs.ruby-lang.org/issues/8285

7d524df80e

Co-authored-by: Julian Mehnle <julian@mehnle.net>
2024-08-13 21:09:08 +00:00
Naoto Ono
436d23f80d Make sure to wait for the thread to exit in TestProcess#test_wait_and_sigchild 2024-08-13 14:47:48 +09:00
Koichi Sasada
d5afa2cc95 do not show unused block on send
Some case it is difficult to know the calling method uses a block
or not with `send` on a general framework. So this patch stops
showing unused block warning on `send`.

example with test/unit:

```ruby
require 'test/unit'

class T < Test::Unit::TestCase
  def setup
  end

  def test_foo = nil
end
```

=> /home/ko1/ruby/install/master/lib/ruby/gems/3.4.0+0/gems/test-unit-3.6.2/lib/test/unit/fixture.rb:284: warning: the block passed to 'priority_setup' defined at /home/ko1/ruby/install/master/lib/ruby/gems/3.4.0+0/gems/test-unit-3.6.2/lib/test/unit/priority.rb:183 may be ignored

because test/unit can call any setup method (`priority_setup` in this case) with a block.

Maybe we can show the warning again when we provide a way to recognize
the calling method uses a block or not.
2024-08-13 12:17:56 +09:00
tompng
992596fb7a Fix next inside block argument stack underflow
[Bug #20344]
Fix compile_next adding removable adjust label
2024-08-12 18:09:32 +09:00
Nobuyoshi Nakada
21a9d7664c
Fix flag test macro
`RBOOL` is a macro to convert C boolean to Ruby boolean.
2024-08-11 02:36:37 +09:00
Jean Boussier
b1f4222fc5 Cherry-pick test for [Bug #20668]
The bug didn't impact master because this was largely refactored,
but it's still valuable to add the test for it to prevent future
regressions.
2024-08-10 12:41:35 +02:00
Peter Zhu
d1474affa8 [ruby/psych] Convert tabs to spaces in test/psych/test_yaml.rb
64bfc308f8
2024-08-09 19:35:29 +00:00
Naoto Ono
f57167d338 Increase timeout in test_darwin_invalid_call method 2024-08-09 12:16:23 +09:00
Hiroshi SHIBATA
68ebd56a76 [ruby/uri] Use URI::RFC2396_PARSER explicitly in URI
898b889811
2024-08-08 02:09:27 +00:00
Peter Zhu
584559d86a Fix leak of token_info when Ripper#warn jumps
For example, the following code leaks:

    class MyRipper < Ripper
      def initialize(src, &blk)
        super(src)
        @blk = blk
      end

      def warn(msg, *args) = @blk.call(msg)
    end

    $VERBOSE = true
    def call_parse = MyRipper.new("if true\n  end\n") { |msg| return msg }.parse

    10.times do
      500_000.times do
        call_parse
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    37536
    53744
    70064
    86448
    102576
    119120
    135248
    151216
    167744
    183824

After:

    19280
    19696
    19728
    20336
    20448
    21408
    21616
    21616
    21824
    21840
2024-08-07 09:14:14 -04:00
Peter Zhu
ced35800d4 Fix leak in warning of duplicate keys when Ripper#warn jumps
For example, the following code leaks:

    class MyRipper < Ripper
      def initialize(src, &blk)
        super(src)
        @blk = blk
      end

      def warn(msg, *args) = @blk.call(msg)
    end

    $VERBOSE = true
    def call_parse = MyRipper.new("if true\n  end\n") { |msg| return msg }.parse

    10.times do
      500_000.times do
        call_parse
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    34832
    51952
    69760
    88048
    105344
    123040
    141152
    159152
    176656
    194272

After:

    18400
    20256
    20272
    20272
    20272
    20304
    20368
    20368
    20368
    20400
2024-08-06 10:19:50 -04:00
Hiroshi SHIBATA
267da552a1 [ruby/uri] Fallback missing constants with RFC3986_PARSER
(https://github.com/ruby/uri/pull/113)

* Fallback missing constants with RFC3986_PARSER

* raise missing constant

* Update test/uri/test_common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Update lib/uri/common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Update lib/uri/common.rb

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

---------

c2fdec079a

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-08-06 09:09:52 +00:00
Kazuki Yamaguchi
65e3717db7 [ruby/openssl] test/openssl/test_pkey_dsa.rb: skip all tests in FIPS mode
OpenSSL running in the FIPS mode will stop supporting DSA key
generation and signature generation due to a FIPS 140-3 requirement.
Although it appears that FIPS 186-5 still allows signature
verification in some cases, there would be little point in writing such
a specific test case.

DSA will still be tested if OpenSSL is not running in the FIPS mode.

test_generate_on_non_fips is merged to test_generate again.

3651884fd2
2024-08-06 06:38:03 +00:00
dependabot[bot]
2985770b05 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.99 to 0.9.100.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.99...v0.9.100)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

dd5df7d614
2024-08-05 17:26:13 +00:00
dependabot[bot]
312a87cde6 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.98 to 0.9.100.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.98...v0.9.100)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

6f05927746
2024-08-05 17:25:58 +00:00
tomoya ishida
dbd36e1c23 [ruby/reline] Accept colon-style hash in test assertion
(https://github.com/ruby/reline/pull/732)

Hash#inspect is proposed to change to {key: value, non_symbol_key => value} in https://bugs.ruby-lang.org/issues/20433#note-10

1fd73b358a
2024-08-05 15:53:45 +00:00
fatkodima
a35d324862 [ruby/optparse] Fix parsing array arguments with :into option
19700e96d8
2024-08-05 02:28:12 +00:00
Stan Lo
cbc40bb130 Sync rdoc 2024-08-05 08:27:45 +08:00
Ricardo Trindade
7d5cb4573d [ruby/irb] Remove Ruby version checks
(https://github.com/ruby/irb/pull/985)

9ce6972e71
2024-08-04 14:53:51 +00:00
Yusuke Endoh
b708661313 Extend timeout in test/ruby/test_file_exhaustive.rb 2024-08-03 16:30:32 +09:00
Yusuke Endoh
42cd267beb Reduce noise in object generation count tests
The parallel testing framework may create strings in a separate thread.

```
    1) Failure:
  TestStringMemory#test_byteslice_prefix [D:/a/ruby/ruby/src/test/ruby/test_string_memory.rb:40]:
  One object allocation is expected, but allocated: [["D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb", 42, String, "2240\x00\x00\x00\x00...
```
2828827119 (step):23:1026
2024-08-03 14:39:17 +09:00
Yusuke Endoh
23837c5170 Show where objects were allocated on allocation count tests 2024-08-03 05:25:28 +09:00
Yusuke Endoh
3f93ef06a8 Show what objects were actually allocated on allocation count tests
According to Launchable, these tests fail randomly

```
Failure:
TestStringMemory#test_byteslice_prefix [D:/a/ruby/ruby/src/test/ruby/test_string_memory.rb:33]:
<1> expected but was
<2>.
```

https://app.launchableinc.com/organizations/ruby/workspaces/ruby/data/test-paths/file%3Dtest%2Fruby%2Ftest_string_memory.rb%23%23%23class%3DTestStringMemory%23%23%23testcase%3Dtest_byteslice_prefix?testSessionStatus=flake
2024-08-02 23:29:28 +09:00
tomoya ishida
16b0242808 [ruby/rdoc] Add new ruby parser that uses Prism
(https://github.com/ruby/rdoc/pull/1144)

* Add a new ruby parser RDoc::Parser::PrismRuby

* Add a new ruby parser testcase independent from parser's internal implementation

* unknown meta method

* Use MethodSignatureVisitor only to scan params, block_params and calls_super

* Add calls_super test

* Drop ruby 2.6. Prism requires ruby >= 2.7

* Remove duplicated documentation comment from prism_ruby.rb

* Add test for wrong argument passed to metaprogramming method

* Rename visit_call_[DSL_METHOD_NAME] to make it distinguishable from visit_[NODE_TYPE]_node

* Method receiver switch of true/false/nil to a case statement

* Extract common part of add_method(by def keyword) and add meta_comment method

* Reuse consecutive comments array when collecting comments

* Simplify DSL call_node handling

* Refactor extracting method visibility arguments

fde99f1be6
2024-07-31 20:50:00 +00:00
Peter Zhu
6358397490 Fix leak of AST when Ripper#compile_error jumps
For example, the following script leaks:

    class MyRipper < Ripper
      def initialize(src, &blk)
        super(src)
        @blk = blk
      end

      def compile_error(msg) = @blk.call(msg)
    end

    def call_parse = MyRipper.new("/") { |msg| return msg }.parse

    10.times do
      100_000.times do
        call_parse
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    93952
    169040
    244224
    318784
    394432
    468224
    544048
    618560
    693776
    768384

After:

    19776
    19776
    20352
    20880
    20912
    21408
    21328
    21152
    21472
    20944
2024-07-31 14:47:44 -04:00
Stan Lo
27c22f822a [ruby/rdoc] Drop unnecessary file_name parameter from Parser.for
method.
(https://github.com/ruby/rdoc/pull/1135)

* Unify top_level creation in tests

* Remove unnecessary file_name param from Parser.for

It should be always the same as the top_level's absolute_name, so there's
no point of taking it as a separate parameter.

97c497dfbb
2024-07-31 14:36:41 +00:00
Satoshi Tagomori
19ec803179 Reset the counter for two consecutive runs 2024-07-31 10:59:51 +09:00
David Rodríguez
1164b6a7ba [rubygems/rubygems] Fix gem list regression when a regular gem shadows a default one
Previously, if you have bundler installed both as a regular gem and a
default gem, the default gem would be displayed by `gem list`.

10a6b1736e
2024-07-30 14:01:43 +00:00
David Rodríguez
3d248b2eb3 [rubygems/rubygems] Always leave default gem executables around
775c35e197
2024-07-30 14:01:32 +00:00
Peter Zhu
b37ffb9345 Move incorrectly placed tests
The tests for Integer#ceil was accidentally placed in test_truncate.
2024-07-30 09:02:23 -04:00
Peter Zhu
a7167d0cee Fix ceil when ndigits is large
[Bug #20654]

This commit fixes Integer#ceil and Float#ceil when the number is
negative and ndigits is large such that 10**ndigits is a bignum.

Previously, it would return 0 in such cases. However, this would cause
unexpected behaviour such as:

    puts 1.ceil(-5) # => 100000
    puts 1.ceil(-10) # => 10000000000
    puts 1.ceil(-20) # => 0

This commit changes the last result so that it will return
100000000000000000000.
2024-07-30 08:21:28 -04:00
Peter Zhu
3af2a7fbe1 Fix floor when ndigits is large
[Bug #20654]

This commit fixes Integer#floor and Float#floor when the number is
negative and ndigits is large such that 10**ndigits is a bignum.

Previously, it would return 0 in such cases. However, this would cause
unexpected behaviour such as:

    puts -1.floor(-5) # => -100000
    puts -1.floor(-10) # => -10000000000
    puts -1.floor(-20) # => 0

This commit changes the last result so that it will return
-100000000000000000000.
2024-07-30 08:21:28 -04:00
tomoya ishida
1870505f47
Fix wrong unreachable chunk remove when jump destination label is unremovable 2024-07-30 15:31:58 +09:00
Satoshi Tagomori
6c5c30b542 Use tmpdir for various environments (including Windows) 2024-07-30 15:31:24 +09:00
Satoshi Tagomori
50a0552bd7 Fix test code and extension to avoid using gvars and Kernel methods 2024-07-30 15:31:24 +09:00
Satoshi Tagomori
c884db0b5b [BUG #20655] Add tests to use rb_ensure and call cont.call 2024-07-30 15:31:24 +09:00
yui-knk
7ea678b24b Add array test cases for TestParse#test_define_singleton_error 2024-07-30 12:48:24 +09:00
Nobuyoshi Nakada
30f57637ee Wait for server threads to finish 2024-07-30 07:33:43 +08:00
dependabot[bot]
0afbc73b2a [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.98 to 0.9.99.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.98...v0.9.99)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

da7b71d188
2024-07-29 23:24:49 +00:00
Aaron Patterson
2c1655314a Revert moving things to Ruby
This is slowing down benchmarks on x86, so lets revert it for now.
2024-07-29 14:18:11 -07:00
Randy Stauner
acbb8d4fb5 Expand opt_newarray_send to support Array#pack with buffer keyword arg
Use an enum for the method arg instead of needing to add an id
that doesn't map to an actual method name.

$ ruby --dump=insns -e 'b = "x"; [v].pack("E*", buffer: b)'

before:

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,34)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] b@0
0000 putchilledstring                       "x"                       (   1)[Li]
0002 setlocal_WC_0                          b@0
0004 putself
0005 opt_send_without_block                 <calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0007 newarray                               1
0009 putchilledstring                       "E*"
0011 getlocal_WC_0                          b@0
0013 opt_send_without_block                 <calldata!mid:pack, argc:2, kw:[#<Symbol:0x000000000023110c>], KWARG>
0015 leave
```

after:

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,34)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] b@0
0000 putchilledstring                       "x"                       (   1)[Li]
0002 setlocal_WC_0                          b@0
0004 putself
0005 opt_send_without_block                 <calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0007 putchilledstring                       "E*"
0009 getlocal                               b@0, 0
0012 opt_newarray_send                      3, 5
0015 leave
```
2024-07-29 16:26:58 -04:00