Commit graph

15017 commits

Author SHA1 Message Date
Nobuyoshi Nakada
d09f097eec
Time#getlocal tests for [Feature #17544] 2021-06-15 21:42:55 +09:00
Eileen M. Uchitelle
2088a45798
[Bug #17880] Set leaf false on opt_setinlinecache (#4565)
This change fixes the bug described in https://bugs.ruby-lang.org/issues/17880.

Checking `ractor_shareable_p` will cause the method to call back into
Ruby. Anything calling this method can't be a leaf instruction,
otherwise it could crash. By adding `attr bool leaf = false` we no
longer crash because it marks the function as not a leaf.

Here's a simplified reproduction script:

```ruby
require "set"

class Id
  attr_reader :db_id
  def initialize(db_id)
    @db_id = db_id
  end

  def ==(other)
    other.class == self.class && other.db_id == db_id
  end
  alias_method :eql?, :==

  def hash
    10
  end

  def <=>(other)
    db_id <=> other.db_id if other.is_a?(self.class)
  end
end

class Namespace
  IDS = Set[
    Id.new(1).freeze,
    Id.new(2).freeze,
    Id.new(3).freeze,
    Id.new(4).freeze,
  ].freeze

  class << self
    def test?(id)
      IDS.include?(id)
    end
  end
end

p Namespace.test?(Id.new(1))
p Namespace.test?(Id.new(5))
```

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2021-06-14 17:34:57 -07:00
Marc-Andre Lafortune
a09ddfc420 [lib/ostruct] Fix YAML test 2021-06-14 12:28:53 -04:00
Marc-Andre Lafortune
52369fc545 [lib/ostruct] Allow overriding of block_given? 2021-06-14 12:28:53 -04:00
Nobuyoshi Nakada
edbe0e224c
Suppress exception report in inner thread 2021-06-15 00:03:05 +09:00
Nobuyoshi Nakada
57eaa07ba6
Close leaked file descriptors 2021-06-15 00:02:15 +09:00
jfrazx
931ea7cfbe
Add fallback block to OpenStruct#delete_field (#1409) 2021-06-14 09:53:20 -04:00
Bruno Sutic
1ab71a5b98 Fix fiber scheduler address resolve solaris tests 2021-06-14 22:09:23 +12:00
Samuel Williams
050a895439
Wake up join list within thread EC context. (#4471)
* Wake up join list within thread EC context.

* Consume items from join list so that they are not re-executed.

If `rb_fiber_scheduler_unblock` raises an exception, it can result in a
segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This
change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC
which initially caused an infinite loop because on exception will retry. We
explicitly remove items from the thread's join list to avoid this situation.

* Verify the required scheduler interface.

* Test several scheduler hooks methods with broken `unblock` implementation.
2021-06-14 17:56:53 +12:00
Samuel Williams
2792acc8f2
Add scheduler hook Addrinfo.getaddrinfo. (#4375)
Co-authored-by: Bruno Sutic <code@brunosutic.com>
2021-06-14 16:21:08 +12:00
Jeremy Evans
117310bdc0
Make ENV.clone warn and ENV.dup raise
ENV.dup returned a plain Object, since all of ENV's behavior is
defined in ENV's singleton class.  So using dup makes no sense.

ENV.clone works and is used in some gems, but it doesn't do what
the user expects, since modifying ENV.clone also modifies ENV.
Add a deprecation warning pointing the user to use ENV.to_h
instead.

This also undefines some private initialize* methods in ENV,
since they are not needed.

Fixes [Bug #17767]
2021-06-08 10:19:08 -07:00
Yusuke Endoh
8c87efaa8a [ruby/psych] Fix the test that does not work with libyaml-0.1.7
542cf9754f
2021-06-08 08:12:27 +09:00
Hiroshi SHIBATA
bb4a10208c
Do not use YAML module in tests of Psych 2021-06-07 19:24:20 +09:00
Hiroshi SHIBATA
d7146dfd7d
Use assert_raise instead of assert_raises 2021-06-07 19:21:41 +09:00
Jean Boussier
fd6225c7a9
[ruby/psych] Implement YAML.safe_dump to make safe_load more usable.
In case where Psych is used as a two way serializers,
e.g. to serialize some cache or config, it is preferable
to have the same restrictions on both load and dump.

Otherwise you might dump and persist some objects payloads
that you later won't be able to read.

441958396f
2021-06-07 19:15:14 +09:00
Nobuyoshi Nakada
9f3888d6a3 Warn more duplicate literal hash keys
Following non-special_const literals:
* T_REGEXP
2021-06-03 15:11:18 +09:00
Nobuyoshi Nakada
37eb5e7439 Warn more duplicate literal hash keys
Following non-special_const literals:
* T_BIGNUM
* T_FLOAT (non-flonum)
* T_RATIONAL
* T_COMPLEX
2021-06-03 15:11:18 +09:00
Nobuyoshi Nakada
a023db49bf Assertions for duplicate literal hash key warnings 2021-06-03 15:11:18 +09:00
Yusuke Endoh
b957c3dbcb [rubygems/rubygems] Rename test/rubygems/test_{case,utilities}.rb to avoid "test_" prefix
This changes "test/rubygems/test_case.rb" to "test/rubygems/helper.rb",
and "test/rubygems/test_utilities.rb" to "test/rubygems/utilities.rb".

The two files are a helper for tests, not test files. However, a file
starting with "test_" prefix is handled as a test file directly loaded
by test-unit because Rakefile specifies:

```
t.test_files = FileList['test/**/test_*.rb']
```

Directly loading test/rubygems/test_utilities.rb caused "uninitialized
constant Gem::TestCase". This issue was fixed by
59c6820971, but the fix caused a
"circular require" warning because test_utilities.rb and test_case.rb
are now requiring each other.

Anyway, adding "test_" prefix to a test helper file is confusing, so
this changeset reverts the fix and solve the issue by renaming them.

6460e018df
2021-06-03 12:23:22 +09:00
aycabta
77e1b47729 [ruby/rdoc] Add an alias for test-unit with older versions of RubyGems
b8d68fdd87
2021-06-02 11:35:45 +09:00
Nobuyoshi Nakada
9024c7f1bb
Make Thread#native_thread_id not-implemented if unsupported
Raise `NotImplementedError` on unsupported platforms regardless
the argument consistently.
2021-06-01 22:27:13 +09:00
aycabta
c9ab8fe2b1 The test for command injection on Unix platforms should be omitted on Windows 2021-05-31 23:34:40 +09:00
Jeremy Evans
fd65ef2a5a Attempt to fix floating point test failure
The previous behavior depending on exact float values, it seemed
to work OK on amd64 and i386, but other CI platforms are
experiencing non-deterministic test failures with it. Relax test
slightly to hopefully pass on such platforms.
2021-05-29 14:08:24 -07:00
Jeremy Evans
f516379853 Fix Enumerator::ArithmeticSequence handling of float ranges
Depending on the float range, there could be an off-by-one error,
where the last result that should be in the range was missed. Fix
this by checking if the computed value for the expected value
outside the range is still inside the range, and if so, increment
the step size.

Fixes [Bug #16612]
2021-05-29 08:56:15 -07:00
Alan Wu
5ada23ac12 compile.c: Emit send for === calls in when statements
The checkmatch instruction with VM_CHECKMATCH_TYPE_CASE calls
=== without a call cache. Emit a send instruction to make the call
instead. It includes a call cache.

The call cache improves throughput of using when statements to check the
class of a given object. This is useful for say, JSON serialization.

Use of a regular send instead of checkmatch also avoids taking the VM
lock every time, which is good for multi-ractor workloads.

    Calculating -------------------------------------
                             master        post
         vm_case_classes    11.013M     16.172M i/s -      6.000M times in 0.544795s 0.371009s
             vm_case_lit      2.296       2.263 i/s -       1.000 times in 0.435606s 0.441826s
                 vm_case    74.098M     64.338M i/s -      6.000M times in 0.080974s 0.093257s

    Comparison:
                      vm_case_classes
                    post:  16172114.4 i/s
                  master:  11013316.9 i/s - 1.47x  slower

                          vm_case_lit
                  master:         2.3 i/s
                    post:         2.3 i/s - 1.01x  slower

                              vm_case
                  master:  74097858.6 i/s
                    post:  64338333.9 i/s - 1.15x  slower

The vm_case benchmark is a bit slower post patch, possibily due to the
larger instruction sequence. The benchmark dispatches using
opt_case_dispatch so was not running checkmatch and does not make the
=== call post patch.
2021-05-28 12:34:03 -04:00
Hiroshi SHIBATA
12214b7814
Resolve to missing Gem::TestCase issue with random order tests 2021-05-28 14:01:58 +09:00
Hiroshi SHIBATA
e487ba7dda
[rubygems/rubygems] Use pend instead of skip 2021-05-28 12:33:16 +09:00
David Rodríguez
a634ef5376 [rubygems/rubygems] Fix "instance variable not initialized" warning
This variable had a typo (it's `@gemhome`), but the test is still
passing, so I assume it's not needed.

3b88642bdb
2021-05-28 11:53:57 +09:00
David Rodríguez
1f505000e6 [rubygems/rubygems] Test installing a non deprecated file
a678959eda
2021-05-28 11:53:45 +09:00
David Rodríguez
9382bda78b [rubygems/rubygems] Remove no longer needed RUBYGEMS_TEST_PATH env variable
0efb894c3b
2021-05-28 11:53:33 +09:00
David Rodríguez
4fb3dd2c42 [rubygems/rubygems] Remove no longer relevant commentsº
8dfe1e30b5
2021-05-28 11:53:21 +09:00
David Rodríguez
f7732ae2eb [rubygems/rubygems] Require the new files in test/ relatively
c77868a555
2021-05-28 11:53:09 +09:00
David Rodríguez
59c6820971 [rubygems/rubygems] Copy files specific to testing rubygems to test
aa390a3500
2021-05-28 11:52:57 +09:00
Hiroshi SHIBATA
f7d661e783
[rubygems/rubygems] Try fix ruby-core CI
* Port
8e91b969df
from ruby-core, and make it compatible with psych 3 & 4.
2021-05-28 11:52:32 +09:00
Jeremy Evans
fd8991f797 Fix lazy enumerator with index size
Fixes [Bug #17889]
2021-05-27 14:17:32 -07:00
Hiroshi SHIBATA
350bc29107 Guard for the ftp protocol feature of OpenURI 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
b8dcad8d32 Defer to require prime for OpenSSL::TestBN 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
be2e2b4805 Promote net-smtp to the bundled gems 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
aa9726f7b9 Promote net-pop to the bundled gems 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
d5bc6b2337 Promote net-imap to the bundled gems 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
e49c998d1e Promote net-ftp to the bundled gems 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
454a36794f Promote matrix to the bundled gems 2021-05-27 14:42:11 +09:00
Hiroshi SHIBATA
c9178c1127 Promote prime to the bundled gems 2021-05-27 14:42:11 +09:00
Yusuke Endoh
055ec5254d Rescue NotImplementedError for a test of Thread#native_thread_id
20210526T070003Z.fail.html.gz
```
  1) Error:
TestThread#test_thread_native_thread_id:
NotImplementedError: native_thread_id() function is unimplemented on this machine
    /export/home/users/chkbuild/cb-gcc/tmp/build/20210526T070003Z/ruby/test/ruby/test_thread.rb:1338:in `native_thread_id'
    /export/home/users/chkbuild/cb-gcc/tmp/build/20210526T070003Z/ruby/test/ruby/test_thread.rb:1338:in `test_thread_native_thread_id'
```
2021-05-26 18:02:06 +09:00
Nobuyoshi Nakada
251fafec1b
Suppress debug message 2021-05-26 15:33:25 +09:00
NARUSE, Yui
46655156dc Add Thread#native_thread_id [Feature #17853] 2021-05-26 15:14:11 +09:00
Hiroshi SHIBATA
88e3848fca
RSS library is the bundled gems now 2021-05-26 11:39:01 +09:00
Hiroshi SHIBATA
e54bef92d5
Ignore lib/irb/ext/tracer.rb with TestRequireLib because tracer library was removed from ruby repo 2021-05-26 10:04:24 +09:00
Aaron Patterson
fc832ffbfa Disable compaction on platforms that can't support it
Manual compaction also requires a read barrier, so we need to disable
even manual compaction on platforms that don't support mprotect.

[Bug #17871]
2021-05-25 17:37:21 -07:00
Hiroshi SHIBATA
edcc29dcff Removed gdbm from ruby repo 2021-05-25 20:04:54 +09:00