summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2021-12-06[rubygems/rubygems] Allow using `Gem::Version` without loading the rest of ↵David Rodríguez
rubygems https://github.com/rubygems/rubygems/commit/1b862537a5
2021-12-06[rubygems/rubygems] Fix incorrect quotingDavid Rodríguez
Test was just returning a string instead of actually exercising the require. https://github.com/rubygems/rubygems/commit/62c827d7e1
2021-12-06[rubygems/rubygems] add login & logout for the signin & signout commands ↵Colby Swandale
respectively https://github.com/rubygems/rubygems/commit/49b491970b
2021-12-06[rubygems/rubygems] LOAD_PATH is already reset globallyDavid Rodríguez
https://github.com/rubygems/rubygems/commit/b0bbb27115
2021-12-06[rubygems/rubygems] Remove unneded setupDavid Rodríguez
https://github.com/rubygems/rubygems/commit/9815a04e31
2021-12-05[ruby/securerandom] Remove no longer used helper methodsNobuyoshi Nakada
Unused since r59801, 782b2050b837206d06767d42d0ea5117921247c8, or https://github.com/ruby/securerandom/commit/52c8e7a85e017f. https://github.com/ruby/securerandom/commit/38fc2c4427
2021-12-05Do not use `fcopyfile` if appending to non-empty file [Bug #18388]Nobuyoshi Nakada
`fcopyfile` appends `src` to `to` and then truncates `to` to it's original size.
2021-12-05[rubygems/rubygems] Don't write outside of destdir when regenerating pluginsDavid Rodríguez
https://github.com/rubygems/rubygems/commit/141ef4cb9a
2021-12-05[rubygems/rubygems] Don't write outside of destdir when installing default ↵David Rodríguez
bundler https://github.com/rubygems/rubygems/commit/a62d00c5e8
2021-12-03TestClass#test_subclass_gc reduce the number of iteration by 10xJean Boussier
The test was taking 10 seconds on my machine and did timeout on CI once. Notes: Merged: https://github.com/ruby/ruby/pull/5205
2021-12-03Add tests of string argument to Time.atNobuyoshi Nakada
2021-12-02Lazily create singletons on instance_{exec,eval} (#5146)John Hawthorn
* Lazily create singletons on instance_{exec,eval} Previously when instance_exec or instance_eval was called on an object, that object would be given a singleton class so that method definitions inside the block would be added to the object rather than its class. This commit aims to improve performance by delaying the creation of the singleton class unless/until one is needed for method definition. Most of the time instance_eval is used without any method definition. This was implemented by adding a flag to the cref indicating that it represents a singleton of the object rather than a class itself. In this case CREF_CLASS returns the object's existing class, but in cases that we are defining a method (either via definemethod or VM_SPECIAL_OBJECT_CBASE which is used for undef and alias). This also happens to fix what I believe is a bug. Previously instance_eval behaved differently with regards to constant access for true/false/nil than for all other objects. I don't think this was intentional. String::Foo = "foo" "".instance_eval("Foo") # => "foo" Integer::Foo = "foo" 123.instance_eval("Foo") # => "foo" TrueClass::Foo = "foo" true.instance_eval("Foo") # NameError: uninitialized constant Foo This also slightly changes the error message when trying to define a method through instance_eval on an object which can't have a singleton class. Before: $ ruby -e '123.instance_eval { def foo; end }' -e:1:in `block in <main>': no class/module to add method (TypeError) After: $ ./ruby -e '123.instance_eval { def foo; end }' -e:1:in `block in <main>': can't define singleton (TypeError) IMO this error is a small improvement on the original and better matches the (both old and new) message when definging a method using `def self.` $ ruby -e '123.instance_eval{ def self.foo; end }' -e:1:in `block in <main>': can't define singleton (TypeError) Co-authored-by: Matthew Draper <matthew@trebex.net> * Remove "under" argument from yield_under * Move CREF_SINGLETON_SET into vm_cref_new * Simplify vm_get_const_base * Fix leaf VM_SPECIAL_OBJECT_CONST_BASE Co-authored-by: Matthew Draper <matthew@trebex.net> Notes: Merged-By: jhawthorn <john@hawthorn.email>
2021-12-03[ruby/irb] Examine indentation of in keyword when trying to type includeKaíque Kandy Koga
Use in_keyword_case_scope? Return fast https://github.com/ruby/irb/commit/8acc7f8dc7
2021-12-02Compatibility with IRBschneems
Instead of accessing the struct as an array, access it via methods. There are other places inside of this file already using this API (for example https://github.com/ruby/ruby/blob/e0a5c3d2b71dfad038d7562fdd33f02ffd79232d/lib/irb/ruby-lex.rb#L829-L830). This commit moves all struct array-ish calls to use their method calls instead. It is also ~1.23 faster accessing values via a method instead of as an array according to this microbenchmark: ```ruby Elem = Struct.new(:pos, :event, :tok, :state, :message) do def initialize(pos, event, tok, state, message = nil) super(pos, event, tok, State.new(state), message) end # ... def to_a a = super a.pop unless a.empty? a end end class ElemClass attr_accessor :pos, :event, :tok, :state, :message def initialize(pos, event, tok, state, message = nil) @pos = pos @event = event @tok = tok @state = State.new(state) @message = message end def to_a if @message [@pos, @event, @tok, @state, @message] else [@pos, @event, @tok, @state] end end end # stub state class creation for now class State; def initialize(val); end; end ``` ```ruby Benchmark.ips do |x| x.report("struct") { struct[1] } x.report("class ") { from_class.event } x.compare! end; nil ``` ``` Warming up -------------------------------------- struct 1.624M i/100ms class 1.958M i/100ms Calculating ------------------------------------- struct 17.139M (± 2.6%) i/s - 86.077M in 5.025801s class 21.104M (± 3.4%) i/s - 105.709M in 5.015193s Comparison: class : 21103826.3 i/s struct: 17139201.5 i/s - 1.23x (± 0.00) slower ``` Notes: Merged: https://github.com/ruby/ruby/pull/5093
2021-12-01Don't call + and < in Integer.times for !FIXNUMJeremy Evans
The methods aren't called for FIXNUM, and it's best to have consistent behavior. Fixes [Bug #18377] Notes: Merged: https://github.com/ruby/ruby/pull/5199
2021-12-01Rework tracing for blocks running as methodsAlan Wu
The main impetus for this change is to fix [Bug #13392]. Previously, we fired the "return" TracePoint event after popping the stack frame for the block running as method (BMETHOD). This gave undesirable source location outputs as the return event normally fires right before the frame going away. The iseq for each block can run both as a block and as a method. To accommodate that, this commit makes vm_trace() fire call/return events for instructions that have b_call/b_return events attached when the iseq is running as a BMETHOD. The logic for rewriting to "trace_*" instruction is tweaked so that when the user listens to call/return events, instructions with b_call/b_return become trace variants. To continue to provide the return value for non-local returns done using the "return" or "break" keyword inside BMETHODs, the stack unwinding code is tweaked. b_return events now provide the same return value as return events for these non-local cases. A pre-existing test deemed not providing a return value for these b_return events as a limitation. This commit removes the checks for call/return TracePoint events that happen when calling into BMETHODs when no TracePoints are active. Technically, migrating just the return event is enough to fix the bug, but migrating both call and return removes our reliance on `VM_FRAME_FLAG_FINISH` and re-entering the interpreter when the caller is already in the interpreter. Notes: Merged: https://github.com/ruby/ruby/pull/4637
2021-12-02[rubygems/rubygems] Provide distinguished name which will be correctly parsed.Vít Ondruch
It seems that since ruby openssl 2.1.0 [[1]], the distinguished name submitted to `OpenSSL::X509::Name.parse` is not correctly parsed if it does not contain the first slash: ~~~ $ ruby -v ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux] $ gem list | grep openssl openssl (default: 2.2.0) $ irb -r openssl irb(main):001:0> OpenSSL::X509::Name.parse("CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE) => "CN = nobody/DC=example" irb(main):002:0> OpenSSL::X509::Name.parse("/CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE) => "CN = nobody, DC = example" ~~~ Instead, use `OpenSSL::X509::Name.new` directly as suggested by upstream maintainer. [1]: https://github.com/ruby/openssl/commit/19c67cd10c57f3ab7b13966c36431ebc3fdd653b https://github.com/rubygems/rubygems/commit/09ca0c2dae Co-authored-by: Kazuki Yamaguchi <k@rhe.jp>
2021-12-01Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbdHiroshi SHIBATA
2021-11-30[rubygems/rubygems] Fix race condition when reading & writing gemspecs ↵David Rodríguez
concurrently When bundler parallel installer installs gems concurrently, one can get confusing warnings like the following: ``` "[/home/runner/work/rubygems/rubygems/bundler/tmp/2/gems/system/specifications/zeitwerk-2.4.2.gemspec] isn't a Gem::Specification (NilClass instead). ``` I've got these warnings several times in the past, but I never managed to reproduce them, and never look deeply into the root cause, but this time a got a cause that reproduced quite frequently, so I looked into it. The problem is one thread reading a gemspec while another thread is writing it. The write of the gemspec was not protected, so `Gem::Specification.load` could end up seeing a truncated gemspec and thus throw this warning. The fix involve two changes: * Change the methods that write gemspecs to use `Gem.binary_write` which is protected by a lock. * Fix `Gem.binary_write` to create the file lock at file creation time, not when the file already exists after. The realworld user problem caused by this issue happens in bundler, but I'm fixing it in rubygems first, and then I'll backport to bundler whatever needs backporting to fix the issue on the bundler side. https://github.com/rubygems/rubygems/commit/a672e7555c
2021-11-30[rubygems/rubygems] Revert "Remove spec file before building"David Rodríguez
This reverts commit af604436d8141c34cb2e1e645b9b0d47bfd55a55. The issue that led to introducing it was never reproduced. I tried to repro with this patch and it still works just fine. Since this removal is getting in the middle for some race conditions I'm facing, I'm reverting the patch. https://github.com/rubygems/rubygems/commit/2dd267f0e4
2021-11-30[rubygems/rubygems] Run hooks tests on gemspecs not already installedDavid Rodríguez
The current `setup_base_installer` ends up using the `quick_gem` helper, which leaves the created specification installed. Instead, make sure to use the `util_spec` helper, which does a similar thing but doesn't leave the specification installed. The idea is that tests do not rely on the installer removing existing gemspecs, bacause I plan to stop doing that. https://github.com/rubygems/rubygems/commit/843f1a0abc
2021-11-30Revert "test/socket/test_socket.rb: skip on Solaris"Naohisa Goto
This reverts commit 27fb9d272daaae89089dfb61849ebe8e7aa6c833. The test failure on Solaris 10 is due to incomplete IPv6 configuration on the CI server, that have already been fixed. Reference for the fix: https://centrify.force.com/support/Article/KB-1179-X11-Forwarding-fails-with-Centrify-OpenSSH-5-0-Solaris/
2021-11-29Simplify platform check for Windows-UCRTLars Kanis
RUBY_PLATFORM can be used since commit 576b2e64cdc5ea42ad345dd3c1c215e006c06fca . Notes: Merged: https://github.com/ruby/ruby/pull/5168
2021-11-26fix to choose correct callcacheKoichi Sasada
It should retun general `cc`, not for overloaded (mandatory only) method call cache. This issue is reported by @shugo and @ktou https://twitter.com/shugomaeda/status/1463699797182119936 Notes: Merged: https://github.com/ruby/ruby/pull/5173
2021-11-25YJIT: Implement new struct accessors (#5161)John Hawthorn
* YJIT: Implement optimized_method_struct_aref * YJIT: Implement struct_aref without method call Struct member reads can be compiled directly into a memory read (with either one or two levels of indirection). * YJIT: Implement optimized struct aset * YJIT: Update tests for struct access * YJIT: Add counters for remaining optimized methods * Check for INT32_MAX overflow It only takes a struct with 0x7fffffff/8+1 members. Also add some cheap compile time checks. * Add tests for non-embedded struct aref/aset Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged-By: jhawthorn <john@hawthorn.email>
2021-11-25Revert "Add GC.stat_size_pool to get stats for a size pool"Peter Zhu
This reverts commit 6157619bb68e4307cdf065cb73d5bfcec30d042d. We'll wait for comments in the open ticket: https://bugs.ruby-lang.org/issues/18364 Notes: Merged: https://github.com/ruby/ruby/pull/5176
2021-11-25Add GC.stat_size_pool to get stats for a size poolPeter Zhu
GC.stat_size_pool will return stats for a particular size pool. This is used for the Variable Width Allocation feature. Notes: Merged: https://github.com/ruby/ruby/pull/5169
2021-11-25[ruby/win32ole] Scale timeout in win32oleNobuyoshi Nakada
https://github.com/ruby/win32ole/commit/7e04d0eb3e Notes: Merged: https://github.com/ruby/ruby/pull/5175
2021-11-25[ruby/win32ole] Fix typos [ci skip]Nobuyoshi Nakada
https://github.com/ruby/win32ole/commit/8d46bd0c93 Notes: Merged: https://github.com/ruby/ruby/pull/5175
2021-11-25test/ruby/test_iseq.rb: Avoid pollution of method namespaceYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20211125T003004Z.log.html.gz ``` [ 4780/21204] TestISeq#test_super_with_anonymous_block/home/chkbuild/chkbuild/tmp/build/20211125T003004Z/ruby/test/ruby/test_iseq.rb:141: warning: method redefined; discarding old touch3 /home/chkbuild/chkbuild/tmp/build/20211125T003004Z/ruby/test/ruby/test_iseq.rb:121: warning: previous definition of touch3 was here = 0.00 s ```
2021-11-24[ruby/zlib] [Bug #18358] Fix crash in zlib when in progressPeter Zhu
When Zlib::Inflate#inflate or Zlib::Deflate#deflate is called recursively inside the block, a crash can occur because of an use-after-free bug. https://github.com/ruby/zlib/commit/50fb8a0338
2021-11-24[ruby/cgi] When parsing cookies, only decode the valuesNobuyoshi Nakada
https://github.com/ruby/cgi/commit/052eb3a828
2021-11-24test/ruby/test_iseq.rb: Use __LINE__ to make the error log easy to seeYusuke Endoh
2021-11-23Add setclassvariable to yjit (#5127)Eileen M. Uchitelle
Implements setclassvariable in yjit. Note that this version is not faster than the standard version because we aren't handling the inline cache in assembly. This is still important to implement because it will prevent yjit from exiting in methods that call both a cvar setter and other code that yjit can compile. Co-authored-by: Aaron Patterson tenderlove@ruby-lang.org Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2021-11-23Add an extra failing test case for [Bug #18250]Jean Boussier
The parameter being called `req` specifically causes an assertion error: ``` Assertion failed: (key != 0), function hash_table_raw_insert, file id_table.c, line 153. ``` Renaming the parameter or removing the `*` doesn't reproduce. Notes: Merged: https://github.com/ruby/ruby/pull/5157
2021-11-23Add Class#subclassesJean Boussier
Implements [Feature #18273] Returns an array containing the receiver's direct subclasses without singleton classes. Notes: Merged: https://github.com/ruby/ruby/pull/5045
2021-11-23Suppress the “experimental" warnings for `IO::Buffer`Nobuyoshi Nakada
As this warning is emitted just once per processes, needs in each files when parallel testing.
2021-11-22Avoid assert failure when NULL EC is expectedAlan Wu
After 5680c38c75aeb5cbd219aafa8eb48c315f287d97, postponed job APIs now expect to be called on native threads not managed by Ruby and handles getting a NULL execution context. However, in debug builds the change runs into an assertion failure with GET_EC() which asserts that EC is non-NULL. Avoid the assertion failure by passing `false` for `expect_ec` instead as the intention is to handle when there is no EC. Add a test from John Crepezzi and John Hawthorn to exercise this situation. See GH-4108 See GH-5094 [Bug #17573] Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Crepezzi <john.crepezzi@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/5156 Merged-By: XrXr
2021-11-21[ruby/reline] Correct padding space calculationima1zumi
fix https://github.com/ruby/irb/issues/308 This bug occurred when `dialog.width - calculate_width(s, true)` was negative. When `dialog.width` is shorter than `old_dialog.width`, it calculates how much padding it has to do. However, there are cases where `s` is longer than `dialog.width`, as in the issue. In that case, `padding_space_with_escape_sequences` will crash. Here, `old_dialog.width` is longer than `dialog.width`, so I changed the padding width to `old_dialog.width - dialog.width`. https://github.com/ruby/reline/commit/c581c31e0f
2021-11-21Fix setting struct member by public_sendNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5152
2021-11-19Add YJIT codegen for objtostring (#5149)Adam Hess
This is the minimal correct objtostring implementation in YJIT. For correctness, it is important that to_string not get called on strings or subclasses of string. There is a new test for this behavior. A follow up should implement an optimized version for other types as performed in `vm_objtostring`. Co-authored-by: John Hawthorn <jhawthorn@github.com> Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2021-11-19Fix test_super_with_anonymous_block test to use anonymous blockJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/5147
2021-11-19optimize `Struct` getter/setterKoichi Sasada
Introduce new optimized method type `OPTIMIZED_METHOD_TYPE_STRUCT_AREF/ASET` with index information. Notes: Merged: https://github.com/ruby/ruby/pull/5131
2021-11-18Optimize dynamic string interpolation for symbol/true/false/nil/0-9Jeremy Evans
This provides a significant speedup for symbol, true, false, nil, and 0-9, class/module, and a small speedup in most other cases. Speedups (using included benchmarks): :symbol :: 60% 0-9 :: 50% Class/Module :: 50% nil/true/false :: 20% integer :: 10% [] :: 10% "" :: 3% One reason this approach is faster is it reduces the number of VM instructions for each interpolated value. Initial idea, approach, and benchmarks from Eric Wong. I applied the same approach against the master branch, updating it to handle the significant internal changes since this was first proposed 4 years ago (such as CALL_INFO/CALL_CACHE -> CALL_DATA). I also expanded it to optimize true/false/nil/0-9/class/module, and added handling of missing methods, refined methods, and RUBY_DEBUG. This renames the tostring insn to anytostring, and adds an objtostring insn that implements the optimization. This requires making a few functions non-static, and adding some non-static functions. This disables 4 YJIT tests. Those tests should be reenabled after YJIT optimizes the new objtostring insn. Implements [Feature #13715] Co-authored-by: Eric Wong <e@80x24.org> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: Koichi Sasada <ko1@atdot.net> Notes: Merged: https://github.com/ruby/ruby/pull/5002 Merged-By: jeremyevans <code@jeremyevans.net>
2021-11-18Anonymous block forwarding allows a method to forward a passedJeremy Evans
block to another method without having to provide a name for the block parameter. Implements [Feature #11256] Co-authored-by: Yusuke Endoh mame@ruby-lang.org Co-authored-by: Nobuyoshi Nakada nobu@ruby-lang.org Notes: Merged: https://github.com/ruby/ruby/pull/5051
2021-11-18Make Module#{public,private,protected,module_function} return argumentsJeremy Evans
Previously, each of these methods returned self, but it is more useful to return arguments, to allow for simpler method decorators, such as: ```ruby cached private def foo; some_long_calculation; end ``` Where cached sets up caching for the method. For each of these methods, the following behavior is used: 1) No arguments returns nil 2) Single argument is returned 3) Multiple arguments are returned as an array The single argument case is really the case we are trying to optimize for, for the same reason that def was changed to return a symbol for the method. Idea and initial patch from Herwin Quarantainenet. Implements [Feature #12495] Notes: Merged: https://github.com/ruby/ruby/pull/5037
2021-11-18Expect bool as `sort:` option at glob [Feature #18287]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5084 Merged-By: nobu <nobu@ruby-lang.org>
2021-11-17Allow Kernel#load to load code into a specified moduleJeremy Evans
Instead of always using a new anonymous module for Kernel#load if the wrap argument is not false/nil, use the given module if a module is provided. Implements [Feature #6210] Notes: Merged: https://github.com/ruby/ruby/pull/4986
2021-11-18[rubygems/rubygems] `Gem::Specification.reset` already clears loaded spec cacheDavid Rodríguez
Plus, that method is supposed to be private. https://github.com/rubygems/rubygems/commit/f8a01ddb9f
2021-11-17Add tests for cme NULL crashPeter Zhu
Tests for GitHub PR #5122. Originally in GitHub PR #5121. Notes: Merged: https://github.com/ruby/ruby/pull/5132