Commit graph

18546 commits

Author SHA1 Message Date
Kevin Newton
7dba4f424d [ruby/prism] IBM861 encoding
6d2b59384a
2023-11-16 17:39:37 +00:00
Kevin Newton
91af9e8d93 [ruby/prism] IBM860 encoding
aa6163d77a
2023-11-16 17:39:37 +00:00
Kevin Newton
a7df025c3f [ruby/prism] IBM857 encoding
8c9b580f84
2023-11-16 17:39:36 +00:00
Kevin Newton
076d0957b9 [ruby/prism] IBM855 encoding
9354ad1848
2023-11-16 17:39:36 +00:00
Kevin Newton
b0a188655d [ruby/prism] IBM852 encoding
45251fcbf1
2023-11-16 17:39:35 +00:00
Kevin Newton
ef748f353b [ruby/prism] IBM775 encoding
65175641b1
2023-11-16 17:39:34 +00:00
Kevin Newton
ae3c346746 [ruby/prism] IBM-737 encoding
af1a665939
2023-11-16 17:39:33 +00:00
Kevin Newton
8c44d69b9f [ruby/prism] IBM720 encoding
fc1f6ea3af
2023-11-16 17:39:33 +00:00
Kevin Newton
ba937eee0b [ruby/prism] IBM437 encoding
d60329eeb5
2023-11-16 17:39:32 +00:00
Kevin Newton
f60b974393 [ruby/prism] Add cp855 encoding
8069d143f5
2023-11-16 17:39:32 +00:00
Kevin Newton
5d7e6842b5 [ruby/prism] Add cp852 encoding
ebe83490bf
2023-11-16 17:39:31 +00:00
Kevin Newton
63c490dc4e [ruby/prism] Add remaining windows encodings
e77b549a59
2023-11-16 17:39:30 +00:00
Kevin Newton
ca789e7232 [ruby/prism] Add windows-1250 encoding
a362535ca4
2023-11-16 17:39:30 +00:00
Maple Ong
1ead19825d [ruby/prism] Test cp51932
29ba8cd1f2
2023-11-16 17:13:17 +00:00
Haldun Bayhantopcu
e3f464522c [ruby/prism] Fix calls with splat without parenthesis
d81a77e0e3
2023-11-16 15:13:08 +00:00
TSUYUSATO Kitsune
64a122acfd [ruby/prism] Add test cases for in in case condition
Fix https://github.com/ruby/prism/pull/1515

It is also fixed by #1807, so this adds only test cases.

a0092f075e
2023-11-16 15:12:01 +00:00
toshimaru
72242e69aa [ruby/rdoc] fix: Fix NoMethodError for tokens_to_s method
Calling `tokens_to_s` gets an error if `token_stream` is nil:

```
undefined method `compact' for nil:NilClass (NoMethodError)
```

So, fall back to an empty array if `@token_stream` is nil.

452e4a2600
2023-11-16 01:43:12 +00:00
Kevin Newton
d2e7a70ee6 [ruby/prism] Track the then keyword for conditionals
fef0019a25
2023-11-15 23:08:11 +00:00
David Rodríguez
e9bc530795
[rubygems/rubygems] Make temp gem home independent of pwd
5c36556d2e
2023-11-15 19:38:28 +09:00
Yusuke Endoh
5bf75c20a2 Refactor the settings of test-all out
test/runner.rb and tool/lib/test/unit/parallel.rb must use the same
settings. However, some settings were copied and pasted, while some were
added only to test/runner.rb.
This changeset creates tool/test/init.rb for all settings of test-unit,
which is loaded not only by test/runner.rb but also
tool/lib/test/unit/parallel.rb.

Background: the GEM_HOME environment variable was removed in
test/runner.rb, which prohibit `require "rake"` (note that rake is a
bundled gem). However the parallel mode didn't refrect this setting,
i.e., `require "rake"` was allowed.
This leads to an inconsistency, which actually affected a test test
defines s test class *only when* `require "rake"` is successful.
(test/rubygems/test_gem_package_task.rb)

1851105563 (step):8:1714
```
  /home/runner/work/ruby/ruby/src/tool/lib/test/unit.rb:729:in `const_get': uninitialized constant TestGemPackageTask (NameError)

                suites.map! {|r| ::Object.const_get(r[:testcase])}
                                         ^^^^^^^^^^
```
2023-11-15 19:27:10 +09:00
Nobuyoshi Nakada
db8d437d4e
No need to save $VERBOSE 2023-11-15 17:52:40 +09:00
Nobuyoshi Nakada
b003c95ef4
Separate tests for Hash only from tests for Hash and its subclasses 2023-11-15 17:52:40 +09:00
Hiroshi SHIBATA
536649f819
Fix IRB tests (#8925)
* Revert "Fixup da2c2931a6"

This reverts commit e1978a905a.

* Revert "Skip Type completion tests related with IRB::VERSION"

This reverts commit da2c2931a6.

* require irb/version to test IRB::VERSION

---------

Co-authored-by: tompng <tomoyapenguin@gmail.com>
2023-11-15 14:58:51 +09:00
Hiroshi SHIBATA
e1978a905a Fixup da2c2931a6 2023-11-15 12:11:12 +09:00
Yuta Saito
9cba65fd18 test: Follow-up fix for #8916
`test_thread_trace` is also flaky due to the same reason as #8916.

20231114T213002Z.fail.html.gz
20231114T090003Z.fail.html.gz
2023-11-15 11:38:55 +09:00
Hiroshi SHIBATA
da2c2931a6 Skip Type completion tests related with IRB::VERSION 2023-11-15 11:02:16 +09:00
Hiroshi SHIBATA
197ab823ba
Revert "Tests of irb is still broken."
This reverts commit 5398bbcbab.

  We explicitly load rubygems at rubygems_ext.rb

  8840d8507b
2023-11-15 10:09:00 +09:00
Kevin Newton
befad28f30
Resync prism delete bin/dot 2023-11-14 16:22:03 -05:00
TSUYUSATO Kitsune
93e9be2f69
[ruby/prism] Check value expressions on creating a node
d60948bac3
2023-11-14 16:22:03 -05:00
TSUYUSATO Kitsune
5048c4f461
[ruby/prism] Check value expressions on parsing arguments and assignments
They are corresponding to `arg_value` in `parse.y`.

a4a4834e0d
2023-11-14 16:22:03 -05:00
Kevin Newton
ed75518192
[ruby/prism] Rename librubyparser to libprism
librubyparser was an artifact of the prototype that was initially
named ruby-parser. Instead, this renames it to libprism to be
consistent with the actual name.

8600b06811
2023-11-14 16:22:03 -05:00
TSUYUSATO Kitsune
80e379bda1
[ruby/prism] Check value expressions on parsing arguments and assignments
They are corresponding to `arg_value` in `parse.y`.

a4a4834e0d
2023-11-14 16:22:02 -05:00
TSUYUSATO Kitsune
336d81a671 [ruby/prism] Check value expressions on creating a node
d60948bac3
2023-11-14 14:34:48 +00:00
TSUYUSATO Kitsune
499786de46 [ruby/prism] Check value expressions on parsing arguments and assignments
They are corresponding to `arg_value` in `parse.y`.

a4a4834e0d
2023-11-14 14:34:48 +00:00
TSUYUSATO Kitsune
3439f1e62e [ruby/prism] Add parse_value_expression
37fad74134
2023-11-14 14:34:47 +00:00
Mike Dalessio
26d11383e5 [ruby/prism] fix: float suffix at end of file
Found by fuzzing.

d77d4fe2b7
2023-11-14 14:25:41 +00:00
Mike Dalessio
d6d1a1839a [ruby/prism] fix: nested heredoc dedentation use-after-free
Because the lex mode may be freed when popped, we need to store off
this value for dedentation.

64007322f5

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2023-11-14 14:11:55 +00:00
Nobuyoshi Nakada
9935512275 [ruby/rdoc] Fix TIDYLINK after braces
(https://github.com/ruby/rdoc/pull/1015)

TIDYLINK multi-word label should not include braces.

41ad3191e9
2023-11-14 07:59:56 +00:00
Yuta Saito
50e1c293b7 test: Assert only events originated from the test_settracefunc.rb test file
This test suite is flaky on CI, because the test asserts events from
finalizers also. Tracing events from finalizers is not deterministic
and is not a part of test interests, so this commit changes the test
to assert only events originated from the test file itself.
2023-11-14 16:01:07 +09:00
Mike Dalessio
e020eb26f0 [ruby/prism] fix: Handle zero-length block parameters in invalid Ruby
Found by fuzzing.

4cd6c8cf98
2023-11-14 05:25:46 +00:00
Peter Zhu
fabf5bead7 Don't overwrite shape capacity when removing ivar
Other objects may be using the shape, so we can't change the capacity
otherwise the other objects may have a buffer overflow.
2023-11-13 18:26:36 -05:00
Yuta Saito
e8ab3f7010 test: Check file name in test_thread_add_trace_func also
For better assert failure diagnostics.
2023-11-14 06:00:10 +09:00
TSUYUSATO Kitsune
d5c3680a0c [ruby/prism] Add tests for error cases on #1791, #1807, and #1810
231e965124
2023-11-13 13:34:24 +00:00
tomoya ishida
90b49024c0 [ruby/reline] Fallback to 256color if COLORTERM != truecolor
(https://github.com/ruby/reline/pull/604)

* Fallback to 256color if COLORTERM != truecolor

* Add Reline::Face.force_truecolor to force truecolor without COLORTERM env

090e1e4df0
2023-11-13 12:42:31 +00:00
Jean Boussier
a1887f4dc2 Revert "Fix crash caused by concurrent ObjectSpace.dump_all calls"
This reverts commit 9a62fd3cba.
2023-11-13 08:57:57 +01:00
Jean Boussier
9ca41e9991 GVL Instrumentation: pass thread->self as part of event data
Context: https://github.com/ivoanjo/gvl-tracing/pull/4

Some hooks may want to collect data on a per thread basis.
Right now the only way to identify the concerned thread is to
use `rb_nativethread_self()` or similar, but even then because
of the thread cache or MaNy, two distinct Ruby threads may report
the same native thread id.

By passing `thread->self`, hooks can use it as a key to store
the metadata.

NB: Most hooks are executed outside the GVL, so such data collection
need to use a thread-safe data-structure, and shouldn't use the
reference in other ways from inside the hook.

They must also either pin that value or handle compaction.
2023-11-13 08:45:20 +01:00
Vít Ondruch
5bb7562872 [rubygems/rubygems] Explicitly define @default_specifications_dir for tests
Resetting `@default_specifications_dir` to `nil` means that the
`Gem.default_specifications_dir` needs to be invoked. However, given
that this method might be overridden by operating_system.rb and similar,
this might lead to various test failures. Providing the default value
makes the issues go away.

59626cb650
2023-11-13 11:06:10 +09:00
Vít Ondruch
28f7a46f44 [rubygems/rubygems] Provide more insightful test error output
Original output:

~~~
Failure: test_realworld_upgraded_default_gem(TestGemRequire): <false> is not true.
/mnt/test/rubygems/test_require.rb:474:in `test_realworld_upgraded_default_gem'
     471:     File.write(path, code)
     472:
     473:     output = Gem::Util.popen({ "GEM_HOME" => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip
  => 474:     assert $?.success?
     475:     refute_empty output
     476:     assert_equal "999.99.9", output.lines[0].chomp
     477:     # Make sure only files from the newer json gem are loaded, and no files from the default json gem
~~~

New output:

~~~
Failure: test_realworld_upgraded_default_gem(TestGemRequire)
/mnt/test/rubygems/test_require.rb:475:in `test_realworld_upgraded_default_gem'
     472:
     473:     output = Gem::Util.popen({ "GEM_HOME" => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip
     474:     refute_empty output
  => 475:     assert_equal "999.99.9", output.lines[0].chomp
     476:     # Make sure only files from the newer json gem are loaded, and no files from the default json gem
     477:     assert_equal ["#{@gemhome}/gems/json-999.99.9/lib/json.rb"], output.lines.grep(%r{/gems/json-}).map(&:chomp)
     478:     assert $?.success?
<"999.99.9"> expected but was
<"/mnt/tmp/test_rubygems_20231110-36663-of405r/test_realworld_upgraded_default_gem.rb:3:in `<main>': undefined method `version' for nil:NilClass (NoMethodError)">

diff:
? 999                                                                             .99.9
? /mnt/tmp/test_rubygems_20231110-36663-of405r/test_realworld_upgraded_default_gem rb:3:in `<main>': undefined method `version' for nil:NilClass (NoMethodError)
? ??? ????
~~~

It is more valuable to check the command output then the error code. If
the command fails for some reason, the output probably contains some
detail, while checking the return code tells not much.

b76062e852
2023-11-13 11:06:10 +09:00
David Rodríguez
54511303a4 [rubygems/rubygems] Drop support for Ruby 2.6 and Ruby 2.7 in RubyGems
10c26a483d
2023-11-13 11:06:10 +09:00
Vít Ondruch
43b8b88751 [rubygems/rubygems] Report possible error prior checking output of gem uninstall
Originally, the failed test case reported following error:

~~~
Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <""> was expected to include
  <"Successfully uninstalled a-2\n">.
/mnt/test/rubygems/test_gem_commands_exec_command.rb:742:in `block in test_gem_exec_gem_uninstall'
     739:
     740:       # assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
  => 742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
     744:       invoke "--verbose", "gem", "uninstall", "b"
     745:       assert_includes @ui.output, "Successfully uninstalled b-2\n"
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'
~~~

This does not tell much. Empty string is more often good sign, but not
in this case. However, checking error output first helps with
understanding possible issue:

~~~
Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <"ERROR:  While executing gem ... (Gem::FilePermissionError)\n" +
  "    You don't have write permissions for the /builddir/bin directory.\n" +
  "\t/mnt/lib/rubygems/uninstaller.rb:213:in `remove_executables'\n" +

... snip ...

/mnt/test/rubygems/test_gem_commands_exec_command.rb:740:in `block in test_gem_exec_gem_uninstall'
     737:         nil
     738:       end
     739:
  => 740:       assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
     742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'
~~~

BTW this issue is caused by operating_system.rb overriding
`Gem.operating_system_defaults` method and explicitly adding `--bindir`
option.

d98e36bbe7
2023-11-13 11:06:10 +09:00