Commit graph

16449 commits

Author SHA1 Message Date
Nobuyoshi Nakada
3c85698da2
Stop stale tests [Bug #9718] 2021-09-02 01:39:01 +09:00
Nobuyoshi Nakada
0729052329
Test against the target class 2021-09-02 01:33:30 +09:00
Aaron Patterson
cd4f5b1322
Guard array when appending
This prevents early collection of the array.  The GC doesn't see the
array on the stack when Ruby is compiled with optimizations enabled

[ruby-core:105099] [Bug #18140]
2021-09-02 01:22:19 +09:00
aycabta
cf2faf2e33 [ruby/rdoc] Move RDoc::RDoc#load_options to RDoc::RDoc.load_options
ac85e01756
2021-09-02 00:32:13 +09:00
aycabta
67eaa222cf Add a test for Readline.readline without tty 2021-09-01 17:29:01 +09:00
aycabta
a75f38431e Revert "Omit some tests until debugging is complete"
This reverts commit 3695d94b25.
2021-08-31 20:35:04 +09:00
jory-graham
db154b20cc [ruby/psych] Replace A-Za-z with [:alpha:]
8ec36494fb
2021-08-31 19:34:54 +09:00
Aaron Patterson
9ed2cb26de [ruby/psych] Add quotes to the strings "y" and "n"
'y' and 'n' are kind of ambiguous.  Syck treated y and n literals in
YAML documents as strings.  But this is not what the YAML 1.1 spec says.
YAML 1.1 says they should be treated as booleans.  When we're dumping
documents, we know it's a string, so adding quotes will eliminate the
"ambiguity" in the emitted document

Fixes #443

6a1c30634e
2021-08-31 19:34:46 +09:00
Alexandr Opak
44353d0dee [ruby/psych] add more tests
8f71222bf3
2021-08-31 19:34:28 +09:00
Alexandr Opak
beffa72c27 [ruby/psych] fix typo
ebb0cbded1
2021-08-31 19:34:21 +09:00
Alexandr Opak
48b50cb4fe [ruby/psych] fix parsing integer values with '_' at the end
e0bb853014
2021-08-31 19:34:13 +09:00
Tomer Brisker
31ba0921f8 [ruby/psych] Improve float scalar scanner
Previously, `+.inf` was not handled correctly. Additionally, the regexp
was checking for inf and NaN, even though these cases are handled earlier
in the condition. Added a few tests to ensure handling some missing
cases.

6e0e7a1e9f
2021-08-31 19:34:06 +09:00
David Rodríguez
1e290c31f4 [rubygems/rubygems] Merge Gem::UriParser and Gem::PrintableUri into a Gem::Uri class
The new class is a wrapper on top of an URI. And then, when you want
credentials redacted, you call `#redacted` that returns a copy of itself,
but with credentials redacted.

9581c2740a
2021-08-31 19:06:14 +09:00
Daniel Niknam
ceba866864 [rubygems/rubygems] Remove unnecessary tests
We will be passing string to this class so there is no need to be defensive about it.

30bd52a977
2021-08-31 19:06:14 +09:00
Daniel Niknam
aa898b4206 [rubygems/rubygems] Remove @credential_redacted instance variable
c3bb52eb5c
2021-08-31 19:06:14 +09:00
Daniel Niknam
589377fbdc [rubygems/rubygems] Refactor Gem::RemoteFetcher::FetchError.build back to its initialize method
21dcdd2dc5
2021-08-31 19:06:14 +09:00
Daniel Niknam
a508693f06 [rubygems/rubygems] Remove defensive guards
dba130cd80
2021-08-31 19:06:14 +09:00
Daniel Niknam
fafd9d280a [rubygems/rubygems] Rename Gem::PrintableUri#parsed_uri? to Gem::PrintableUri#valid_uri?
a5177709c9
2021-08-31 19:06:14 +09:00
Daniel Niknam
3adc141a79 [rubygems/rubygems] Refactor Gem::RemoteFetcher::FetchError initializer to build method
The `initialize` method is already doing a lot and by adding the `Gem::PrintableUri` to redact sensitive information, things are getting complicated and hard to read here. For the start, I have refactored the `initialize` method into a class method called `build`.

4312e8fdf5
2021-08-31 19:06:14 +09:00
Daniel Niknam
19e1d3cdce [rubygems/rubygems] Using Gem::PrintableUri in Gem::Request class
The `@uri` variable could be a source URI with a credential. Using `Gem::PrintableUri` to make sure we are redacting sensitive information from it when logging on verbose mode.

f566787211
2021-08-31 19:06:14 +09:00
Daniel Niknam
31c2e6c08e [rubygems/rubygems] Using Gem::PrintableUri in Gem::Commands::InstallCommand class
The `x.source.uri` could be a source URI with a credential. Using `Gem::PrintableUri` to make sure we are redacting sensitive information from it.

8755ee0aaa
2021-08-31 19:06:14 +09:00
Daniel Niknam
b41802421a [rubygems/rubygems] Introduce Gem::PrintableUri that would redact URIs to be used on outputs
We need to redact URI credential in several places and copy pasting the code into each part of it is not ideal. This class is responsible for parsing URI strings and redacting credential from it. Also, it will handle URI object in the same manner. We will be reusing this class whenever we need to print/display a URI to users.
URI with the following format will be redacted:
- Token: `http://my-secure-token@example.com` => `http://REDACTED@example.com`
- Username & Password: `http://my-username:my-secure-password@example.com` => `http://my-username:REDACTED@example.com`
- x-oauth-basic: `http://my-secure-token:x-oauth-basic@example.com` => `http://REDACTED:x-oauth-basic@example.com`

f1e45d3a89
2021-08-31 19:06:14 +09:00
Daniel Niknam
14a9e24f7e [rubygems/rubygems] Add a few tests for Gem::UriParser.parse_uri
1ea73df161
2021-08-31 19:06:14 +09:00
Daniel Niknam
c71d1a26ef [rubygems/rubygems] Pick the last founded gems when fetching metadata
e3d150d822

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2021-08-31 19:06:14 +09:00
David Rodríguez
907fa88a76 [rubygems/rubygems] Remove unused file
No longer used since
b7f6270b9e.

76803894a0
2021-08-31 19:06:14 +09:00
David Rodríguez
590d2222a0 [rubygems/rubygems] Remove helper method not buying us much
81dc685d20
2021-08-31 19:06:14 +09:00
David Rodríguez
d01c3111c2 [rubygems/rubygems] Remove MacOS specific extra GEM_PATH
They should properly configure `GEM_PATH` instead.

3bd9ae33ca
2021-08-31 19:06:14 +09:00
Daniel Niknam
717ad64f41 [rubygems/rubygems] Replace StandardError with Exception
We think it's unlikely that `rubygems/defaults/operating_system` could be shipped with a SyntaxError so StandardError could be better choice to prevent "false positives" errors.

1f73e784dd
2021-08-31 19:06:14 +09:00
Daniel Niknam
34e073c0ca [rubygems/rubygems] Reword the message
For errors that could happened while loading `rubygems/defaults/operating_system`

6e1e2141f8
2021-08-31 19:06:14 +09:00
Daniel Niknam
744e128ed9 [rubygems/rubygems] Exclude truffleruby from the test for failure of operating_system.rb
truffleruby does not raise any error when requiring `rubygems`.

21e2fcd0b2
2021-08-31 19:06:14 +09:00
Daniel Niknam
aafc615b4a [rubygems/rubygems] Enhance error handling when loading the rubygems/defaults/operating_system file
When loading `rubygems/defaults/operating_system`
- we want to keep it silent if the raised exception is a LoadError
- we want to print a message in other cases and ask users to report the issue to their OS support.

Ruby 3 comes with special error handling for loading `rubygems` and it will show a warning when LoadError exception raised for requiring 'rubygem'.
Because of that, we decided to leave the LoadError scenario as it is.
Reference: d1998d8767/gem_prelude.rb (L1-L5)

0a97e12fe1
2021-08-31 19:06:14 +09:00
David Rodríguez
9fa5c4cd07 [rubygems/rubygems] Also load user installed rubygems plugins
82960c262f
2021-08-31 19:06:14 +09:00
David Rodríguez
2d0d1c339a [rubygems/rubygems] Recommend bundle install rather than gem install -g
4028cbc408
2021-08-31 19:06:14 +09:00
David Rodríguez
76b77d9275 [rubygems/rubygems] Refactor reseting RUBYGEMS_GEMDEPS in tests
91dca11112
2021-08-31 19:06:14 +09:00
David Rodríguez
87dfb55c16 [rubygems/rubygems] Use Gem.use_gemdeps only from binstubs
The previous behavior was to automatically require `bundler/setup`
everytime `rubygems` was required, which I think was too much.

b25379a295
2021-08-31 19:06:14 +09:00
David Rodríguez
b6c082fd09 [rubygems/rubygems] Remove misleading comment
When I read, I thought the assertion was incorrect. It's doing the right
thing, though.

e72c27367a
2021-08-31 19:06:14 +09:00
David Rodríguez
19d77a1cfc [rubygems/rubygems] Remove unnecessary spec manipulation
c7c00c280f
2021-08-31 19:06:14 +09:00
David Rodríguez
b17cdad2f8 [rubygems/rubygems] Remove redundant part of error message
It doesn't really add much, in my opinion. We want to be helpful, but
also concise when possible.

9d56009cf7
2021-08-31 19:06:14 +09:00
aycabta
3695d94b25 Omit some tests until debugging is complete 2021-08-31 16:21:40 +09:00
Nobuyoshi Nakada
2dd26bed86
[Feature #16972] Add mode: option to Pathname#mkpath 2021-08-31 11:53:41 +09:00
Nobuyoshi Nakada
66a4768f65 [ruby/irb] Relax backtrace nest levels
fb637bc68f
2021-08-30 13:16:46 +09:00
Hiroshi SHIBATA
b17dc55017 [ruby/irb] Added the extra stdout message with test-unit
b153d587a1
2021-08-30 12:39:37 +09:00
Hiroshi SHIBATA
f3ae14cbde [ruby/irb] Use capture_output instead of capture_io
077e4ae7de
2021-08-30 12:39:31 +09:00
Hiroshi SHIBATA
598f4f4219 [ruby/irb] Use pend instead of skip
f441ce35bf
2021-08-30 12:39:23 +09:00
aycabta
ece4ed0da7 Add --autocomplete / --noautocomplete options 2021-08-30 02:45:13 +09:00
aycabta
24a26db795 [ruby/reline] Disable autocompletion in tests
9b1913567a
2021-08-30 02:37:23 +09:00
aycabta
3bbe860e50 [ruby/irb] Remove path settings for debugging
48029944a5
2021-08-30 02:33:29 +09:00
Jeremy Evans
2d98593bf5 Support tracing of attr_reader and attr_writer
In vm_call_method_each_type, check for c_call and c_return events before
dispatching to vm_call_ivar and vm_call_attrset.  With this approach, the
call cache will still dispatch directly to those functions, so this
change will only decrease performance for the first (uncached) call, and
even then, the performance decrease is very minimal.

This approach requires that we clear the call caches when tracing is
enabled or disabled.  The approach currently switches all vm_call_ivar
and vm_call_attrset call caches to vm_call_general any time tracing is
enabled or disabled. So it could theoretically result in a slowdown for
code that constantly enables or disables tracing.

This approach does not handle targeted tracepoints, but from my testing,
c_call and c_return events are not supported for targeted tracepoints,
so that shouldn't matter.

This includes a benchmark showing the performance decrease is minimal
if detectable at all.

Fixes [Bug #16383]
Fixes [Bug #10470]

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2021-08-29 07:23:39 -07:00
aycabta
7ea46c1ef2 [ruby/reline] Fix tests so that the completion journey starts on first C-n/C-p
52a40f2cd3
2021-08-29 20:30:33 +09:00
Nobuyoshi Nakada
a615885f1e
Free previously used tables [Bug #18134] 2021-08-29 17:18:58 +09:00