summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2024-08-02Show what objects were actually allocated on allocation count testsYusuke Endoh
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 Notes: Merged: https://github.com/ruby/ruby/pull/11295
2024-07-31[ruby/rdoc] Add new ruby parser that uses Prismtomoya ishida
(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 https://github.com/ruby/rdoc/commit/fde99f1be6
2024-07-31Fix leak of AST when Ripper#compile_error jumpsPeter Zhu
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 Notes: Merged: https://github.com/ruby/ruby/pull/11287
2024-07-31[ruby/rdoc] Drop unnecessary `file_name` parameter from `Parser.for`Stan Lo
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. https://github.com/ruby/rdoc/commit/97c497dfbb
2024-07-31Reset the counter for two consecutive runsSatoshi Tagomori
Notes: Merged: https://github.com/ruby/ruby/pull/11284
2024-07-30[rubygems/rubygems] Fix `gem list` regression when a regular gem shadows a ↵David Rodríguez
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`. https://github.com/rubygems/rubygems/commit/10a6b1736e
2024-07-30[rubygems/rubygems] Always leave default gem executables aroundDavid Rodríguez
https://github.com/rubygems/rubygems/commit/775c35e197
2024-07-30Move incorrectly placed testsPeter Zhu
The tests for Integer#ceil was accidentally placed in test_truncate.
2024-07-30Fix ceil when ndigits is largePeter Zhu
[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. Notes: Merged: https://github.com/ruby/ruby/pull/11257
2024-07-30Fix floor when ndigits is largePeter Zhu
[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. Notes: Merged: https://github.com/ruby/ruby/pull/11257
2024-07-30Fix wrong unreachable chunk remove when jump destination label is unremovabletomoya ishida
Notes: Merged: https://github.com/ruby/ruby/pull/11267 Merged-By: nobu <[email protected]>
2024-07-30Use tmpdir for various environments (including Windows)Satoshi Tagomori
Notes: Merged: https://github.com/ruby/ruby/pull/11254
2024-07-30Fix test code and extension to avoid using gvars and Kernel methodsSatoshi Tagomori
Notes: Merged: https://github.com/ruby/ruby/pull/11254
2024-07-30[BUG #20655] Add tests to use rb_ensure and call cont.callSatoshi Tagomori
Notes: Merged: https://github.com/ruby/ruby/pull/11254
2024-07-30Add array test cases for `TestParse#test_define_singleton_error`yui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/11276
2024-07-30Wait for server threads to finishNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11273
2024-07-29[rubygems/rubygems] Bump rb-sysdependabot[bot]
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] <[email protected]> https://github.com/rubygems/rubygems/commit/da7b71d188
2024-07-29Revert moving things to RubyAaron Patterson
This is slowing down benchmarks on x86, so lets revert it for now. Notes: Merged: https://github.com/ruby/ruby/pull/11275
2024-07-29Expand opt_newarray_send to support Array#pack with buffer keyword argRandy Stauner
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 ``` Notes: Merged: https://github.com/ruby/ruby/pull/11249
2024-07-26Fix memory leak in String#start_with? when regexp times outPeter Zhu
[Bug #20653] This commit refactors how Onigmo handles timeout. Instead of raising a timeout error, onig_search will return a ONIGERR_TIMEOUT which the caller can free memory, and then raise a timeout error. This fixes a memory leak in String#start_with when the regexp times out. For example: regex = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001) str = "a" * 1000000 + "x" 10.times do 100.times do str.start_with?(regex) rescue end puts `ps -o rss= -p #{$$}` end Before: 33216 51936 71152 81728 97152 103248 120384 133392 133520 133616 After: 14912 15376 15824 15824 16128 16128 16144 16144 16160 16160 Notes: Merged: https://github.com/ruby/ruby/pull/11247
2024-07-26[ruby/net-http] Removed needless NullWriter classHiroshi SHIBATA
https://github.com/ruby/net-http/commit/ddb2a81aed
2024-07-25Fix test_kwarg_eval_memory_leakPeter Zhu
Hash.new no longer takes keyword arguments except for capacity, so we should just use a method that takes keyword arguments instead. Notes: Merged: https://github.com/ruby/ruby/pull/11246
2024-07-25[ruby/prism] Sync from ruby/rubyKevin Newton
https://github.com/ruby/prism/commit/280517c325
2024-07-25Fix memory leak in Regexp capture group when timeoutPeter Zhu
[Bug #20650] The capture group allocates memory that is leaked when it times out. For example: re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001) str = "a" * 1000000 + "x" 10.times do 100.times do re =~ str rescue Regexp::TimeoutError end puts `ps -o rss= -p #{$$}` end Before: 34688 56416 78288 100368 120784 140704 161904 183568 204320 224800 After: 16288 16288 16880 16896 16912 16928 16944 17184 17184 17200 Notes: Merged: https://github.com/ruby/ruby/pull/11238
2024-07-25Omit TestFile#test_stat when the machine is stupidly slowYusuke Endoh
GitHub Actions macos-14 machine is stupid. https://app.launchableinc.com/organizations/ruby/workspaces/ruby/data/test-paths/file%3Dtest%2Fruby%2Ftest_file.rb%23%23%23class%3DTestFile%23%23%23testcase%3Dtest_stat?organizationId=ruby&workspaceId=ruby&testPathId=file%3Dtest%2Fruby%2Ftest_file.rb%23%23%23class%3DTestFile%23%23%23testcase%3Dtest_stat&testSessionStatus=flake Notes: Merged: https://github.com/ruby/ruby/pull/11241
2024-07-24[ruby/openssl] x509attr: avoid using OpenSSL::ASN1 internals in #value=Kazuki Yamaguchi
OpenSSL::ASN1 is being rewritten in Ruby. To make it easier, let's remove dependency to the instance variables and the internal-use function ossl_asn1_get_asn1type() outside OpenSSL::ASN1. This also fixes the insufficient validation of the passed value with its tagging. https://github.com/ruby/openssl/commit/35a157462e
2024-07-24[Bug #20649] Allow `nil` as 2nd argument of `assign_error`Nobuyoshi Nakada
Fallback to the last token element in that case, for the backward compatibilities. Notes: Merged: https://github.com/ruby/ruby/pull/11235
2024-07-24[Bug #20647] Disallow `return` directly within a singleton classNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11234
2024-07-23[ruby/prism] Single line method bodies should not be marked as newlineKevin Newton
https://github.com/ruby/prism/commit/18a8597276
2024-07-23Implement UNLESS NODE keyword locationsyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/11227
2024-07-23[Feature #20624] Enhance `RubyVM::AbstractSyntaxTree::Node#locations`yui-knk
This commit introduce `RubyVM::AbstractSyntaxTree::Node#locations` method and `RubyVM::AbstractSyntaxTree::Location` class. Ruby AST node will hold multiple locations information. `RubyVM::AbstractSyntaxTree::Node#locations` provides a way to access these locations information. `RubyVM::AbstractSyntaxTree::Location` is a class which holds these location information: * `#first_lineno` * `#first_column` * `#last_lineno` * `#last_column` Notes: Merged: https://github.com/ruby/ruby/pull/11226
2024-07-22[ruby/prism] Implement mismatched indentation warningKevin Newton
https://github.com/ruby/prism/commit/5d5bf92be8
2024-07-22bundled_gems.rb: Add a fast pathJean Boussier
[Bug #20641] `Gem::BUNDLED_GEMS.warning?` adds a lot of extra work on top of `require`. When the call end up atually loading code the overhead is somewhat marginal. However it's not uncommon for code to go some late `require` in some paths, so it's expected that calling `require` with something already required is somewhat fast, and `bundled_gems.rb` breaks this assumption. To avoid this, we can have a fast path that in most case allow to short-circuit all the heavy computations. If we extract the feature basename and it doesn't match any of the bundled gems we care about we can return very early. With this change `require 'date'` is now only 1.33x slower on Ruby 3.3.3, than it was on Ruby 3.2.2, whereas before this change it was at least 100x slower. Notes: Merged: https://github.com/ruby/ruby/pull/11208
2024-07-21Fix a typo in setup of block-after-blockcall testsNobuyoshi Nakada
Unparenthesize the argument and make `command_call` when calling with `do`-block. Notes: Merged: https://github.com/ruby/ruby/pull/11216
2024-07-21Fix SEGV on method call with empty args and brace block for do block command ↵yui-knk
call Notes: Merged: https://github.com/ruby/ruby/pull/11215
2024-07-20Do not set Enumerator::Lazy#zip to use packed formatJeremy Evans
Enumerator#zip yields a single array, not multiple arguments, so Enumerator::Lazy#zip should do the same. Fixes [#20623] Notes: Merged: https://github.com/ruby/ruby/pull/11212
2024-07-18Avoid array allocation for f(*r2k_ary) when def f(x)Jeremy Evans
When calling a method that does not accept a positional splat parameter with a splatted array with a ruby2_keywords flagged hash, there is no need to duplicate the splatted array. Previously, Ruby would duplicate the splatted array and potentially modify it before flattening it to the VM stack Use a similar approach as the f(*ary, **hash) optimization, flattening the splatted array to the VM stack without modifying it, and make any modifications needed to the VM stack. Notes: Merged: https://github.com/ruby/ruby/pull/11161
2024-07-18Avoid hash allocation for f(*r2k_ary) when def f(kw: 1)Jeremy Evans
When calling a method that accepts keywords but not a keyword splat with a splatted array with a ruby2_keywords flagged hash, there is no need to duplicate the ruby2_keywords flagged hash, since it will be accessed to get the keyword values, but it will not be modified. Notes: Merged: https://github.com/ruby/ruby/pull/11161
2024-07-18Check for and remove duplicate checks in test_allocationJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/11161
2024-07-18Avoid array allocation for f(*empty_ary, **hash) when def f(x)Jeremy Evans
This avoids an array allocation when calling a method that does not accept a positional splat or keywords with both a positional splat and keywords. Previously, Ruby would dup the positional splat to append the keyword splat to it. Then it would flatten the dupped positional splat array to the VM stack. This flattens the given positional splat to the VM stack, then adds the keyword splat hash after the last positional splat element on the VM stack, avoiding the need to modify the positional splat array. Notes: Merged: https://github.com/ruby/ruby/pull/11161
2024-07-18Avoid unnecessary array allocations for f(arg, *arg, **arg, **arg), f(*arg, ↵Jeremy Evans
a: lvar), and other calls The `f(arg, *arg, **arg, **arg)` case was previously not optimized. The optimizer didn't optimize this case because of the multiple keyword splats, and the compiler didn't optimize it because the `f(*arg, **arg, **arg)` optimization added in 0ee3960685e283d8e75149a8777eb0109d41509a didn't apply. I found it difficult to apply this optimization without changing the `setup_args_core` API, since by the time you get to the ARGSCAT case, you don't know whether you were called recursively or directly, so I'm not sure if it was possible to know at that point whether the array allocation could be avoided. This changes the dup_rest argument in `setup_args_core` from an int to a pointer to int. This allows us to track whether we have allocated a caller side array for multiple splats or splat+post across recursive calls. Check the pointed value (*dup_rest) to determine the `splatarray` argument. If dup_rest is 1, then use `splatarray true` (caller-side array allocation), then set *dup_rest back to 0, ensuring only a single `splatarray true` per method call. Before calling `setup_args_core`, check whether the array allocation can be avoided safely using `splatarray false`. Optimizable cases are: ``` // f(*arg) SPLAT // f(1, *arg) ARGSCAT LIST // f(*arg, **arg) ARGSPUSH SPLAT HASH nd_brace=0 // f(1, *arg, **arg) ARGSPUSH ARGSCAT LIST HASH nd_brace=0 ``` If so, dup_rest is set to 0 instead of 1 to avoid the allocation. After calling `setup_args_core`, check the flag. If the flag includes `VM_CALL_ARGS_SPLAT`, and the pointed value has changed, indicating `splatarray true` was used, then also set `VM_CALL_ARGS_SPLAT_MUT` in the flag. My initial attempt at this broke the `f(*ary, &ary.pop)` test, because we were not duplicating the ary in the splat even though it was modified later (evaluation order issue). The initial attempt would also break `f(*ary, **ary.pop)` or `f(*ary, kw: ary.pop)` cases for the same reason. I added test cases for those evaluation order issues. Add setup_args_dup_rest_p static function that checks that a given node is safe. Call that on the block pass node to determine if the block pass node is safe. Also call it on each of the hash key/value nodes to test that they are safe. If any are not safe, then set dup_rest = 1 so that `splatarray true` will be used to avoid the evaluation order issue. This new approach has the affect of optimizing most cases of literal keywords after positional splats. Previously, only static keyword hashes after positional splats avoided array allocation for the splat. Now, most dynamic keyword hashes after positional splats also avoid array allocation. Add allocation tests for dynamic keyword keyword hashes after positional splats. setup_args_dup_rest_p is currently fairly conservative. It could definitely be expanded to handle additional node types to reduce allocations in additional cases. Notes: Merged: https://github.com/ruby/ruby/pull/11161
2024-07-19[rubygems/rubygems] Fix line comment issue for mapalpha0x00
https://github.com/rubygems/rubygems/commit/7ca06e139b
2024-07-18[PRISM] Refactor parser support into its own moduleKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11201
2024-07-19[ruby/uri] Also support URI::PATTERN with switch-backHiroshi SHIBATA
https://github.com/ruby/uri/commit/823697edb4
2024-07-19[ruby/uri] Added test for constant definition and remove URI::REGEXP when ↵Hiroshi SHIBATA
using RFC3986_PARSER https://github.com/ruby/uri/commit/6f616d97fc
2024-07-19[ruby/uri] Rename and switch RFC2396_PARSER testHiroshi SHIBATA
https://github.com/ruby/uri/commit/2e0f73f05e
2024-07-19[ruby/uri] Switch to inspect with default parserHiroshi SHIBATA
https://github.com/ruby/uri/commit/0ab9abbf08
2024-07-18[rubygems/rubygems] Fix unused variable warning when running RubyGems testsDavid Rodríguez
https://github.com/rubygems/rubygems/commit/155d8fd051
2024-07-18Refactor RUBY_DESCRIPTION assertions in test_rubyoptionsKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11192
2024-07-18[ruby/irb] Clear ENV["XDG_CONFIG_HOME"] to avoid loadingtomoya ishida
user-defined irbrc in TestIRB::ConfigValidationTest (https://github.com/ruby/irb/pull/982) https://github.com/ruby/irb/commit/632da0ff29