Commit graph

16449 commits

Author SHA1 Message Date
Hiroshi SHIBATA
34ebf82e83 [ruby/tmpdir] Use omit instead of skip for test-unit
40107b59b3
2022-01-11 21:50:53 +09:00
Hiroshi SHIBATA
9b3dcf193c [ruby/net-http] Use omit instead of skip for test-unit
843d4548de
2022-01-11 21:45:34 +09:00
Hiroshi SHIBATA
167121a9e7 [ruby/find] Use omit instead of skip for test-unit
0ebbd5b852
2022-01-11 21:40:51 +09:00
Hiroshi SHIBATA
6b87d98011 [ruby/zlib] Use omit instead of skip for test-unit
5f23cd3009
2022-01-11 21:35:22 +09:00
Hiroshi SHIBATA
f95039af75
Use omit instead of skip without the default gems tests 2022-01-11 21:17:59 +09:00
Nobuyoshi Nakada
1c9b5d452e
Reject command line option ending with - 2022-01-11 11:49:34 +09:00
aycabta
9e79ae539b [ruby/reline] Clear dialog when just_move_cursor is called with dialog at last line
05024b968e
2022-01-11 06:10:37 +09:00
John Hawthorn
930ebdd7ca YJIT: Support kwargs for cfunc
This adds support for passing keyword arguments to cfuncs. This is done
by calling a helper method to create the hash from the top N values on
the stack (determined by the callinfo) and then moving that value onto
the stack.
2022-01-10 10:53:31 -08:00
Nobuyoshi Nakada
47a05f7c09
Do not run the same tests twice 2022-01-08 14:47:59 +09:00
Nobuyoshi Nakada
fb532d801c
Run an old fixed bug in the same process 2022-01-08 14:47:49 +09:00
Nobuyoshi Nakada
64eccbf578
Run the tests on a subclass of String 2022-01-08 14:47:49 +09:00
Jeremy Evans
dd6a75195a [ruby/pathname] Make Pathname#each_entry return enumerator if called without block
Fixes [Bug #18158]

914c726aa2
2022-01-07 09:42:09 +09:00
Jeremy Evans
3f6bfe49db Update test/ruby/test_module.rb
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-01-06 08:03:33 -08:00
Jeremy Evans
a79c59472d Allow include before calling Module#initialize
This is to allow Module subclasses that include modules before
calling super in the subclass's initialize.

Remove rb_module_check_initializable from Module#initialize.
Module#initialize only calls module_exec if a block is passed,
it doesn't have other issues that would cause problems if
called multiple times or with an already initialized module.

Move initialization of super to Module#allocate, though I'm not
sure it is required there.  However, it's needed to be removed
from Module#initialize for this to work.

Fixes [Bug #18292]
2022-01-06 08:03:33 -08:00
ximenasandoval
73be7a85cd [rubygems/rubygems] Fix suggestions flag
b55a1393ca
2022-01-06 23:58:39 +09:00
ximenasandoval
cea4a81056 [rubygems/rubygems] Let fetch understand gem:version syntax
Fix version error message

Add tests to fetch error messages

Fix default version since is not necessary

070620ebe4
2022-01-06 23:58:38 +09:00
David Rodríguez
ee5e684bc1 [rubygems/rubygems] Fix gem install <non-existent-gem> --force crash
Before:

```
$ gem install sfdsfdsfsdide --force
ERROR:  While executing gem ... (NoMethodError)
    undefined method `spec' for nil:NilClass

    @always_install << newest.spec
                             ^^^^^
```

After:

```
$ gem install sfdsfdsfsdide --force
ERROR:  Could not find a valid gem 'sfdsfdsfsdide' (>= 0) in any repository
```

4e2bfd1101
2022-01-06 23:52:48 +09:00
YO4
e3b0c8c106 [ruby/reline] windows: test_yamatanooroti fix
windows can't create too narrow and tall window.

20b5f2f6fc
2022-01-06 18:33:57 +09:00
Jeremy Evans
791343b5bb Remove Refinement#{extend_object,append_features,prepend_features}
Also make include, prepend, and extend raise a TypeError if one
of the modules is a refinement.

Implements [Feature #18270]
2022-01-05 10:59:03 -08:00
Yusuke Endoh
f22296d27e test/ruby/test_refinement.rb: Remove "assigned but unused variable" 2022-01-05 23:46:27 +09:00
Shugo Maeda
54198c7b97
Add Module#refinements and Refinement#refined_class [Feature #12737] 2022-01-05 17:47:29 +09:00
Shugo Maeda
21ee5341f8
Add Module.used_refinements 2022-01-05 16:58:23 +09:00
Kazuhiro NISHIYAMA
d5836db1b3
Fix Leaked file descriptor: TestIO_Console#test_console_kw
```
Leaked file descriptor: TestIO_Console#test_console_kw: 10 : #<File:/dev/tty>
```
2022-01-05 09:05:52 +09:00
David Rodríguez
d1a91076dc [rubygems/rubygems] Fix race conditon on JRuby
On JRuby, sometimes we get the following error in CI when running a
realworld test that checks that `gem install rails` succeeds:

```
ERROR:  While executing gem ... (NoMethodError)
    undefined method `ignored=' for nil:NilClass
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/stub_specification.rb:193:in `to_spec'
	org/jruby/RubyArray.java:2642:in `map'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:758:in `_all'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/specification.rb:956:in `each'
	org/jruby/RubyEnumerable.java:1710:in `any?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/resolver/activation_request.rb:111:in `installed?'
	/home/runner/.rubies/jruby-9.3.2.0/lib/ruby/stdlib/rubygems/request_set.rb:173:in `block in install'
```

I'm not sure how this error is happening, but I think there's no need to
copy the `@ignored` instance variable when materializing stub
specifications. This instance variable is used to not print a warning
about missing extensions more than once for each gem upon gem
activation, but as far as I can see, it's only used by methods that work
on specification stubs. Once specifications are materialized, I think
it can be safely ignored.

301cecd5a7
2022-01-05 07:25:45 +09:00
Jeremy Evans
9e0a91d064 Don't segfault if Warning.warn is undefined
Check that there is a method entry for the method before passing
it to rb_method_entry_arity.

Fixes [Bug #18458]
2022-01-04 10:03:18 -08:00
Peter Zhu
615e9b2865 [Feature #18364] Add GC.stat_heap to get stats for memory heaps
GC.stat_heap will return stats for memory heaps. This is
used for the Variable Width Allocation feature.
2022-01-04 09:46:36 -05:00
Yusuke Endoh
e9a4cc02b4 [ruby/error_highlight] Add a test to check if it is robust against a spoofed filename
Previously, RubyVM::AST.of opened a wrong file if the iseq's file path is spoofed.

```
module Dummy
  binding.irb
end
```

```
$ ruby test.rb

From: test.rb @ line 2 :

    1: module Dummy
 => 2:   binding.irb
    3: end

irb(Dummy):001:0> foo
/home/mame/work/ruby/local/lib/ruby/3.1.0/error_highlight/base.rb:412:in `spot_colon2': undefined method `last_lineno' for nil:NilClass (NoMethodError)

      if nd_parent.last_lineno == @node.last_lineno
                  ^^^^^^^^^^^^
```

Found by @kateinoigakukun

This issue is already fixed in the interpreter side.
This change just adds a test for the case.

f3626b9032
2022-01-04 23:18:37 +09:00
Christian Boos
11b1ebe606 [ruby/error_highlight] Fix the spurious TypeError.
When we have no backtrace locations, we can't have the highlight,
so just return the message.

9f5c639494
2022-01-04 23:09:01 +09:00
Christian Boos
e22218b510 [ruby/error_highlight] Reproduce the error seen when calling .to_s in embedded Ruby
The test fails with the following error:

Error: test_simulate_funcallv_from_embedded_ruby(ErrorHighlightTest): TypeError: wrong argument type nil (expected method)

52943c9cd2
2022-01-04 23:09:00 +09:00
Yusuke Endoh
b673e9a304 Fix the previous commit 2022-01-04 17:52:07 +09:00
Yusuke Endoh
426ddbfff5 test/ruby/test_method.rb: Fix a random failure during make COVERAGE=1
This fixes the following failure.

```
1) Error:
TestMethod#test_method_list:
NoMethodError: undefined method `<=>' for #<BasicObject:0x00007f7757e7eb60>

      mods = mods.sort_by {|m| m.name }
                 ^^^^^^^^
```
4699487470

TestNoMethodError#test_to_s creates an anonymous module whose `#name`
method returns a BasicObject.

f0669fb6cb/test/ruby/test_nomethod_error.rb (L95-L99)

TestMethod#test_method_list uses `ObjectSpace.each_object(Module)` to
gather all Modules and attempts to sort them by `#name`.
But the anonymous module returns a BasicObject, which leads to the test
failure above.
2022-01-04 17:34:28 +09:00
Hiroshi SHIBATA
47bf64a26d
Use omit instead of skip: test/ruby/**/*.rb 2022-01-04 17:25:30 +09:00
Jeremy Evans
67612dadbc [ruby/net-http] Handle invalid use of IP addresses in SNI
Server Name Indication does not allow IP addresses (RFC 6066, section 3:
`Literal IPv4 and IPv6 addresses are not permitted in "HostName".`).

Recent versions of LibreSSL enforce this restriction, which raises
when setting the hostname to an IP address (s.hostname=), before
attempting to setup the SSL connection.

Since the certificate used in the test is already for localhost,
we cannot connect to localhost.  However, as all the test does is
check for a specific exception, just modify the regexp used so it
handles both cases.

6ab399db45
2022-01-04 08:25:58 +09:00
aycabta
66e9256147 [ruby/reline] Remove test TODO comments that have been confirmed by E2E tests
2ed77b693f
2022-01-03 07:06:28 +09:00
aycabta
76181ae940 [ruby/reline] Check capname of tigetstr/tigetflag/tigetnum
Incorrect arguments can cause SEGV.

a58748bcf9
2022-01-02 11:44:07 +09:00
aycabta
f375b6414d [ruby/reline] Add test_tigetstr_with_error
1ca779740a
2022-01-02 11:44:06 +09:00
aycabta
85f304b931 [ruby/reline] Implement Reline::Terminfo.tigetnum
695212d5d2
2022-01-02 10:27:09 +09:00
aycabta
0af9eab08e [ruby/reline] Consolidate tests that were unnecessarily divided
62eec42e4a
2022-01-01 23:13:32 +09:00
aycabta
6300c4dcc3 [ruby/reline] Implement Reline::Terminfo.tigetflag
0451ed7a28
2022-01-01 23:06:53 +09:00
Nobuyoshi Nakada
fae0b66431 Remove deprecated Random::DEFAULT [Feature #17351] 2022-01-01 18:55:52 +09:00
Jeremy Evans
f53dfab95c Add support for anonymous rest and keyword rest argument forwarding
This allows for the following syntax:

```ruby
def foo(*)
  bar(*)
end
def baz(**)
  quux(**)
end
```

This is a natural addition after the introduction of anonymous
block forwarding.  Anonymous rest and keyword rest arguments were
already supported in method parameters, this just allows them to
be used as arguments to other methods.  The same advantages of
anonymous block forwarding apply to rest and keyword rest argument
forwarding.

This has some minor changes to #parameters output.  Now, instead
of `[:rest], [:keyrest]`, you get `[:rest, :*], [:keyrest, :**]`.
These were already used for `...` forwarding, so I think it makes
it more consistent to include them in other cases.  If we want to
use `[:rest], [:keyrest]` in both cases, that is also possible.

I don't think the previous behavior of `[:rest], [:keyrest]` in
the non-... case and `[:rest, :*], [:keyrest, :**]` in the ...
case makes sense, but if we did want that behavior, we'll have to
make more substantial changes, such as using a different ID in the
... forwarding case.

Implements [Feature #18351]
2021-12-30 14:37:42 -08:00
Nobuyoshi Nakada
db547a3bc4
[ruby/win32ole] Undefine allocator of WIN32OLE_VARIABLE to get rid of warning
27d0fdc622
2021-12-30 21:13:11 +09:00
aycabta
2a311594cc [ruby/reline] Omit a test on Ruby 2.6
Some tokens in Ruby 2.6 have difference information than in 2.7 and later,
but 2.6 will soon be out of support.

f3bc698385
2021-12-30 20:52:06 +09:00
aycabta
9295732af8 [ruby/reline] Use ripper_lex_without_warning
b7536dc224
2021-12-30 20:52:06 +09:00
ima1zumi
f589242e75 [ruby/reline] Use unix_line_discard when Ctrl-u is entered
The kill-line was called when C-u was entered, so it is now called unix-line-discard.

In readline(3):

> unix-line-discard (C-u)
>               Kill backward from point to the beginning of the line.
>               The killed text is saved on the kill-ring.

27570d195e
2021-12-30 20:23:58 +09:00
Hiroshi SHIBATA
239e71c0af [ruby/reline] Use omit instead of skip
a538de421f
2021-12-29 20:12:36 +09:00
Hiroshi SHIBATA
f25c2e6336
Use omit instead of skip: test/ruby/enc/**/*.rb 2021-12-29 19:27:58 +09:00
Samuel Williams
f27eb8148f
Sync io-console gem. 2021-12-29 13:27:40 +13:00
Hiroshi SHIBATA
763592d208
Use omit instead of skip: test/-ext-/**/*.rb 2021-12-28 21:13:39 +09:00
Hiroshi SHIBATA
55cdb8b013
Use omit instead of skip: test/socket/**/*.rb 2021-12-28 20:29:54 +09:00