Commit graph

20692 commits

Author SHA1 Message Date
Étienne Barrié
257f78fb67 Show where mutated chilled strings were allocated
[Feature #20205]

The warning now suggests running with --debug-frozen-string-literal:

```
test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
```

When using --debug-frozen-string-literal, the location where the string
was created is shown:

```
test.rb:3: warning: literal string will be frozen in the future
test.rb:1: info: the string was created here
```

When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW.
When mutating chilled strings and deprecation warnings are not enabled,
the overhead is a simple warning category enabled check.

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-10-21 12:33:02 +02:00
Go
fe17697aac [ruby/irb] Improve history test's encoding setting
(https://github.com/ruby/irb/pull/1022)

* improve history test's encoding setting

* fix missing locale error for ci and refactoring

7f385bc19b
2024-10-20 06:18:07 +00:00
Taketo Takashima
eb8cf1d60e [ruby/ipaddr] Added to_json/as_json method
Updated to use cidr method when return address with prefix in #as_json

cf8181d53e
2024-10-18 15:00:37 +00:00
kojix2
9a98b70a50 [ruby/fiddle] test: Fix a typo
(https://github.com/ruby/fiddle/pull/154)

1f818e4684
2024-10-18 11:35:00 +09:00
Stephen Humphries
326a21d441
Relax Pure::Parser's comment regex...
...to allow any character sequence, including "/*", before then end
sequence of a multi-line ANSI C-style comment
.
2024-10-18 11:31:42 +09:00
Jean Boussier
8feed977a0 [ruby/json] Assume Encoding is defined
8713aa4812
2024-10-18 11:30:55 +09:00
Takumasa Ochi
20dc1e5c25 [ruby/json] Always dup argument to preserve original encoding for force_encoding
db9a489ca2
2024-10-18 11:30:42 +09:00
YuheiNakasaka
57e1b64c81 [ruby/json] Fix behavior of trying to parse non-string objects
e2e9936047
2024-10-18 11:28:13 +09:00
Mike Dalessio
0b38e18488 [ruby/rdoc] feature: Render mixed-in methods and constants with
`--embed-mixins`
(https://github.com/ruby/rdoc/pull/842)

* Embed mixed-in methods and constants with `--embed-mixins`

When `--embed-mixins` option is set:

- methods from an `extend`ed module are documented as singleton methods
- attrs from an `extend`ed module are documented as class attributes
- methods from an `include`ed module are documented as instance methods
- attrs from an `include`ed module are documented as instance attributes
- constants from an `include`ed module are documented

Sections are created when needed, and Darkfish's template annotates
each of these mixed-in CodeObjects. We also respect the mixin methods'
visibility.

This feature is inspired by Yard's option of the same name.

* Add comment to document why we set object visibility

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Add the mixin_from attribute to CodeObject's initializer

* Add test coverage for private mixed-in attributes.

---------

481c2ce660

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-10-17 20:40:34 +00:00
Nobuyoshi Nakada
9da60a14bf [ruby/etc] Fix sysconfdir when load-relative
When relative load paths option is enabled, the prefix is determined
at the runtime.  The only way to get it outside libruby is to use
rbconfig.rb.

e5b498fad9
2024-10-17 07:32:38 +00:00
Lars Kanis
85ce3b177c [ruby/win32-registry] Fix compatibility with JRuby
JRuby's fiddle implementation has quite some shortcomings compared with the CRuby impl.
Add JRuby tests in CI.

7f34184c2e
2024-10-17 01:51:41 +00:00
Lars Kanis
6a49bbd734 [ruby/win32-registry] Move all tests to volatile environment and use per-test individual registry key
This allows to run all tests in parallel.
Usage of `File` methods is avoided.
Since all tests are executed in the volatile environment of the registry,
the dedicated 'create_volatile' test is removed now.
Also add some documentation to the test setup.

Downside of this use of the "Volatile Environment" is that we can not use or test
the `create` method with default options.
This is because within this path only keys with option `REG_OPTION_VOLATILE` are allowed.

3c186ae7dd
2024-10-17 01:48:05 +00:00
Peter Zhu
90aa6aefc4 Fix memory leak in syntax error in prism
If there is a syntax error, there could be an ast_node in the result.
This could get leaked if there is a syntax error so parsing could not
complete (parsed is not set to true).

For example, the following script leaks memory:

    10.times do
      10_000.times do
        eval("def foo(...) super(...) {}; end")
      rescue SyntaxError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    31328
    42768
    53856
    65120
    76208
    86768
    97856
    109120
    120208
    131296

After:

    20944
    20944
    20944
    20944
    20944
    20944
    20944
    20944
    20944
    20944
2024-10-16 14:52:46 -04:00
Kevin Newton
5eca11ca5e RubyVM::InstructionSequence.of Thread::Backtrace::Location
This would be useful for debugging.
2024-10-16 14:31:26 -04:00
Kevin Newton
550ae745f6 [ruby/prism] Relocation
5ea6042408
2024-10-16 15:56:01 +00:00
Peter Zhu
ebfe615a0c Skip GC compaction tests in test_yjit.rb when not supported 2024-10-16 10:17:54 -04:00
Hiroshi SHIBATA
21bac99122 [ruby/yaml] Make YAML::DBM optional
f7c44d3fd7
2024-10-16 17:04:37 +09:00
Hiroshi SHIBATA
1d7547f50d [ruby/yaml] Also use safe_load with each_value, values and shift
f47d6123eb
2024-10-16 17:04:36 +09:00
Hiroshi SHIBATA
623897c97e [ruby/yaml] Added basic test cases
36a339c0d7
2024-10-16 17:04:35 +09:00
Hiroshi SHIBATA
1379ef6f7d [ruby/json] Embedded helper.rb into test_helper.rb
f8417ffc69
2024-10-16 04:34:22 +00:00
Hiroshi SHIBATA
3c1b0f21aa [ruby/json] Fixed load path for ext version
c17823688e
2024-10-16 04:34:21 +00:00
Hiroshi SHIBATA
8af6606b22
Restore missing test-case from c5a6d80427
Co-authored-by: "Jean Boussier" <byroot@ruby-lang.org>
2024-10-16 11:24:25 +09:00
Jean Boussier
fdbead76ec
[ruby/json] ractor_test.rb: ignore stderr
When rubygems is double loaded it fails the test.

The warning should happen in the first place but this
makes the test more resilient.

513ddeaeb1
2024-10-16 11:24:25 +09:00
Sutou Kouhei
8d127c9b59
Use JRuby implementation for TruffleRuby (#149)
Fix GH-145

Rename `lib/fiddle/jruby.rb` to `lib/fiddle/ffi_backend.rb` as a generic
ffi gem API based implementation.
JRuby and TruffleRuby use `lib/fiddle/ffi_backend.rb`.

---------

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-10-16 11:24:25 +09:00
Nobuyoshi Nakada
bbd5b8ddae
[ruby/fiddle] Ractor support
(https://github.com/ruby/fiddle/pull/139)

91d0ea9849

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-10-16 11:24:25 +09:00
Vinicius Stock
ed993b5bcc [ruby/rdoc] Generate meta tags based on page's content
(https://github.com/ruby/rdoc/pull/1091)

716bc16a7d
2024-10-15 22:59:33 +00:00
Peter Zhu
3da3cabf98 Remove a puts in test_finalizer_thread_raise 2024-10-15 09:10:35 -04:00
David Rodríguez
48fdb9faa0 [rubygems/rubygems] Fix gem contents for default gems
A default gem does not always live in the same place. For example,
Bundler may be installed to `site_dir` when RubyGems have been upgraded.

A more reliable way seems to actually activate the default gem, so that
we can know for sure where it lives.

c69f6dfb18
2024-10-14 17:51:24 +00:00
David Rodríguez
57404e4369 [rubygems/rubygems] Fix duplicated specs when they have been previously activated
b44bf2ac74
2024-10-14 14:51:20 +00:00
Nobuyoshi Nakada
9611c619ac
[Bug #20797] Check seconds in UTC offset as well as minutes 2024-10-14 13:55:55 +09:00
tomoya ishida
98fce00cab [ruby/reline] Support continuous tab completion
(https://github.com/ruby/reline/pull/761)

Continuous tab completion is possible in GNU Readline.
If dig_perfect_match_proc is set, continuous tab completion will be disabled.

469a52846b
2024-10-13 04:55:41 +00:00
tomoya ishida
c12c95462a [ruby/irb] Fix rendering test broken by conflict
(https://github.com/ruby/irb/pull/1016)

a21b953a99
2024-10-13 04:30:33 +00:00
John Bampton
afacb8ada5
[DOC] Fix spelling 2024-10-12 12:48:10 +00:00
tomoya ishida
199b298049 [ruby/irb] Make rendering test faster using updated yamatanooroti
(https://github.com/ruby/irb/pull/1001)

2c2956bc1f
2024-10-12 04:24:37 +00:00
Kevin Newton
5f62522d5b [ruby/prism] Prism::StringQuery
Introduce StringQuery to provide methods to access some metadata
about the Ruby lexer.

d3f55b67b9
2024-10-11 19:34:57 +00:00
Peter Zhu
8aeb60aec8 Rename supports_auto_compact? to supports_compact?
It's testing whether GC compaction is supported in general.
2024-10-11 15:29:10 -04:00
Peter Zhu
6a88e9d430 Used respond_to? check for compaction in test_gc_compact.rb 2024-10-11 15:29:10 -04:00
Gert Goet
eccfb6e60c [ruby/irb] History refactors (https://github.com/ruby/irb/pull/1013)
* Extract logic save_history in separate helper

* Extract logic history_file in helper

* Allow for readonly history

52307f9026
2024-10-11 16:34:19 +00:00
Peter Zhu
2dab59933c Remove defined check for GC.config in test_gc.rb
GC.config is always defined.
2024-10-11 11:35:45 -04:00
David Rodríguez
01abc2f79e [rubygems/rubygems] Check that the binstub was actually reset
d46fca6126
2024-10-11 09:40:44 +00:00
David Rodríguez
1ad990a366 [rubygems/rubygems] Only pristine executables for default gems
1cfc1d626c
2024-10-10 19:46:44 +00:00
Kevin Newton
7a198af7cd [ruby/prism] Prism::CodeUnitsCache
Calculating code unit offsets for a source can be very expensive,
especially when the source is large. This commit introduces a new
class that wraps the source and desired encoding into a cache that
reuses pre-computed offsets. It performs quite a bit better.

There are still some problems with this approach, namely character
boundaries and the fact that the cache is unbounded, but both of
these may be addressed in subsequent commits.

2e3e1a4d4d
2024-10-10 18:02:27 +00:00
Peter Zhu
9df86a86af Fix typo in test_gc.rb [ci skip] 2024-10-10 11:44:52 -04:00
Kevin Newton
b5ecb03ae4 [ruby/prism] Do not warn for unused variables on negative lines
Fixes [Bug #20788]

27e91f21af
2024-10-10 15:13:10 +00:00
David Rodríguez
d12c8cbf14 [rubygems/rubygems] Fix gem pristine etc resetting gem twice sometimes
If a default version and a regular version of etc are present at the
same time, RubyGems will end up duplicating work and running pristine
twice.

The `etc` gem is special because it's loaded by RubyGems by default.
When doing this, RubyGems will activate the regularly installed version.
The when `gem pristine` runs, it will find to installed specifications
but materialize both to the already activated specification.

Before:

```
$ gem pristine etc --version 1.4.3
Restoring gems to pristine condition...
Building native extensions. This could take a while...
Restored etc-1.4.3
Building native extensions. This could take a while...
Restored etc-1.4.3
```

After:

```
$ gem pristine etc --version 1.4.3
Restoring gems to pristine condition...
Skipped etc-1.4.3, it is a default gem
Building native extensions. This could take a while...
Restored etc-1.4.3
```

5c279ac56b
2024-10-10 14:54:04 +00:00
David Rodríguez
36e9a6bb41 [rubygems/rubygems] Improve some indentations
30f228a97f
2024-10-10 14:54:04 +00:00
David Rodríguez
a1492ffdc2 [rubygems/rubygems] Run specs that now pass on JRuby
2af077ee38
2024-10-10 14:51:30 +00:00
Kevin Newton
82c76f1896 [ruby/prism] Reject invalid splat as last statement of parentheses
3a0b1c6110
2024-10-10 14:45:59 +00:00
Hiroshi SHIBATA
2cf4aa0801
[ruby/fiddle] Only print Fiddle::VERSION when flag is true
(https://github.com/ruby/fiddle/pull/151)

The test of current HEAD revision occurred `unknown command` on
`ruby/ruby` repo.

```
$ make test-all -j TESTS="fiddle -j12" MSPECOPT="-j"
(snip)

# Running tests:

unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_pack 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686:waiting 58687=test_pinne
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_pack 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 58687=test_
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_pack 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 58687=test_
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 5868
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 586
unknown command: "Fiddle::VERSION: 1.1.3.dev"
unknown command: "Fiddle::VERSION: 1.1.3.dev"
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_struct_builder 58686=test_cparser 5
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_struct_builder 58686=test_cparser 5
unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_struct_builder 58686=test_cparser 5
Finished tests in 1.136194s, 194.5090 tests/s, 929.4187 assertions/s.
221 tests, 1056 assertions, 0 failures, 0 errors, 4 skips
```

I only show fiddle version in this repository with `$VERSBOSE` flag.

31bebd85be
2024-10-10 15:15:54 +09:00
Hiroshi SHIBATA
43d14d50fc
Revert "Commented out to print fiddle version"
This reverts commit a1db8dbe16.
2024-10-10 15:15:54 +09:00