Граф коммитов

14622 Коммитов

Автор SHA1 Сообщение Дата
aycabta b0cc46b484 [ruby/reline] The config file must accept any character encoding
In Japan, so many programmers used EUC-JP to write text files that contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This commit supports the whole encoding of what user set including UTF-8.

ref. https://github.com/ruby/reline/pull/280

https://github.com/ruby/reline/commit/0b45022e16
2021-06-21 17:58:48 +09:00
aycabta c59bbd86a6 [ruby/reline] Use ReadConsoleInputW() instead of getwch()
This needs https://github.com/aycabta/yamatanooroti/pull/19, which is released
by yamatanooroti gem 0.0.7, to test with yamatanooroti.

https://github.com/ruby/reline/commit/06c1f45da1
2021-06-21 17:58:48 +09:00
Mark Delk a049dfd10a [ruby/reline] ensure reline's encoding is used when reading inputrc character values
This change ensures we use `Reline::IOGate`'s `encoding` when converting
characters from their integer values.

This fixes an issue that may occur if you have UTF characters in your
`.inputrc`, but your default encoding isn't set.

For example:

```
> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"
```

https://github.com/ruby/reline/commit/cf372fc0fc
2021-06-21 17:58:48 +09:00
Yusuke Endoh acae5f363d ast.rb: RubyVM::AST.parse and .of accepts `save_script_lines: true`
This option makes the parser keep the original source as an array of
the original code lines. This feature exploits the mechanism of
`SCRIPT_LINES__` but records only the specified code that is passed to
RubyVM::AST.of or .parse, instead of recording all parsed program texts.
2021-06-18 02:34:27 +09:00
Nobuyoshi Nakada 95ef545997 [rubygems/rubygems] Close then unlink tempfiles on Windows
In ruby/ruby test actions, number of "leaked tempfile" messages
are shown on Windows.

As Windows disallows removing open files, `Tempfile#unlink` fails
silently before `#close`.
Close then unlink by `#close!` instead.

https://github.com/rubygems/rubygems/commit/fe0b88ac30
2021-06-17 12:28:15 +09:00
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
https://github.com/ruby/psych/commit/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.

https://github.com/ruby/psych/commit/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.

https://github.com/rubygems/rubygems/commit/6460e018df
2021-06-03 12:23:22 +09:00
aycabta 77e1b47729 [ruby/rdoc] Add an alias for test-unit with older versions of RubyGems
https://github.com/ruby/rdoc/commit/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.

https://github.com/rubygems/rubygems/commit/3b88642bdb
2021-05-28 11:53:57 +09:00
David Rodríguez 1f505000e6 [rubygems/rubygems] Test installing a non deprecated file
https://github.com/rubygems/rubygems/commit/a678959eda
2021-05-28 11:53:45 +09:00
David Rodríguez 9382bda78b [rubygems/rubygems] Remove no longer needed `RUBYGEMS_TEST_PATH` env variable
https://github.com/rubygems/rubygems/commit/0efb894c3b
2021-05-28 11:53:33 +09:00
David Rodríguez 4fb3dd2c42 [rubygems/rubygems] Remove no longer relevant commentsº
https://github.com/rubygems/rubygems/commit/8dfe1e30b5
2021-05-28 11:53:21 +09:00
David Rodríguez f7732ae2eb [rubygems/rubygems] Require the new files in `test/` relatively
https://github.com/rubygems/rubygems/commit/c77868a555
2021-05-28 11:53:09 +09:00
David Rodríguez 59c6820971 [rubygems/rubygems] Copy files specific to testing rubygems to `test`
https://github.com/rubygems/rubygems/commit/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
http://rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/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
Hiroshi SHIBATA 55cd3e4ebf Removed dbm from ruby repo 2021-05-25 15:18:31 +09:00
Hiroshi SHIBATA ab3266ea5c Removed tracer from ruby repo 2021-05-25 13:13:52 +09:00
aycabta f57968e329 Set USE_COLORIZE to the default value in a test 2021-05-24 12:13:46 +09:00
jethrodaniel d06d4560a1 [ruby/irb] update test/irb/test_init.rb to avoid useless eval
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

https://github.com/ruby/irb/commit/2dfdc031ec
2021-05-24 11:56:05 +09:00
Mark Delk b8ffb1c46f [ruby/irb] respect NO_COLOR environment variable
When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

https://github.com/ruby/irb/commit/401d0916fe
2021-05-24 11:55:58 +09:00
aycabta c264d30261 Use YAML.safe_load to use the permitted_classes option 2021-05-21 21:45:03 +09:00
Nobuyoshi Nakada c4162a4cb8
Refined portability of test for [Bug #17739]
The order of arguments to callback of qsort is not defined.
That means `a` may not be 3 at all.
2021-05-22 14:34:23 +09:00
Jeremy Evans 8b00bfb7c2
Do not allow array modifications after freeze inside sort!
If freezing an array inside sort!, previously the array could be
modified after the freeze.  This checks whether the receiver is
frozen after every yield and potential call to #> or #<,
preventing modifications if the receiver is frozen inside the
block or by the #> or #< call.

Fixes [Bug #17739]
2021-05-21 18:33:56 -07:00
Alan Wu b2fc592c30
Build CDHASH properly when loading iseq from binary
Before this change, CDHASH operands were built as plain hashes when
loaded from binary. Without setting up the hash with the correct
st_table type, the hash can sometimes be an ar_table. When the hash is
an ar_table, lookups can call the `eql?` method on keys of the hash,
which makes the `opt_case_dispatch` instruction not "leaf" as it
implicitly declares.

The following script trips the stack canary for checking the leaf
attribute for `opt_case_dispatch` on VM_CHECK_MODE > 0 (enabled by
default with RUBY_DEBUG).

    rb_vm_iseq = RubyVM::InstructionSequence

    iseq = rb_vm_iseq.compile(<<-EOF)
      case Class.new(String).new("foo")
      when "foo"
        42
      end
    EOF

    puts rb_vm_iseq.load_from_binary(iseq.to_binary).eval

This commit changes the binary loading logic to build CDHASH with the
right st_table type. The dumping logic and the dump format stays the
same
2021-05-21 12:13:55 -04:00
Alan Wu 636d4f7eb9 Avoid setting the visibility of refinement method entries
Since refinement search is always performed, these entries should always
be public. The method entry that the refinement search returns decides
the visibility.

Fixes [Bug #17822]
2021-05-21 12:12:31 -04:00
Nobuyoshi Nakada 50a534a152 ripper: wrap endless method in bodystmt [Bug #17869] 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada 050bb06e66 ripper: assertions for rescue/ensure in method body 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada e9974a466a
Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-21 18:26:07 +09:00
Koichi Sasada 817764bd82 simple rescue+while+break should not use `throw`
609de71f04 fixes the issue by using
`throw` insn if `ensure` is used. However, that patch introduce
additional `throw` even if it is not needed. This patch solves
the issue.

This issue is pointed by @mame.
2021-05-21 18:12:14 +09:00
Nobuyoshi Nakada 59b327aa58
[ruby/rdoc] Drop support for Ruby 2.4
https://github.com/ruby/rdoc/commit/f480b970cc
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada f18a0b7654
[ruby/rdoc] Follow-up rubygems
Use test-unit assertions instead of minitest.

https://github.com/ruby/rdoc/commit/d6a6209d7f
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada 10e63f3f56
[ruby/rdoc] Vertical-bar is disallowed in path names on Windows
No risk of remote code execution, when the file cannot be created.

https://github.com/ruby/rdoc/runs/2565343916?check_suite_focus=true#step:5:58
```
Error: test_remove_unparseable_CVE_2021_31799(TestRDocRDoc): Errno::EINVAL: Invalid argument @ utime_failed - | touch evil.txt && echo tags
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1142:in `utime'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1142:in `block in touch'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1139:in `each'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1139:in `touch'
D:/a/rdoc/rdoc/test/rdoc/test_rdoc_rdoc.rb:463:in `block (2 levels) in test_remove_unparseable_CVE_2021_31799'
     460:     temp_dir do
     461:       file_list = ['| touch evil.txt && echo tags']
     462:       file_list.each do |f|
  => 463:         FileUtils.touch f
     464:       end
     465:
     466:       assert_equal file_list, @rdoc.remove_unparseable(file_list)
```

https://github.com/ruby/rdoc/commit/a7df7dc8fa
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada a298bdf860
[ruby/rdoc] Dir.children is 2.5+
RDoc seems still supporting outdated 2.4.

https://github.com/ruby/rdoc/runs/2565344070?check_suite_focus=true#step:5:64
```
Error: test_remove_unparseable_CVE_2021_31799(TestRDocRDoc): NoMethodError: undefined method `children' for Dir:Class
/home/runner/work/rdoc/rdoc/test/rdoc/test_rdoc_rdoc.rb:467:in `block in test_remove_unparseable_CVE_2021_31799'
     464:       end
     465:
     466:       assert_equal file_list, @rdoc.remove_unparseable(file_list)
  => 467:       assert_equal file_list, Dir.children('.')
     468:     end
     469:   end
     470:
```

https://github.com/ruby/rdoc/commit/5a4a64dc0f
2021-05-21 15:53:34 +09:00
aycabta b1c73f239f [ruby/rdoc] Use File.open to fix the OS Command Injection vulnerability in CVE-2021-31799
https://github.com/ruby/rdoc/commit/a7f5d6ab88
2021-05-21 13:42:24 +09:00
Nobuyoshi Nakada c711093559 Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-20 21:56:58 +09:00
Yusuke Endoh 5026f9a5d5 compile.c: stop the jump-jump optimization if the second has any event
Fixes [Bug #17868]
2021-05-20 19:13:39 +09:00
Hiroshi SHIBATA adcbae8d49
Removed minitest/mock 2021-05-19 14:24:01 +09:00
Yusuke Endoh ceea1ea8af test/rubygems/test_gem_commands_open_command.rb: prevent a warning
http://rubyci.s3.amazonaws.com/debian9/ruby-master/log/20210518T093002Z.log.html.gz
```
[ 9396/21186] TestGemCommandsOpenCommand#test_execute-e:1: warning: possibly useless use of a literal in void context
 = 0.06 s
```
2021-05-18 19:06:48 +09:00
Yusuke Endoh 837cbea64b test/psych/test_coder.rb: Suppress non-parenthesis warnings
http://rubyci.s3.amazonaws.com/debian9/ruby-master/log/20210518T093002Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20210518T093002Z/ruby/test/psych/test_coder.rb:277: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator
```
2021-05-18 19:01:27 +09:00
Nobuyoshi Nakada 34bc8210ed
test/irb/test_raise_no_backtrace_exception.rb: fix test file path
Create a file for test under the temporary directory.
2021-05-18 16:04:37 +09:00
Jeremy Evans 2579593a56 [ruby/fiddle] Do not use a libdir for glibc, it breaks Linux PPC64 (#70)
Fixes [Bug #12666]

https://github.com/ruby/fiddle/commit/a267a40be7
2021-05-18 12:48:40 +09:00
Sutou Kouhei ab5212b3c9 [ruby/fiddle] Add support for "const" in type
GitHub: fix #68

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/d7322c234a
2021-05-18 12:48:40 +09:00
Sutou Kouhei 881b2dc898 [ruby/fiddle] closure: add support for const char *
GitHub: fix GH-62

Reported by Cody Krieger. Thanks!!!

https://github.com/ruby/fiddle/commit/284b820f2d
2021-05-18 12:48:40 +09:00
Sutou Kouhei b2de5999d8 [ruby/fiddle] closure: accept symbol as type
https://github.com/ruby/fiddle/commit/dc2da6633e
2021-05-18 12:48:40 +09:00
Hiroshi SHIBATA e36da7ba18
Revert an accidentally commits at df86a13cc1 2021-05-17 15:28:47 +09:00
Yusuke Endoh 31a757a442 Make the test pass with the old libyaml
I have no idea what result is right, but it fails with libyaml 0.1.7
(bundled with Ubuntu 18.04) anyway.
2021-05-17 14:31:34 +09:00
Yusuke Endoh f367b4ffe7 assert_equal accepts an expected value as the first argument 2021-05-17 14:31:34 +09:00
Yusuke Endoh ffdf0232ef lib/rdoc/rdoc.rb: Allow only RDoc::Options in .rdoc_options
Follow-up of d8fd92f620. Instead of using
unsafe_load blindly, RDoc::Options is only supposed to be allowed.
2021-05-17 12:53:42 +09:00
Hiroshi SHIBATA d8fd92f620
Workaround with fbb4e3f96c in rdoc 2021-05-17 12:04:40 +09:00
Hiroshi SHIBATA 8e91b969df
Workaround with fbb4e3f96c 2021-05-17 12:00:05 +09:00
Yusuke Endoh da5b283963 test/ostruct/test_ostruct.rb: Use YAML.unsafe_load instead of YAML.load
Follow-up of fbb4e3f96c
2021-05-17 11:36:16 +09:00
Aaron Patterson 42b20bdbfe
[ruby/psych] remove deprecated interface
https://github.com/ruby/psych/commit/0767227051
2021-05-17 11:20:46 +09:00
Aaron Patterson c7c2ad5749
[ruby/psych] Introduce `Psych.unsafe_load`
In future versions of Psych, the `load` method will be mostly the same
as the `safe_load` method.  In other words, the `load` method won't
allow arbitrary object deserialization (which can be used to escalate to
an RCE).  People that need to load *trusted* documents can use the
`unsafe_load` method.

This commit introduces the `unsafe_load` method so that people can
incrementally upgrade.  For example, if they try to upgrade to 4.0.0 and
something breaks, they can downgrade, audit callsites, change to
`safe_load` or `unsafe_load` as required, and then upgrade to 4.0.0
smoothly.

https://github.com/ruby/psych/commit/cb50aa8d3f
2021-05-17 11:20:45 +09:00
Hiroshi SHIBATA bcaa6aecea
[ruby/psych] Removed needless platform detection
https://github.com/ruby/psych/commit/57d704fd63
2021-05-17 11:20:45 +09:00
Hiroshi SHIBATA df86a13cc1
[ruby/psych] Import test assertions from ruby/ruby
https://github.com/ruby/psych/commit/01dda86681
2021-05-17 11:20:45 +09:00
Jean Boussier a3ceed50b8
[ruby/psych] Fix symabolize_name with non-string keys
https://github.com/ruby/psych/commit/1c5c29e81f
2021-05-17 11:20:45 +09:00
Jeremy Ebler 830778db95
[ruby/psych] feat: allow scalars and sequences to be styled when dumped
https://github.com/ruby/psych/commit/546154ddb7
2021-05-17 11:20:45 +09:00
Gabriel Nagy 229cb0fcdb
[Win32] long path name support [Bug #12551]
Implement long path support on Windows by applying Microsoft's
recommended application manifest.

To make this work on both Visual C++ and MinGW, include the manifest as
a resource when generating the resource files. This way it will be
embedded into the executables generated by both compilers.

It's important for the manifest resource to have ID 1, otherwise GCC
will embed a default manifest.

Note that in addition to this, the user needs to have [long paths enabled]
either by modifying the registry or by enabling a group policy.

[long paths enabled]: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-05-17 08:33:08 +09:00
Yusuke Endoh f210d456a8 test/objspace/test_objspace.rb: check stderr before stdout
When `require "objspace/trace"` fails, previously the failure says:
```
  1) Failure:
TestObjSpace#test_objspace_trace [/tmp/ruby/v3/src/trunk-mjit/test/objspace/test_objspace.rb:621]:
<3> expected but was
<0>.
```
but this is hard to debug.
2021-05-14 18:07:58 +09:00
Yusuke Endoh 702961a88b test/ruby/test_refinement.rb: prevent "assigned but unused variable" 2021-05-14 15:44:13 +09:00
Yusuke Endoh cf1e1879f1 ext/objspace/lib/objspace/trace.rb: Added
This file, when require'ed, starts tracing the object allocations, and
redefines `Kernel#p` to show the allocation site.

This commit is experimental; the library name and APIs may change.

[Feature #17762]
2021-05-14 13:40:32 +09:00
Nobuyoshi Nakada 110f242ef9
Also `\U` after control/meta is invalid [Bug #17861]
As well as `\u`, `\U` should be invalid there too.
And highlight including `u`/`U` not only the backslash before it.
2021-05-13 12:54:56 +09:00
Jeremy Evans 9ce29c94d8 Avoid improper optimization of case statements mixed integer/rational/complex
Fixes [Bug #17857]
2021-05-12 19:30:05 -07:00
Jeremy Evans 11ae581a4a Fix handling of control/meta escapes in literal regexps
Ruby uses a recursive algorithm for handling control/meta escapes
in strings (read_escape).  However, the equivalent code for regexps
(tokadd_escape) in did not use a recursive algorithm.  Due to this,
Handling of control/meta escapes in regexp did not have the same
behavior as in strings, leading to behavior such as the following
returning nil:

```ruby
/\c\xFF/ =~ "\c\xFF"
```

Switch the code for handling \c, \C and \M in literal regexps to
use the same code as for strings (read_escape), to keep behavior
consistent between the two.

Fixes [Bug #14367]
2021-05-12 18:55:43 -07:00
Yusuke Endoh 9484f9ebdf [rubygems/rubygems] Use `Time.stub :now` to avoid a random failure
Essentially this reverts 45464bfcbdf9f9cfb440950bc57a27d237627a17.
The commit removed a mock of Time.now, which caused a random failure.

http://rubyci.s3.amazonaws.com/ubuntu1804/ruby-master/log/20210512T123004Z.fail.html.gz
```
  1) Failure:
TestGemPackageTarWriter#test_add_file_signer [/home/chkbuild/chkbuild/tmp/build/20210512T123004Z/ruby/test/rubygems/test_gem_package_tar_writer.rb:117]:
Field mtime of the tar header differs..
<"14046746312\u0000"> expected but was
<"14046746311\x00">.
```

Object#stub is defined at f1af59fe02ef2cc58f13e2742e4cc6cf8c2a1a20, so
now `Time.stub :now` works.

https://github.com/rubygems/rubygems/commit/85f60a9ed0
2021-05-13 09:26:13 +09:00
Yusuke Endoh 31794d2e73 parse.y: Allow "command" syntax in endless method definition
This change allows `def hello = puts "Hello"` without parentheses.

Note that `private def hello = puts "Hello"` does not parse for
technical reason.

[Feature #17398]
2021-05-13 00:14:50 +09:00
git 81513c9dab * remove trailing spaces. [ci skip] 2021-05-12 17:40:52 +09:00
Koichi Sasada 523a6998dd Use another class for the comparison.
`memsize_of(Object.new)` can be changed with past ivar creation
history for Object instances (another Object instance has 4 or
more ivars, next created Object instance has the area for the
ivars). So use antoher class for the comparison.
2021-05-12 17:40:31 +09:00
Hiroshi SHIBATA 81720b947a Use assert_raise instead of assert_raises 2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA cdcfe1082c Revert 924ce2c5ba4d1c1dc781a6a06682204d358421bb
Because test-unit didn't provide the benchmark test. And This test
  is fragile with the several environments.
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA bef49e6e8d [rubygems/rubygems] Added begin-end block for java platform
Because pend of test-unit raises exception.

https://github.com/rubygems/rubygems/commit/b5e2d0855a
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA d33888bf96 [rubygems/rubygems] Replace skip to pend
https://github.com/rubygems/rubygems/commit/0b145135c7
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 129bc04ab7 [rubygems/rubygems] util/rubocop -a
https://github.com/rubygems/rubygems/commit/a10ff97830
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 00f5b4b546 [rubygems/rubygems] Don't use Minitest::Mock
https://github.com/rubygems/rubygems/commit/d3fa893597
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 3456335a9c [rubygems/rubygems] Removed minitest/mock from test/rubygems/test_gem_remote_fetcher.rb
https://github.com/rubygems/rubygems/commit/f1af59fe02
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA ff3f990499 [rubygems/rubygems] Removed minitest/mock from test_gem_package_tar_writer.rb
https://github.com/rubygems/rubygems/commit/45464bfcbd
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 7b3b48549b [rubygems/rubygems] capture_output will return empty string, not nil
https://github.com/rubygems/rubygems/commit/3fa93f6144
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 9b5e4ce611 [rubygems/rubygems] Fixed variable scope at test_silent_system
https://github.com/rubygems/rubygems/commit/bfcdf79657
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA cd375e455e [rubygems/rubygems] Rewrite with capture_output
https://github.com/rubygems/rubygems/commit/a091004ded
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 5ed9d3f16f [rubygems/rubygems] Use capture_output instead of capture_io
https://github.com/rubygems/rubygems/commit/c46185abe3
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA c30594bb0c [rubygems/rubygems] Use assert_raise instead of assert_raises
https://github.com/rubygems/rubygems/commit/769e87f011
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 2c0072dec5 [rubygems/rubygems] Use dummy assertion for assert_https
https://github.com/rubygems/rubygems/commit/64d843fe17
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA a1c416460b [rubygems/rubygems] Use capture_output instead of assert_silent
https://github.com/rubygems/rubygems/commit/3225aab7f8
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 958f9d425a [rubygems/rubygems] Use capture_output instead of capture_io for test-unit
https://github.com/rubygems/rubygems/commit/ab9c80d4cb
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 3948be3503 [rubygems/rubygems] Use assert_path_exist and assert_path_not_exist instead of assert_path_exists and refute_path_exists
https://github.com/rubygems/rubygems/commit/a7c93558c3
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 81d793a921 [rubygems/rubygems] Extract assert_output to assert_empty and assert_equal with capture_output
https://github.com/rubygems/rubygems/commit/f6759440a4
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 183174475c [rubygems/rubygems] Use Regexp with refute_match
https://github.com/rubygems/rubygems/commit/51fdbe53bc
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 3c9633acfc [rubygems/rubygems] Also use capture_output instead of capture_io
https://github.com/rubygems/rubygems/commit/229858ea56
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA 26cbda8dc9 [rubygems/rubygems] Use capture_output instead of capture_io.
https://github.com/rubygems/rubygems/commit/ad9206d4d0
2021-05-12 17:24:43 +09:00
Koichi Sasada 5a6af44e20 skip test for debug.
test_memsize_of_iseq fails on repeat tests and it seems to difficult
to solve immediately. Now this test is skipped.

It seems that the result of `memsize_of(Object.new)` are increased.
Why...?
2021-05-12 12:57:53 +09:00
Koichi Sasada 3df7c967bb suppress warnings on repeat tests.
Constant definitions are affect on outer namespace of an anonymous
module. To define constants on the anonymous module, this patch
uses Module#class_eval(str).
2021-05-12 12:53:14 +09:00
卜部昌平 6911b4bc82 test_cdhash: refactor change class
It is now strange to test Complex in a class named Rational_Test.
2021-05-12 10:30:46 +09:00
卜部昌平 cc0dc67bbb cdhash_cmp: can also take complex
There are complex literals `123i`, which can also be a case condition.
2021-05-12 10:30:46 +09:00
卜部昌平 d0e6c6e682 cdhash_cmp: rational literals with fractions
Nobu kindly pointed out that rational literals can have fractions.
2021-05-12 10:30:46 +09:00
卜部昌平 2bc293e899 cdhash_cmp: can take rational literals
Rational literals are those integers suffixed with `r`.  They tend to
be a part of more complex expressions like `123/456r`, but in theory
they can live alone.  When such "bare" rational literals are passed to
case-when branch, we have to take care of them.  Fixes [Bug #17854]
2021-05-12 10:30:46 +09:00
Takashi Kokubun cc1ea6e023
Run nmake check on Actions (#4487)
* Run nmake check on Actions

* Skip tests not working in mswin GitHub Actions

* Override TEMP

* Revert "Skip tests not working in mswin GitHub Actions"

This reverts commit 544d2575fcdf23ae63cd25aa03fce10c28b259f2.

* Revert "Revert "Skip tests not working in mswin GitHub Actions""

This reverts commit e1f8ad7862c9c4be52dc6e1031a004621eb07e6e.

* Fix timeouts

* Skip some more broken tests

* Update windows.yml

* Add a guard for rbasic_spec

* Revert "Update windows.yml"

This reverts commit bc9694b6b3b9594d406378d15ca11723fb052bc8.

* Skip the ensure clause

* Simplify the ensure
2021-05-11 15:18:44 -07:00
Alan Wu 39a2ba5cc5
Method cache: fix refinement entry handling
To invalidate some callable method entries, we replace the entry in the
class. Most types of method entries are on the method table of the
origin class, but refinement entries without an orig_me are housed in
the method table of the class itself. They are there because refinements
take priority over prepended methods.

By unconditionally inserting a copy of the refinement entry into the
origin class, clearing the method cache created situations where there
are refinement entry duplicates in the lookup chain, leading to infinite
loops and other problems.

Update the replacement logic to use the right class that houses the
method entry. Also, be more selective about cache invalidation when
moving refinement entries for prepend. This avoids calling
clear_method_cache_by_id_in_class() before refinement entries are in the
place it expects.

[Bug #17806]
2021-05-11 12:05:06 -04:00
Yusuke Endoh 1b61cdd5e0 test/irb/test_raise_no_backtrace_exception.rb: Set LC_MESSAGES as UTF-8 2021-05-11 19:38:06 +09:00
Takashi Kokubun 66ca6ede16 [ruby/irb] Skip test_raise_exception_with_invalid_byte_sequence
on Windows for now. It seems like we haven't figured this out yet.

https://github.com/ruby/irb/commit/ecf5a1ace1
2021-05-11 14:46:33 +09:00
Takashi Kokubun afa70d079f
Explicitly specify encoding for another test as well
Same as e2ccc3301e
https://ci.appveyor.com/project/ruby/ruby/builds/39102539/job/k8m1yrrjesxbgvtq
2021-05-10 21:41:36 -07:00
Yusuke Endoh e2ccc3301e test/irb/test_raise_no_backtrace_exception.rb: UTF-8 is expected
... for the output of assert_in_out_err.

This will fix the following failure on many CI machines

http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20210511T030005Z.fail.html.gz
```
  1) Failure:
TestIRB::TestRaiseNoBacktraceException#test_raise_exception_with_different_encoding_containing_invalid_byte_sequence [/home/chkbuild/chkbuild/tmp/build/20210511T030005Z/ruby/test/irb/test_raise_no_backtrace_exception.rb:41]:
pid 221531 exit 0.

1. [1/2] Assertion for "stdout"
   | invalid byte sequence in US-ASCII.
```
2021-05-11 13:30:28 +09:00
Takashi Kokubun bb54361057 [ruby/irb] Skip the new IRB test on Windows for now
It's not passing from the beginning
https://github.com/ruby/ruby/runs/2550929220
https://ci.appveyor.com/project/ruby/ruby/builds/39100747

https://github.com/ruby/irb/commit/71fc180018
2021-05-11 13:01:38 +09:00
David Rodríguez 5b0abba931 Sync bundler & rubygems 2021-05-11 11:29:41 +09:00
aycabta 774cc32b4d [ruby/irb] Treat encodings in exception correctly
https://github.com/ruby/irb/commit/4452adbe04
2021-05-11 09:32:08 +09:00
Jean Boussier c110ade0d2
[ruby/psych] Fix custom marshalization with symbolize_names: true
https://github.com/ruby/psych/commit/ee26f26ab5
2021-05-10 19:17:32 +09:00
Hiroshi SHIBATA ab785b28e2 [ruby/psych] Use assert_raise instead of assert_raises
https://github.com/ruby/psych/commit/e6ad12b4e1
2021-05-10 19:09:43 +09:00
Hiroshi SHIBATA bae9a21e40 [ruby/psych] Use pend instead of skip
https://github.com/ruby/psych/commit/efd2a62c9a
2021-05-10 18:53:56 +09:00
Hiroshi SHIBATA 53c5a4bbe1 [ruby/psych] Fixed test-case for NaN
https://github.com/ruby/psych/commit/f85a008263
2021-05-10 18:53:49 +09:00
Hiroshi SHIBATA 230d559f6b [ruby/psych] Use Ractor constant for ignoreing condition
https://github.com/ruby/psych/commit/cc5f957327
2021-05-10 18:53:41 +09:00
Hiroshi SHIBATA ce67549c50 [ruby/psych] Use test-unit instead of minitest
https://github.com/ruby/psych/commit/01e7310dd3
2021-05-10 18:53:33 +09:00