Commit graph

16692 commits

Author SHA1 Message Date
Nobuyoshi Nakada
5b959e238e [Bug #19016] re-order error handling at cleanup
Build and store the error message with `#detailed_message` before
terminating all Ractors, then show the message later.
2022-11-22 00:33:19 +09:00
Takashi Kokubun
c9fbc779a6 [ruby/irb] Add commands to start and use the debugger
(https://github.com/ruby/irb/pull/449)

* Seamlessly integrate a few debug commands

* Improve the break command support

* Utilize skip_src option if available

* Add step and delete commands

* Write end-to-end tests for each debugger command

* Add documentation

* Add backtrace, info, catch commands

976100c1c2
2022-11-21 08:46:27 +00:00
Yusuke Endoh
730b841f8d Prevent a "warning: ambiguity between regexp and two divisions" 2022-11-21 16:13:15 +09:00
yui-knk
d8601621ed Enhance keep_tokens option for RubyVM::AbstractSyntaxTree parsing methods
Implementation for Language Server Protocol (LSP) sometimes needs token information.
For example both `m(1)` and `m(1, )` has same AST structure other than node locations
then it's impossible to check the existence of `,` from AST. However in later case,
it might be better to suggest variables list for the second argument.
Token information is important for such case.

This commit adds these methods.

* Add `keep_tokens` option for `RubyVM::AbstractSyntaxTree.parse`, `.parse_file` and `.of`
* Add `RubyVM::AbstractSyntaxTree::Node#tokens` which returns tokens for the node including tokens for descendants nodes.
* Add `RubyVM::AbstractSyntaxTree::Node#all_tokens` which returns all tokens for the input script regardless the receiver node.

[Feature #19070]

Impacts on memory usage and performance are below:

Memory usage:

```
$ cat test.rb
root = RubyVM::AbstractSyntaxTree.parse_file(File.expand_path('../test/ruby/test_keyword.rb', __FILE__), keep_tokens: true)

$ /usr/bin/time -f %Mkb /usr/local/bin/ruby -v
ruby 3.2.0dev (2022-11-19T09:41:54Z 19070-keep_tokens d3af1b8057) [x86_64-linux]
11408kb

# keep_tokens :false
$ /usr/bin/time -f %Mkb /usr/local/bin/ruby test.rb
17508kb

# keep_tokens :true
$ /usr/bin/time -f %Mkb /usr/local/bin/ruby test.rb
30960kb
```

Performance:

```
$ cat ../ast_keep_tokens.yml
prelude: |
  src = <<~SRC
    module M
      class C
        def m1(a, b)
          1 + a + b
        end
      end
    end
  SRC
benchmark:
  without_keep_tokens: |
    RubyVM::AbstractSyntaxTree.parse(src, keep_tokens: false)
  with_keep_tokens: |
    RubyVM::AbstractSyntaxTree.parse(src, keep_tokens: true)

$ make benchmark COMPARE_RUBY="./ruby" ARGS=../ast_keep_tokens.yml
/home/kaneko.y/.rbenv/shims/ruby --disable=gems -rrubygems -I../benchmark/lib ../benchmark/benchmark-driver/exe/benchmark-driver \
            --executables="compare-ruby::./ruby -I.ext/common --disable-gem" \
            --executables="built-ruby::./miniruby -I../lib -I. -I.ext/common  ../tool/runruby.rb --extout=.ext  -- --disable-gems --disable-gem" \
            --output=markdown --output-compare -v ../ast_keep_tokens.yml
compare-ruby: ruby 3.2.0dev (2022-11-19T09:41:54Z 19070-keep_tokens d3af1b8057) [x86_64-linux]
built-ruby: ruby 3.2.0dev (2022-11-19T09:41:54Z 19070-keep_tokens d3af1b8057) [x86_64-linux]
warming up..

|                     |compare-ruby|built-ruby|
|:--------------------|-----------:|---------:|
|without_keep_tokens  |     21.659k|   21.303k|
|                     |       1.02x|         -|
|with_keep_tokens     |      6.220k|    5.691k|
|                     |       1.09x|         -|
```
2022-11-21 09:01:34 +09:00
Nobuyoshi Nakada
701dfe4eb7
[Bug #19016] Handle syntax error in main script like other errors
So that `SyntaxError#detailed_message` will be used also in the case
exiting by such syntax error.
2022-11-20 20:00:40 +09:00
Takashi Kokubun
779917fcc0
Avoid a timeout on test_cache_optimization_exponential
The timeout seems too short for some CIs.
20221120T012840Z.fail.html.gz
2022-11-19 21:58:22 -08:00
Takashi Kokubun
66ac288ae2 [ruby/irb] Push an accidentally uncommitted diff
7e9f27afd7
2022-11-20 05:38:43 +00:00
Takashi Kokubun
67034ac7e2 [ruby/irb] Deal with inconsistency with ruby/ruby
41d5012849
2022-11-20 05:34:51 +00:00
Takashi Kokubun
8512b97d27 [ruby/irb] Require missing EnvUtil
9bb1757b02
2022-11-20 05:32:11 +00:00
Takashi Kokubun
fa2e0cc018 [ruby/irb] Try using a different file name
hoping to address:
5873689640

de9a6b9d00
2022-11-20 05:31:56 +00:00
Takashi Kokubun
f47251671d [ruby/irb] Require rubygems for ruby/ruby
You can't take rubygems for granted in a default gem.
5873689466

58bb3954d0
2022-11-20 05:19:50 +00:00
Takashi Kokubun
1284baec12
Skip TestDRbSSLAry on mswin
This doesn't seem to stably work on mswin:
5871633211

For CI stability, it generally seems like a bad idea to run druby tests
on Windows, given that it's pretty much unstable on MinGW as well.
2022-11-19 21:14:08 -08:00
Takashi Kokubun
e0f0367ab5 [ruby/irb] Fix CI failure on ruby/ruby
ea8c716922
2022-11-20 05:06:07 +00:00
Stan Lo
180ed611b2 [ruby/irb] Add edit command (https://github.com/ruby/irb/pull/453)
* Add edit command

* Make find_source a public singleton method

* Add document for the edit command

* Make find_end private

* Remove duplicated private

4321674aa7
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-11-20 04:47:54 +00:00
yui-knk
082cfcfd06 Add test cases for args forwarding after rest argument 2022-11-19 10:17:16 +09:00
Alan Wu
7f269a3c2d Fix io/console test for --with-static-linked-ext
The tests looks for the .so file, which doesn't exist when the extension
is statically linked. In that situation it passes -I to ruby with
nothing after it which ate the -rio/console argument.
2022-11-18 18:50:34 -05:00
Aaron Patterson
10788166e7 Differentiate T_OBJECT shapes from other objects
We would like to differentiate types of objects via their shape.  This
commit adds a special T_OBJECT shape when we allocate an instance of
T_OBJECT.  This allows us to avoid testing whether an object is an
instance of a T_OBJECT or not, we can just check the shape.
2022-11-18 08:31:56 -08:00
yui-knk
f0ce118662 Make anonymous rest arg (*) and block arg (&) accessible from ARGS node 2022-11-18 18:25:42 +09:00
Shugo Maeda
ddd62fadaf Allow anonymous keyword rest parameter with other keyword parameters
Fixes [Bug #19132]
2022-11-18 18:23:06 +09:00
Yusuke Endoh
ca1aa7afea Prevent a "method redefined" warning
20221118T033003Z.log.html.gz
```
[21350/22024] TestIRB::ExtendCommandTest#test_show_source_end_finder/home/chkbuild/chkbuild/tmp/build/20221118T033003Z/ruby/test/irb/test_cmd.rb:523: warning: method redefined; discarding old show_source_test_method
/home/chkbuild/chkbuild/tmp/build/20221118T033003Z/ruby/test/irb/test_cmd.rb:523: warning: previous definition of show_source_test_method was here
 ```
2022-11-18 15:39:50 +09:00
Yusuke Endoh
096ffebbbf Prevent a "warning: assigned but unused variable - s2" 2022-11-18 14:39:40 +09:00
Samuel Williams
ea8a7287e2
Add support for sockaddr_un on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00
Takashi Kokubun
4e4b29b1a9
YJIT: Make the code GC test stabler
The first `add_pages` call shouldn't hit Code GC yet; otherwise
`compiles` returns false. With the increased code size in runtime_stats
itself, it sometimes hits Code GC too early, at least in arm64 that has
a large code size.
2022-11-17 14:02:01 -08:00
st0012
923c1aaed7
Drop Ruby 2.5 support
Because it has reached EOL for more than 1.5 years and it won't be
supported by the next reline version either.
2022-11-17 13:06:32 +09:00
Takashi Kokubun
05af417587
YJIT: Show YJIT build option in RUBY_DESCRIPTION (#6738)
YJIT: Show YJIT profile in RUBY_DESCRIPTION
2022-11-16 10:08:52 -08:00
Stan Lo
9751b54971 [ruby/irb] Improve testing infra
(https://github.com/ruby/irb/pull/442)

* Add test_in_isolation task to run tests in isolation

This simulates how tests are run in Ruby CI and can detect some issues
before they're merged and break Ruby CI later.

* Run test_in_isolation task on CI

* Fix TestRaiseNoBacktraceException's setup

51f23c58b0
2022-11-15 17:26:51 +00:00
Hiroshi SHIBATA
36dc99af5a
Added empty class for test methods in TestIRB cases 2022-11-15 20:19:43 +09:00
st0012
1eae15142f [ruby/irb] Remove duplicated TestInputMethod definitions
4b831d02e1
2022-11-15 10:07:32 +00:00
Takashi Kokubun
d15d1c01c2
Rename --mjit-min-calls to --mjit-call-threshold (#6731)
for consistency with YJIT
2022-11-14 23:38:52 -08:00
Yusuke Endoh
81c494d810 [ruby/error_highlight] Enable tests for TypeError and ArgumentError
These tests were unintentionally disabled by `if false`

fa6d00d80d
2022-11-14 06:22:35 +00:00
Takashi Kokubun
96d29dff66
Fix invokebuiltin in Ruby MJIT
45fe7f7575/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb (L21)
has not been ported correctly.
2022-11-13 21:14:47 -08:00
Kenta Murata
ef1c6109b1 [ruby/bigdecimal] Tweak check_rounding_mode_option
e1c6c9be25
2022-11-13 02:02:02 +00:00
Stan Lo
14a1394bcd [ruby/irb] Simplify info command's tests
(https://github.com/ruby/irb/pull/440)

5942949226
2022-11-11 21:05:35 +00:00
Hiroshi SHIBATA
28611be6ee Merge RubyGems/Bundler master from ee2f8398324af4bc1b95f7565ce2fda98126e026 2022-11-11 17:24:08 +09:00
Josef Šimánek
de159c5a85 [rubygems/rubygems] Store last check even when upgrade is not available and fix test.
bcffc2b0a5
2022-11-11 17:24:08 +09:00
Josef Šimánek
7ce0f81fbb [rubygems/rubygems] Use file in XDG_STATE_HOME directory to store last update check timestamp.
0fbc4ace8a
2022-11-11 17:24:08 +09:00
Josef Šimánek
c7d043065c [rubygems/rubygems] Add 'call for update' to RubyGems install command.
05811f8248
2022-11-11 17:24:08 +09:00
Jason Karns
ceeefb5870 [rubygems/rubygems] github source should default to secure protocol
Bundler 2 switched to secure https here c2e81f8ff6

Insecure protocols should be avoided to prevent MITM attacks.

758413364a
2022-11-11 17:24:08 +09:00
Yusuke Endoh
adfbee85e0 Allow a float error for Regexp.timeout
The tests failed on windows

5740085169 (step):18:62
```
    1) Failure:
  TestRegexp#test_s_timeout [D:/a/ruby/ruby/src/test/ruby/test_regexp.rb:1586]:
  <0.30000000000000004> expected but was
  <0.3>.

    2) Failure:
  TestRegexp#test_timeout_shorter_than_global [D:/a/ruby/ruby/src/test/ruby/test_regexp.rb:1631]:
  <0.30000000000000004> expected but was
  <0.3>.
```
2022-11-11 09:07:00 +09:00
Takashi Kokubun
8fa83fa0b2 [ruby/irb] Transform ls's --grep/-G option to keyword args
(https://github.com/ruby/irb/pull/437)

* Transform ls's --grep/-G option to keyword args

* Make --grep less flexible

* Support -g instead of --grep

* Suppress warnings from symbol aliases
2022-11-10 22:55:15 +00:00
Yusuke Endoh
06e17d7659 Run EnvUtil.apply_timeout_scale outside of assert_separately
It does not work well in assert_separately
2022-11-11 07:42:03 +09:00
Thomas E. Enebo
51d161980a [ruby/racc] Make racc test more flexible (for JRuby).
JRuby uses these same files for testing racc. The existing logic will not
find 'racc' in a JRuby project checkout. This change allows it to work by
just assuming 'ruby -S racc' when running tests. This will not change C
Ruby's detection when setting up tests (since earlier checks will find
racc).

b74ce5e018
2022-11-10 22:36:34 +00:00
Takashi Kokubun
2b8191bdad
YJIT: Invalidate JIT code only for ISEQ_TRACE_EVENTS (#6695) 2022-11-10 17:12:38 -05:00
Takashi Kokubun
0de3bc92b4 [ruby/irb] Make $ and @ default aliases
(https://github.com/ruby/irb/pull/438)

0613589476
2022-11-10 17:31:15 +00:00
Jemma Issroff
5246f4027e Transition shape when object's capacity changes
This commit adds a `capacity` field to shapes, and adds shape
transitions whenever an object's capacity changes. Objects which are
allocated out of a bigger size pool will also make a transition from the
root shape to the shape with the correct capacity for their size pool
when they are allocated.

This commit will allow us to remove numiv from objects completely, and
will also mean we can guarantee that if two objects share shapes, their
IVs are in the same positions (an embedded and extended object cannot
share shapes). This will enable us to implement ivar sets in YJIT using
object shapes.

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2022-11-10 10:11:34 -05:00
Jemma Issroff
9986697b62 Omit test on IO Buffers which relies on String being embedded
There is currently a bug ([#19084]) in how extended strings work in
IO Buffers. Object Shapes changes will make the string in this test
extended on 32 bit machines. Since this behavior is currently broken
(unrelated to object shapes) on 32 bit machines, this test will then
fail. We preemptively omit it so that this commit can be reverted
once the bug is fixed.
2022-11-10 10:11:34 -05:00
Jemma Issroff
199b59f065 Fix bug in array pack with shared strings
If string literals are long and they become shared, we need to make them
independent before we can write to them. [Bug #19116]
2022-11-10 09:26:37 -05:00
Nobuyoshi Nakada
b7e8876704
[Bug #19100] Add init_int32 function to rb_random_interface_t
Distinguish initialization by single word from initialization by
array.
2022-11-10 12:06:13 +09:00
Nobuyoshi Nakada
6eaed20e14
Add version to the interface of Random extensions 2022-11-10 11:59:45 +09:00
TSUYUSATO Kitsune
0a14825f73 Update timeout seconds for square test 2022-11-09 23:21:26 +09:00