Commit graph

64552 commits

Author SHA1 Message Date
David Rodríguez
9057e9c7b1 [rubygems/rubygems] The file is only ever required when openssl is available
41976ef3ec
2020-07-31 21:07:19 +09:00
David Rodríguez
6eb89f8637 [rubygems/rubygems] Remove now unneeded code
We patch `net-http-persistent` to not autoload `openssl`.

757dec3cf2
2020-07-31 21:07:19 +09:00
David Rodríguez
ea8f7d4a81 [rubygems/rubygems] Gem::Specification#to_ruby doesn't need openssl
The `openssl` require when openssl not present was having the
side-effect the our custom require fallbacks would end up loading `Gem::Specification.stubs`.

Co-authored-by: Alyssa Ross <hi@alyssa.is>

22c4ded4ad
2020-07-31 21:07:19 +09:00
David Rodríguez
6608bc77b6 [rubygems/rubygems] Fix skip message
a763e539cd
2020-07-31 21:07:19 +09:00
David Rodríguez
e1494145d9 [rubygems/rubygems] Make sure tests at least load without openssl
054d57f74b
2020-07-31 21:07:19 +09:00
David Rodríguez
779f1a9c69 [rubygems/rubygems] Set the expected hash in one step
25912ce6c9
2020-07-31 21:07:19 +09:00
David Rodríguez
34527927e8 [rubygems/rubygems] Remove unnecessary check
No check is done for the other expectation and they are completely
symmetric as far as I can see.

4de89e0718
2020-07-31 21:07:19 +09:00
David Rodríguez
69fa0d6d30 [rubygems/rubygems] Move openssl require to a separate file
So it can be reused.

b9fc6e40db
2020-07-31 21:07:19 +09:00
David Rodríguez
6b14249c98 [rubygems/rubygems] In the rubies we support Exception#path is always there
babf943144
2020-07-31 21:07:19 +09:00
David Rodríguez
07dc9691a8 [rubygems/rubygems] https functionality was merged into net/https
d81ce9e457
2020-07-31 21:07:19 +09:00
David Rodríguez
0a7f12fcc6 [rubygems/rubygems] Only require what we are using
d92b94f3cf
2020-07-31 21:07:19 +09:00
David Rodríguez
9ad9c2d9c3 [rubygems/rubygems] Let the original error happen
It will give more useful information.

efcecb5af5
2020-07-31 21:07:19 +09:00
David Rodríguez
b84b4e8bfa [rubygems/rubygems] Remove unnecessary stuff
The `rubygems/security` require already does this.

bbb444b6f1
2020-07-31 21:07:19 +09:00
David Rodríguez
d3efba0950 [rubygems/rubygems] Run test/rubygems/test_bundled_ca.rb locally
It's not that slow.

9b928a4503
2020-07-31 21:07:19 +09:00
David Rodríguez
ed3794495d [rubygems/rubygems] Remove unused TEST_SSL environment variable
1e2c3cf118
2020-07-31 21:07:19 +09:00
Nobuyoshi Nakada
db2047ebaf [rubygems/rubygems] Fix encoding mismatch errors on MinGW
GNU make in MSys is localized to use UTF-8 while Ruby's filesystem
encoding is set to OEM CodePage (e.g., CP932 in Japanese Edition),
the read output from the make has broken encoding and results in
"invalid byte sequence" errors.  As `DESTDIR` is set to a US-ASCII
7bit clean string, matching as binary encoding should have no
problems.

96a5e7523b
2020-07-31 21:07:19 +09:00
bronzdoc
6c19b0ec6e [rubygems/rubygems] Reword warning
cbd4abf8cf
2020-07-31 21:07:19 +09:00
bronzdoc
00bdac18cf [rubygems/rubygems] Warn on duplicate dependency in a specification
af3e5f7883
2020-07-31 21:07:19 +09:00
David Rodríguez
985309ac38 [rubygems/rubygems] Support PATH's using File::ALT_SEPARATOR in Gem::Installer
Co-authored-by: MSP-Greg <MSP-Greg@users.noreply.github.com>

710b969b60
2020-07-31 21:07:19 +09:00
David Rodríguez
04d3e0727a [rubygems/rubygems] Move traling if to the same line for readablity
d722b8b578
2020-07-31 21:07:19 +09:00
David Rodríguez
c090c64b4f [rubygems/rubygems] Prefer the standard separator on Windows
It seems like the most common case since it requires no tricks on our
CI environment.

Co-authored-by: MSP-Greg <MSP-Greg@users.noreply.github.com>

751c475574
2020-07-31 21:07:19 +09:00
Colby Swandale
65a4b03781 [rubygems/rubygems] fix missing identation
2cca6714f3
2020-07-31 21:07:19 +09:00
Jean Boussier
561576367b [rubygems/rubygems] Deduplicate the requirement operators in memory
9963d33cf2
2020-07-31 21:07:19 +09:00
Jeremy Evans
1a935606b5 [rubygems/rubygems] Fix Kernel#warn override to handle backtrace location with nil path
It's very unlikely to hit this case, but it is possible, as
Thread::Backtrace::Location#path can return nil if the location is
a cfunc with no previous iseq.  See location_path in vm_backtrace.c
in Ruby.

511935645a
2020-07-31 21:07:19 +09:00
Benoit Daloze
331fe6a88f [rubygems/rubygems] Ignore internal frames in RubyGems' Kernel#warn
* See https://github.com/oracle/truffleruby/issues/2046
* `<internal:` is a common prefix also used by core Ruby files in CRuby.
* test_no_kernel_require_in_*warn_with_uplevel already test this.
* Unfortunately just skipping `<internal:` in the Ruby implementation
  is not enough, because RubyGems' #warn would not skip the
  `<internal:` require (TruffleRuby defines #require in Ruby),
  and the Ruby implementation's #warn would not skip
  RubyGems's #require. The #caller_locations(0) look like this:

  warnee.rb:1:in `<top (required)>' # where #warn is called
  <internal:core> core/kernel.rb:234:in `gem_original_require' # not skipped by RubyGems' warn, skipped by the Ruby impl
  rubygems/core_ext/kernel_require.rb:54:in `require' # not skipped by the Ruby impl's warn, what would be shown without this fix
  warn.rb:1:in `<main>' # what would be correct

  warn.rb is
  require "warnee"
  warnee.rb is
  puts caller_locations(0), nil
  warn "oops", uplevel: 1

7c838f7419
2020-07-31 21:07:19 +09:00
David Rodríguez
14ab281faa [rubygems/rubygems] Disallow warnings to creep into the test suite
694e6afee7
2020-07-31 21:07:19 +09:00
David Rodríguez
9d6123da15 [rubygems/rubygems] Fix test warning
f4c4cddb68
2020-07-31 21:07:19 +09:00
David Rodríguez
06f84d0567 [rubygems/rubygems] Don't super on main test setup
The `teardown` method doesn't call it either and I don't think it's
necessary.

ca2a5d485d
2020-07-31 21:07:19 +09:00
David Rodríguez
d0cc4ecb8f [rubygems/rubygems] Remove very old compatibility code
6e4bef758b
2020-07-31 21:07:19 +09:00
David Rodríguez
1260d22cae [rubygems/rubygems] Extract some common code into a private method
d1be8cdb3a
2020-07-31 21:07:19 +09:00
David Rodríguez
d5b5a7ab31 [rubygems/rubygems] Remove very old TODO note
It was added 10 years ago on a "146 additions, 170 deletions" commit
named "Deprecation removals and minor cleanup." that didn't explain much
other than that.

This TODO doesn't necessarily apply nowadays. I don't see how anyways.
TODO notes, if useful at all, should include a clear explanation of what
should be done either via the note itself or the commit message. This
note doens't meet any of these.

So I want to remove it because it distracts me every time I go through
it.

58d81e8a32
2020-07-31 21:07:19 +09:00
Jean Boussier
76722c4928 [rubygems/rubygems] Optimize Gem.already_loaded?
Profiling a simple `ruby -e '1'` I see:

```
==================================
  Mode: wall(10)
  Samples: 3414 (55.10% miss rate)
  GC: 856 (25.07%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
       689  (20.2%)         669  (19.6%)     Gem.already_loaded?
       462  (13.5%)         462  (13.5%)     (marking)
       393  (11.5%)         393  (11.5%)     (sweeping)
       815  (23.9%)         365  (10.7%)     Gem::Specification.load
      1050  (30.8%)         156   (4.6%)     Gem.register_default_spec
       100   (2.9%)          84   (2.5%)     Gem::Specification#files
        64   (1.9%)          64   (1.9%)     Gem::BasicSpecification#internal_init
       136   (4.0%)          59   (1.7%)     <top (required)>
      2312  (67.7%)          58   (1.7%)     <top (required)>
        57   (1.7%)          57   (1.7%)     RbConfig.expand
        81   (2.4%)          55   (1.6%)     Gem::Requirement.parse
       191   (5.6%)          51   (1.5%)     <top (required)>
       128   (3.7%)          47   (1.4%)     Gem::Requirement#initialize
        41   (1.2%)          41   (1.2%)     Gem.suffix_regexp
       229   (6.7%)          35   (1.0%)     <module:Gem>
       260   (7.6%)          34   (1.0%)     Kernel#require
```

So clearly `Gem.already_loaded?` is a major hotspot.

After this optimization, it's down to:
```
==================================
  Mode: wall(10)
  Samples: 2653 (58.21% miss rate)
  GC: 718 (27.06%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
       416  (15.7%)         416  (15.7%)     (marking)
       715  (27.0%)         312  (11.8%)     Gem::Specification.load
       299  (11.3%)         299  (11.3%)     (sweeping)
       279  (10.5%)         279  (10.5%)     Gem.already_loaded?
       564  (21.3%)         106   (4.0%)     Gem.register_default_spec
        95   (3.6%)          80   (3.0%)     Gem::Specification#files
        72   (2.7%)          72   (2.7%)     Gem::BasicSpecification#internal_init
       129   (4.9%)          58   (2.2%)     <top (required)>
        53   (2.0%)          53   (2.0%)     RbConfig.expand
      1697  (64.0%)          52   (2.0%)     <top (required)>
        68   (2.6%)          49   (1.8%)     Gem::Requirement.parse
       183   (6.9%)          48   (1.8%)     <top (required)>
       112   (4.2%)          44   (1.7%)     Gem::Requirement#initialize
       220   (8.3%)          33   (1.2%)     <module:Gem>
       250   (9.4%)          32   (1.2%)     Kernel#require
```

The idea is that the vast majority of the time `already_loaded?` won't match
anything. So by first looking for candidate paths that `end_with?` the file we
look for, we save `default_gem_load_paths.size` iterations and string concatenations.

c60ce88d49
2020-07-31 21:07:19 +09:00
Hiroshi SHIBATA
832fe77879 Bump version to 3.2.0.rc.1 2020-07-31 21:07:19 +09:00
Bart de Water
734c5276f0 [rubygems/rubygems] Simplify digest name selection and use SHA256
The previous commit introduces the Gem::Security.create_digest method, allowing to:
- decouple algorithm choice from implementation (OpenSSL or Ruby built-in)
- untangle the SHA512 fallback for TarWriter from the generic hashing digest choice (undoing commit 9471f8ed2bdc12248d2619bbbce6e53cd6c16cb6)

1bc03231e4
2020-07-31 21:07:19 +09:00
Bart de Water
8161cf85ba Stop using deprecated OpenSSL::Digest constants 2020-07-31 21:07:19 +09:00
Karol Bucek
e7b6e0ff58 [rubygems/rubygems] remove explicit require(s) for auto-loaded constant(s)
the Gem module's auto-loads will handle loading these as needed,

this started as a redundancy found in *rubygems.rb* which had:
`autoload :Specification, 'rubygems/specification'` as well as
`require 'rubygems/specification'`

43ceae7ac0
2020-07-31 21:07:19 +09:00
Marc-Andre Lafortune
c3b480b776 [rubygems/rubygems] Test files should not be included in spec.files
0c0760b734
2020-07-31 21:07:19 +09:00
David Rodríguez
a89665b7b1 Enforce no empty lines around class body in rubygems
To normalize the code style with `bundler`.
2020-07-31 21:07:19 +09:00
Jeremy Evans
a6bfc951aa Document Array#flatten{,!} accept explicit nil argument [ci skip]
Fixes [Bug #10475]
2020-07-30 12:39:54 -07:00
Aaron Patterson
7533519990
NODE_MATCH needs reference updating 2020-07-30 11:11:13 -07:00
git
b933b43b67 * 2020-07-31 [ci skip] 2020-07-31 00:59:33 +09:00
Nobuyoshi Nakada
47f2c5429b
Added NUL-contained cases 2020-07-31 00:54:34 +09:00
Marc-Andre Lafortune
352895b751 [ruby/racc] Return nil for all syntax errors
51817ce0f6
2020-07-30 10:07:06 -04:00
Marc-Andre Lafortune
1b1ea7b3bc Fix Array#flatten for recursive array when given positive depth [Bug #17092] 2020-07-30 09:53:42 -04:00
Hiroshi SHIBATA
2bd1f827f1
Promote io-nonblock to the default gems. 2020-07-30 21:21:08 +09:00
Hiroshi SHIBATA
d75b42a70a
Promote io-wait to the default gems 2020-07-30 21:10:28 +09:00
Hiroshi SHIBATA
ec1ab1d465
Add explicitly require for Dir.mktmpdir 2020-07-30 21:01:22 +09:00
Nobuyoshi Nakada
b2d96abb42 Extract version number from the source
"requiring version.rb" strategy has some issues.

- cannot work when cross-compiling
- often introduces wrong namespace
- must know the superclasses
- costs at each runtime than at build-time

etc.
2020-07-30 19:03:18 +09:00
Espartaco Palma
cfbae7dae0 [skip-ci] Clarification for dup vs clone docs
Both clone & dup returns a new object when executed
on the documentation looks like they are returning the
same object cloned or dup'ed which is true for method
as extend, but not for the above mentioned.
2020-07-30 18:34:17 +09:00
Jun Aruga
265968d675 Apply timeout-scale to test_nogvl_poll. 2020-07-30 18:28:41 +09:00