Граф коммитов

2337 Коммитов

Автор SHA1 Сообщение Дата
David Rodríguez 6353f1d5e8 [rubygems/rubygems] Fill in missing deployment specs
https://github.com/rubygems/rubygems/commit/e16aa47b8f
2023-06-06 10:52:56 +09:00
David Rodríguez 603772440c [rubygems/rubygems] Remove redundant specs
They are already tested above.

https://github.com/rubygems/rubygems/commit/23073dcece
2023-06-06 10:52:55 +09:00
David Rodríguez 1f9e66836b [rubygems/rubygems] Fix inline mode with multiple sources
If we're in inline mode, Bundler first resolves using only local gems,
and if some gems are missing, then it re-resolves using remote gems.
However, "source resolution" from the initial "local" try was being
memoized, resulting in Bundler not looking for some gems remotely in the
second resolution.

This commit forces a proper re-resolve in this case.

https://github.com/rubygems/rubygems/commit/fdc631075e
2023-06-06 10:52:53 +09:00
Benoit Daloze 957b6a491f rb_io_descriptor() is available since 3.1 2023-06-01 11:41:41 +02:00
Samuel Williams a218ed5692
Hide the usage of `rb_io_t` where possible. (#7880)
This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility.
2023-06-01 14:23:30 +09:00
NARUSE, Yui 85dcc4866d Revert "Hide most of the implementation of `struct rb_io`. (#6511)"
This reverts commit 18e55fc1e1.

fix [Bug #19704]
https://bugs.ruby-lang.org/issues/19704
This breaks compatibility for extension libraries. Such changes
need a discussion.
2023-06-01 08:43:22 +09:00
Hiroshi SHIBATA 3bc5f6b240
[rubygems/rubygems] tool_dir needs to handle ruby/ruby repo now
https://github.com/rubygems/rubygems/commit/550d90f4ba
2023-05-31 13:55:30 +09:00
Hiroshi SHIBATA 4bbeed6134 Merge RubyGems/Bundler master from 4076391fce5847689bf2ec402b17133fe4e32285 2023-05-30 21:50:07 +09:00
Samuel Williams 18e55fc1e1
Hide most of the implementation of `struct rb_io`. (#6511)
* Add rb_io_path and rb_io_open_descriptor.

* Use rb_io_open_descriptor to create PTY objects

* Rename FMODE_PREP -> FMODE_EXTERNAL and expose it

FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but
FMODE_EXTERNAL is clearer about what the file descriptor represents and
aligns with language in the IO::Buffer module.

* Ensure that rb_io_open_descriptor closes the FD if it fails

If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be
responsible for closing your file, eventually, if you pass it to
rb_io_open_descriptor, even if it raises an exception.

* Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P

* Expose `rb_io_closed_p`.

* Add `rb_io_mode` to get IO mode.

---------

Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
2023-05-30 10:02:40 +09:00
Benoit Daloze 99ce41564e Refactor guards for Time.new spec 2023-05-29 18:33:51 +02:00
Peter Zhu b7a26dfa16 Unify error messages of rb_num2ulong and rb_num2ull
The error messages were slightly different due, which causes different
behaviour on 32-bit and 64-bit systems.
2023-05-29 11:55:39 -04:00
Benoit Daloze c48d496e8c Update to ruby/spec@c3677cf 2023-05-29 15:27:57 +02:00
Samuel Williams 6d976eb534
Fix "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" on Windows. (#7848)
* Enable borked spec.

* Ensure win32 wrappers are visible and used.

* Reorganise `read`/`write`/`pipe` in `thread_spec.c`.
2023-05-24 22:45:34 +09:00
Nobuyoshi Nakada d8da563f9e
Add a newline at EOF [ci skip] 2023-05-24 15:04:07 +09:00
Samuel Williams 28056a6d16
Add support for pread/pwrite on windows. (#7827) 2023-05-24 09:15:20 +09:00
Jean byroot Boussier 31ac8efca8
Hash.new: print a deprecation warning when receiving keyword arguments (#7828)
[Feature #19236]

In Ruby 3.3, `Hash.new` shall print a deprecation warning if keyword arguments
are passed instead of treating them as an implicit positional Hash.

This will allow to safely introduce a `capacity` keyword argument in 3.4

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2023-05-23 15:51:28 +02:00
Hiroshi SHIBATA a7d7032100
Manually merge syntax_suggest-1.1.0 2023-05-23 10:05:47 +09:00
schneems c638ffa700
[ruby/syntax_suggest] Fix
https://github.com/ruby/syntax_suggest/pull/187 Handle if/else with
empty/comment
line

Reported in #187 this code:

```
class Foo
  def foo
    if cond?
      foo
    else
      # comment
    end
  end

  # ...

  def bar
    if @recv
    end_is_missing_here
  end
end
```

Triggers an incorrect suggestion:

```
Unmatched keyword, missing `end' ?
   1  class Foo
   2    def foo
>  3      if cond?
>  5      else
   8    end
  16  end
```

Part of the issue is that while scanning we're using newlines to determine when to stop and pause. This is useful for determining logically smaller chunks to evaluate but in this case it causes us to pause before grabbing the "end" that is right below the newline. This problem is similar to https://github.com/ruby/syntax_suggest/pull/179.

However in the case of expanding same indentation "neighbors" I want to always grab all empty values at the end of the scan. I don't want to do that when changing indentation levels as it affects scan results.

There may be some way to normalize this behavior between the two, but the tests really don't like that change.

To fix this issue for expanding against different indentation I needed a way to first try and grab any additional newlines with the ability to rollback that guess. In #192 I experimented with decoupling scanning from the AroundBlockScan logic. It also added the ability to take a snapshot of the current scanner and rollback to prior changes.

With this ability in place now we:

- Grab extra empties before looking at the above/below line for the matching keyword/end statement
- If there's a match, grab it
- If there's no match, discard the newlines we picked up in the evaluation

That solves the issue.

https://github.com/ruby/syntax_suggest/commit/513646b912
2023-05-23 10:05:47 +09:00
schneems aaf815c626
[ruby/syntax_suggest] Refactor Scanner logic out of AroundBlockScan introduce history
AroundBlockScan started as a utility class that was meant to be used as a DSL for scanning and making new blocks. As logic got added to this class it became hard to reason about what exactly is being mutated when. I pulled the scanning logic out into it's own class which gives us a clean separation of concerns. This allowed me to remove a lot of accessors that aren't core to the logic provided by AroundBlockScan.

In addition to this refactor the ScanHistory class can snapshot a scan. This allows us to be more aggressive with scans in the future as we can now snapshot and rollback if it didn't turn out the way we wanted.

The change comes with a minor perf impact:

before: 5.092678   0.104299   5.196977 (  5.226494)
after: 5.128536   0.099871   5.228407 (  5.249542)

This represents a 0.996x change in speed (where 1x would be no change and 2x would be twice as fast). This is a 0.38% decrease in performance which is negligible. It's likely coming from the extra blocks being created while scanning. This is negligible and if the history feature works well we might be able to make better block decisions which is means fewer calls to ripper which is the biggest bottleneck.

While this doesn't fix https://github.com/ruby/syntax_suggest/issues/187 it's a good intermediate step that will hopefully make working on that issue easier.

https://github.com/ruby/syntax_suggest/commit/ad8487d8aa
2023-05-23 10:05:47 +09:00
Ivanov-Anton 1dd5427abe
Fix typo in spec file description [ci skip]
fixed typo for spec description
2023-05-21 09:59:34 +09:00
Samuel Williams 2df5a697e2
Add Fiber#kill, similar to Thread#kill. (#7823) 2023-05-18 23:33:42 +09:00
Martin Dürst 30326844c7 fix wording of spec description [ci skip] 2023-05-13 10:07:00 +09:00
Nobuyoshi Nakada 2d9bc3efe5 [Bug #19597] Freeze script name 2023-05-10 17:14:20 +09:00
Hiroshi SHIBATA 0ef6e718d9
Merge https://github.com/rubygems/rubygems/pull/6655 manually. 2023-05-10 15:02:29 +09:00
Hiroshi SHIBATA 9d3ab15827 Relax regexp for console assertion 2023-05-09 12:57:12 +09:00
Jean Boussier 6339cb70c3 marshal.c: shallow freeze user objects
When `freeze: true` argument is passed.

[Bug #19427]
2023-04-26 16:54:25 +02:00
Benoit Daloze 82995d4615 Update to ruby/spec@7f6ca5b 2023-04-25 17:27:57 +02:00
Benoit Daloze e3d05001ed Workaround CRuby adding x86_64-linux-fake in $LOADED_FEATURES 2023-04-25 17:09:53 +02:00
Benoit Daloze d562663e40 Update to ruby/spec@7f69c86 2023-04-25 17:09:53 +02:00
Benoit Daloze d3da01cd11 Update to ruby/mspec@1d8cf64 2023-04-25 17:09:53 +02:00
schneems 3d5febf65b [ruby/syntax_suggest] Clean up output
I previously left a comment stating I didn't know why a certain method existed. In investigating the code in `CaptureCodeContext#capture_before_after_kws` I found that it was added as to give a slightly less noisy output.

The docs for AroundBlockScan#capture_neighbor_context only describe keywords as being a primary concern. I modified that code to only include lines that are keywords or ends. This reduces the output noise even more.

This allows me to remove that `start_at_next_line` method.

One weird side effect of the prior logic is it would cause this code to produce this output:

```
        class OH
          def hello

          def hai
          end
        end
```

```
          1  class OH
        > 2    def hello
          4    def hai
          5    end
          6  end
```

But this code to produce this output:

```
        class OH
          def hello
          def hai
          end
        end
```

```
          1  class OH
        > 2    def hello
          4    end
          5  end
```
Note the missing `def hai`. The only difference between them is that space.

With this change, they're now both consistent.

https://github.com/ruby/syntax_suggest/commit/4a54767a3e
2023-04-25 14:43:06 +09:00
Hiroshi SHIBATA f77dc6fb16 [ruby/syntax_suggest] standardrb --fix-unsafely spec/spec_helper.rb
https://github.com/ruby/syntax_suggest/commit/6e266b3b2b
2023-04-25 14:43:05 +09:00
Jeremy Evans f8e7048348 Allow anonymous memberless Struct
Previously, named memberless Structs were allowed, but anonymous
memberless Structs were not.

Fixes [Bug #19416]
2023-04-24 07:37:20 -07:00
Nobuyoshi Nakada dafbaabc04
Check the precision of `getrusage` at runtime 2023-04-23 12:01:13 +09:00
Nobuyoshi Nakada c5529aa5fc Fix a guard of `Process.times`
`GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID` clock uses `getrusage`
always if available as the name states.  That is if it is implemented
`getrusage` is available, regardless microseconds in its results.
2023-04-22 21:21:35 +09:00
Nobuyoshi Nakada 4cff7a92b8 Fix an example of `Process.times`
Prior to commit 5806c54447, it was "at
least one result with precision beyond milliseconds (with none-zero
microseconds) should exist"; after this commit, "at least one result
should have zero microseconds".  This chance is lower than the
previous condition.
2023-04-22 21:21:35 +09:00
Nobuyoshi Nakada e956052fa9
Skip when unix socket path is too long
Eventually the path directly under "/tmp" is complained by `rm_r` in
spec/mspec/lib/mspec/helpers/fs.rb.
2023-04-21 22:17:18 +09:00
Hiroshi SHIBATA dbcdac00e6 [rubygems/rubygems] Revert "Bundler::YAMLSerializer.load couldn't raise error when invalid yaml was provided"
This reverts commit https://github.com/rubygems/rubygems/commit/cfcfde04c783.

https://github.com/rubygems/rubygems/commit/ac21ae7083
2023-04-20 01:57:16 +00:00
Nobuyoshi Nakada 7821708c84
Use ASCII-compatible encoding for tests
Since these files are written in a wide character encoding, stop at
first NUL byte and are actually empty.  ASCII-incompatible encodings
have never been supported as source encoding.
2023-04-20 09:57:49 +09:00
Hiroshi SHIBATA 8b95b33a9d [rubygems/rubygems] Bundler::YAMLSerializer.load couldn't raise error when invalid yaml was provided
https://github.com/rubygems/rubygems/commit/cfcfde04c7
2023-04-19 06:56:22 +00:00
Vladimir Dementyev b09f5c7bf7
MatchData#named_captures: add optional symbolize_names keyword (#6952) 2023-04-19 11:19:31 +12:00
Jean Boussier f3979aec76 Add spec for `Warning[:performance]`
[Feature #19538]
2023-04-17 10:29:46 +02:00
Jean Boussier 52449b5b75 Implement ObjectSpace::WeakMap#delete and ObjectSpace::WeakKeyMap#delete
[Feature #19561]

It's useful to be able to remove references from weak maps.
2023-04-15 16:29:46 +02:00
git 9a1c737dee * append newline at EOF. [ci skip] 2023-04-15 00:10:49 +00:00
Jean Boussier a1db5ecd93 Add specs for ObjectSpace::WeakKeyMap
[Feature #18498]
2023-04-15 02:10:38 +02:00
Jean Boussier 6c1b604e29 Revert "Add specs for ObjectSpace::WeakKeyMap"
This reverts commit fce8f9f24e.
2023-04-14 10:07:33 +02:00
Jean Boussier fce8f9f24e Add specs for ObjectSpace::WeakKeyMap
[Feature #18498]
2023-04-14 09:57:04 +02:00
Nobuyoshi Nakada 60f22ebf86 [Bug #19533] Add spec of infinite range inclusion 2023-04-14 10:22:09 +09:00
Hiroshi SHIBATA 0196c8527b
Removed file that is part of d89cc317c6 2023-04-11 19:15:25 +09:00
David Rodríguez 4df7c3946a [rubygems/rubygems] Remove one fallback to full indexes on big gemfiles
If Gemfile has a lot of dependencies, we have an optimization that uses
the full index in that case, assuming it's going to be faster.

I think this is an old optimization that predates compact index API
times, I believe we no longer need it these days.

Also, since a few releases ago we check for circular dependencies when
resolving by looping through all versions of each name and removing
those that have circular dependencies that would trip up the resolver.

This loop becomes actually very slow when full indexes are used because
to find dependencies of a gemspec, we need to explicitly fetch the
marshaled gemspec (`gemspec.rz` endpoint) for it, so the optimization
has the opposite effect of making things very slow.

https://github.com/rubygems/rubygems/commit/2f46289bd3
2023-04-07 13:53:00 +00:00
Nobuyoshi Nakada e13575bb79
[Bug #19584] Register global variables before assignment 2023-04-07 11:53:36 +09:00
Hiroshi SHIBATA 6ca1f3eec4
Load only SyntaxSuggest::VERSION for version check 2023-04-06 16:15:41 +09:00
schneems 7ab640d9dd
v1.0.4 2023-04-06 15:49:26 +09:00
schneems 8d72d6159c
v1.0.3
Fix a CI error and add a test to ensure we're testing the current version:

```
Run bundle exec rake test
bundler: failed to load command: rake (/home/runner/work/syntax_suggest/syntax_suggest/vendor/bundle/ruby/3.2.0/bin/rake)
/opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:309:in `check_for_activated_spec!': You have already activated syntax_suggest 1.0.2, but your Gemfile requires syntax_suggest 1.0.3. Since syntax_suggest is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports syntax_suggest as a default gem. (Gem::LoadError)
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:25:in `block in setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `map'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler.rb:151:in `setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `block in <top (required)>'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:136:in `with_level'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:88:in `silence'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `<top (required)>'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `require_relative'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `kernel_load'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:23:in `run'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli.rb:483:in `exec'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
```
2023-04-06 15:47:04 +09:00
schneems 63ea6b0cf2 [ruby/syntax_suggest] Rollback comment indentation behavior
Originally I fixed https://github.com/ruby/syntax_suggest/pull/177 by making the process of comment removal indentation aware. The next commit is the more general fix and means we don't need to carry that additional logic/overhead.

Also: Update syntax via linter
2023-04-06 15:45:29 +09:00
schneems 2acbcec056 [ruby/syntax_suggest] Add comments and refactor AroundBlockScan methods
https://github.com/ruby/syntax_suggest/commit/cecd12292c
2023-04-06 15:45:29 +09:00
schneems 5487ee4fe8 [ruby/syntax_suggest] Fix sibling bug to #177
While #177 is reported as being caused by a comment, the underlying behavior is a problem due to the newline that we generated (from a comment). The prior commit fixed that problem by preserving whitespace before the comment. That guarantees that a block will form there from the frontier before it will be expanded there via a "neighbors" method. Since empty lines are valid ruby code, it will be hidden and be safe.

## Problem setup

This failure mode is not fixed by the prior commit, because the indentation is 0. To provide good results, we must make the algorithm less greedy. One heuristic/signal to follow is developer added newlines. If a developer puts a newline between code, it's more likely they're unrelated. For example:

```
port = rand(1000...9999)
stub_request(:any, "localhost:#{port}")

query = Cutlass::FunctionQuery.new(
  port: port
).call

expect(WebMock).to have_requested(:post, "localhost:#{port}").
  with(body: "{}")
```

This code is split into three chunks by the developer. Each are likely (but not guaranteed) to be intended to stand on their own (in terms of syntax). This behavior is good for scanning neighbors (same indent or higher) within a method, but bad for parsing neighbors across methods.

## Problem

Code is expanded to capture all neighbors, and then it decreases indent level which allows it to capture surrounding scope (think moving from within the method to also capturing the `def/end` definition. Once the indentation level has been increased, we go back to scanning neighbors, but now neighbors also contain keywords.

For example:

```
  1 def bark
  2
  3 end
  4
  5 def sit
  6 end
```

In this case if lines 4, 5, and 6 are in a block when it tries to expand neighbors it will expand up. If it stops after line 2 or 3 it may cause problems since there's a valid kw/end pair, but the block will be checked without it.

TLDR; It's good to stop scanning code after hitting a newline when you're in a method...it causes a problem scanning code between methods when everything inside of one of the methods is an empty line.

In this case it grabs the end on line 3 and since the problem was an extra end, the program now compiles correctly. It incorrectly assumes that the block it captured was causing the problem.

## Extra bit of context

One other technical detail is that after we've decided to stop scanning code for a new neighbor block expansion, we look around the block and grab any empty newlines. Basically adding empty newlines before of after a code block do not affect the parsing of that block.

## The fix

Since we know that this problem only happens when there's a newline inside of a method and we know this particular failure mode is due to having an invalid block (capturing an extra end, but not it's keyword) we have all the metadata we need to detect this scenario and correct it.

We know that the next line above our block must be code or empty (since we grabbed extra newlines). Same for code below it. We can count all the keywords and ends in the block. If they are balanced, it's likely (but not guaranteed) we formed the block correctly. If they're imbalanced, look above or below (depending on the nature of the imbalance), check to see if adding that line would balance the count.

This concept of balance and "leaning" comes from work in https://github.com/ruby/syntax_suggest/pull/152 and has proven useful, but not been formally introduced into the main branch.

## Outcome

Adding this extra check introduced no regressions and fixed the test case. It might be possible there's a mirror or similar problem that we're not handling. That will come out in time. It might also be possible that this causes a worse case in some code not under test. That too would come out in time.

One other possible concern to adding logic in this area (which is a hot codepath), is performance. This extra count check will be performed for every block. In general the two most helpful performance strategies I've found are reducing total number of blocks (therefore reducing overall N internal iterations) and making better matches (the parser to determine if a close block is valid or not is a major bottleneck. If we can split valid code into valid blocks, then it's only evaluated by the parser once, where as invalid code must be continuously re-checked by the parser until it becomes valid, or is determined to be the cause of the core problem.

This extra logic should very rarely result in a change, but when it does it should tend to produce slightly larger blocks (by one line) and more accurate blocks.

Informally it seems to have no impact on performance:

``
This branch:
DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures  3.01s user 1.62s system 113% cpu 4.076 total
```

```
On main:
DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures  3.02s user 1.64s system 113% cpu 4.098 total
```

https://github.com/ruby/syntax_suggest/commit/13739c6946
2023-04-06 15:45:28 +09:00
schneems e5236471c3 [ruby/syntax_suggest] Preserve whitespace in front of comments
When removing comments I previously replaced them with a newline. This loses some context and may affect the order of the indent search which in turn affects the final result. By preserving whitespace in front of the comment, we preserve the "natural" indentation order of the line while also allowing the parser/lexer to see and join naturally consecutive (method chain) lines.

close https://github.com/ruby/syntax_suggest/pull/177
2023-04-06 15:45:28 +09:00
David Rodríguez f3d69bed62
[rubygems/rubygems] Fix resolver hangs when dealing with an incomplete lockfile
While working on locking multiple platforms by default, I got an
infinite resolution loop in one of our resolver specs.

The culprit ended up being that when dealing with lockfile specs with
incomplete dependencies (spec appears in lockfile, but its dependencies
don't), those specs were not being properly expired and that tripped up
resolution.

The issue for some reason only manifests when dealing with multiple
lockfile platforms, that's why it only manifested when working on
locking multiple platforms by default.

https://github.com/rubygems/rubygems/commit/4ca72913bb
2023-04-06 13:07:16 +09:00
Aaron Patterson 8525603c72
Revert "Fix transient heap mode"
This reverts commit 87253d047c.

Revert "Implement `Process.warmup`"

This reverts commit ba6ccd8714.
2023-04-04 12:59:14 -07:00
Jean Boussier ba6ccd8714 Implement `Process.warmup`
[Feature #18885]

For now, the optimizations performed are:

  - Run a major GC
  - Compact the heap
  - Promote all surviving objects to oldgen

Other optimizations may follow.
2023-04-04 19:49:08 +02:00
Josef Šimánek 9cfd8330ca [rubygems/rubygems] Onboard Rubocop Naming/MemoizedInstanceVariableName rule to Bundler.
https://github.com/rubygems/rubygems/commit/d768be0c65
2023-03-28 15:25:44 +09:00
David Rodríguez 4d4743f7e3 [rubygems/rubygems] Fix installing plugins in frozen mode
Plugins don't use a lockfile, so ignore frozen related settings.

https://github.com/rubygems/rubygems/commit/f17a3bb81f
2023-03-28 15:25:42 +09:00
David Rodríguez 674c960513 [rubygems/rubygems] Fix incorrect removal of "ruby" platform from lockfile
When dependencies have changed, we'll be re-resolving, and we can't
really know whether the resolution will be valid or invalid for the Ruby
platform, so skip the removal in that case.

The fix worked, but made some other specs fail, and surfaced that the
`@dependencies_changed` attribute was actually being incorrect set when
explicitly unlocking. Fixed that with an early return.

https://github.com/rubygems/rubygems/commit/20d8f5e5d9
2023-03-28 15:25:42 +09:00
David Rodríguez ed868f9a71 [rubygems/rubygems] Fix unnecessary downgrade of top level dependency when unlocking
Bundler is very conservative by default, trying to preserve versions
from the lockfile as possible, and never downgrading them. However, when
it runs into a resolution error, it still tries to find a valid
resolution.

This fallback behavior was too "brute-force" though, completely
unrestricting any gem found in the resolution conflict, and that could
lead to direct dependencies being downgraded in some edge cases.

Instead, unlock things a bit more carefully:

* First try unlocking fully pinned indirect dependencies, but leave a
  lower bound requirement in place to prevent downgrades.
* Then try unlocking any fully pinned dependency, also leaving a lower
  bound requirement in place.
* Finally completely unrestrict dependencies if nothing else worked.

https://github.com/rubygems/rubygems/commit/7f55ed8302
2023-03-28 15:25:41 +09:00
Michael Siegfried b31bd8b853 [rubygems/rubygems] Rewrite GemVersionPromoter specs
Add tests for pre, move more of the setup into a helper method, and
restructure tests.

There seem to be five considerations for these tests (level, pre, strict,
locked, and whether the current version is a prerelease version, though
the last one overlaps with pre and didn't seem to behave how I expected
under test). Rather than write out the 16 (/32 if the last consideration
is real) combinations, I wrote most with independent tests for each
value. The existing combined tests were maintained (level vs strict)
because these seem the most interrelated.

https://github.com/rubygems/rubygems/commit/74c23a91b2
2023-03-28 01:18:49 +00:00
Jeremy Evans 6c60006de5 Raise ArgumentError if IO.read is provided negative offset
Fixes [Bug #19380]
2023-03-24 12:29:00 -07:00
Jeremy Evans 466ca7ae20 Add Dir.fchdir
This is useful for passing directory file descriptors over UNIX
sockets or to child processes to avoid TOCTOU vulnerabilities.

The implementation follows the Dir.chdir code.

This will raise NotImplementedError on platforms not supporting
both fchdir and dirfd.

Implements [Feature #19347]
2023-03-24 11:18:57 -07:00
Jeremy Evans 5d6579bd91 Change Hash#compact to keep default values and compare_by_identity flag
The documentation states it returns a copy of self with nil value
entries removed.  However, the previous behavior was creating a
plain new hash with non-nil values copied into it.  This change
aligns the behavior with the documentation.

Fixes [Bug #19113]
2023-03-24 10:55:13 -07:00
Jeremy Evans 1b13db25d8 Copy compare_by_identity flag for empty hashes in Hash.ruby2_keywords_hash
This was already copied for non-empty hashes.  As Hash.ruby2_keywords_hash
copies default values, it should also copy the compare_by_identity flag.

Partially Fixes [Bug #19113]
2023-03-24 10:55:13 -07:00
Jeremy Evans d3197def88 Do not copy compare_by_identity flag for non-empty hashes in Hash.[]
It wasn't copied for empty hashes, and Hash.[] doesn't copy the
default value, so copying the compare_by_identity flag does not
make sense.

Partially Fixes [Bug #19113]
2023-03-24 10:55:13 -07:00
David Rodríguez a9146bd81e Don't suggest `--full-index` on API Response mismatch errors
I've never seen this error in real life, and if it was happening, I
think it's either some server side issue that would need to be fixed or
some transient issue. We should move away from the full index, since
it's slow, so let's stop recommending it.
2023-03-23 17:18:49 +09:00
David Rodríguez 164dc58008 Fix logging the fallback to the full index on GemspecError's
The debug message suggests retrying using `--full-index`, but the retry
is happening automatically. Just log that we are falling back to the
full index, like we do with other errors.
2023-03-23 17:18:49 +09:00
David Rodríguez 8e6bbc032c Don't remove RUBY platform when healing a lockfile with missing specs 2023-03-23 17:18:49 +09:00
David Rodríguez 4e7c39f98c Don't remove RUBY platform when healing a lockfile with missing specs 2023-03-23 17:18:49 +09:00
Nobuyoshi Nakada 348412c7fa [rubygems/rubygems] Use indented heredoc
https://github.com/rubygems/rubygems/commit/085d2776d8
2023-03-22 21:21:08 +00:00
Hiroshi SHIBATA 8d1109c03b
Added assertion values for Amazon Linux 2023 2023-03-22 16:10:06 +09:00
David Rodríguez c65d7b4bea When running `bundle lock --update <name>`, checkout locked revision of unrelated git sources directly
Since Bundler 2.4, we will try to checkout any branch specified in the
Gemfile, while until Bundler 2.3 we would directly checkout the locked
revision.

This should not make any difference in most situations, but in some edge
cases, like if the branch specified in the `Gemfile` has been renamed,
but the locked revision still exist, it causes an error now while before
it would update the lockfile without issues.

I debated which behavior was best, since I was not sure. But my
conclusion is that if the situation does not require expiring the
lockfile source in favor of the Gemfile source, we should use the locked
revision directly and proceed happily. So I restored Bundler 2.3
behavior.

I think this is consistent with how yanked gems are handled, for example.

Of course, if explicitly updating the git source itself, or all gems, we
will still get any errors like missing branches related to the git source.
2023-03-17 18:50:55 +09:00
David Rodríguez 0b9e51c429 Don´t consider platform specific candidates when `force_ruby_platform` set
This was working fine for direct dependencies using
`force_ruby_platform` explicitly through Gemfile, but not for indirect
dependencies. In general, indirect dependencies do not have this
property set, but in truffleruby this is different and the default value
is to have it set.
2023-03-17 18:50:55 +09:00
David Rodríguez 12f0be14e2 Don't ignore pre-releases when there's only one candidate
This should be a very rare edge case, however, it does happen when using
a .dev version of Bundler because in that case, that's the only version
that the resolver considers, and it should not be ignored.

We could've special cased this specifically for Bundler, but I think it
does make sense for every gem.
2023-03-17 18:50:55 +09:00
David Rodríguez ddc4fd5644 Normalize git sources
Just like gem sources, a "style-only" change, like adding a trailing
slash, should not expire them.
2023-03-17 18:50:55 +09:00
David Rodríguez 8371c0eac4 [rubygems/rubygems] Fix incorrect error message when multiple platforms are locked
https://github.com/rubygems/rubygems/commit/24d2bf9cb2
2023-03-17 18:50:55 +09:00
David Rodríguez d5121992dc [rubygems/rubygems] Remove unnecessary `specific_local_platform` test helper
https://github.com/rubygems/rubygems/commit/86b574824d
2023-03-17 18:50:55 +09:00
David Rodríguez 2d8b55fcd2 [rubygems/rubygems] Simplify `lockfile_platforms` helper
To make it easier to change the default platforms that get locked later.

https://github.com/rubygems/rubygems/commit/255c4012ec
2023-03-17 18:50:55 +09:00
David Rodríguez 9492efbe71 [rubygems/rubygems] Remove unnecessary `local` helper
https://github.com/rubygems/rubygems/commit/27ed6870ce
2023-03-17 18:50:55 +09:00
David Rodríguez 8a8ade7e5e [rubygems/rubygems] Use more common linux platform for specs
https://github.com/rubygems/rubygems/commit/3841a58095
2023-03-17 18:50:55 +09:00
David Rodríguez f22765f535 [rubygems/rubygems] Use splatted args to `lockfile_platforms_for`
Nicer :)

https://github.com/rubygems/rubygems/commit/c0ab2893c3
2023-03-17 18:50:55 +09:00
Hiroshi SHIBATA f3b129241c [rubygems/rubygems] Applied Layout/SpaceAroundOperators cop
https://github.com/rubygems/rubygems/commit/3139587be9
2023-03-16 01:59:12 +00:00
Hiroshi SHIBATA 56b38fdd69 [rubygems/rubygems] Use OpenSSL::Digest instead of digest stdlib
https://github.com/rubygems/rubygems/commit/69aa007679
2023-03-15 11:21:22 +00:00
Jean Boussier ca437aeb39 rb_ary_sum: don't enter fast path if initial isn't a native numeric type.
[Bug #19530]

If the initial value isn't one of the special cased types, we directly
jump to the slow path.
2023-03-15 09:12:59 +00:00
Ian Ker-Seymer dd47ce10db [rubygems/rubygems] Use `RbSys::ExtensionTask` when creating new rust gems
https://github.com/rubygems/rubygems/commit/125f9fece9
2023-03-10 11:50:06 +00:00
Samuel Williams 86d38b4520
Accept `sleep(nil)` as sleep forever. (#7484) 2023-03-10 16:40:05 +13:00
Nobuyoshi Nakada dc1e6573f2
Fix commit miss 2023-03-09 00:49:11 +09:00
Nobuyoshi Nakada 611a64250a
Disable color mode of test-syntax-suggest when on dumb terminal
The compliation-mode of Emacs sets TERM to "dumb" and does not support
coloring.
2023-03-08 22:57:06 +09:00
Julie Haehn c5296d9396 [rubygems/rubygems] Respect --no-install option for git: sources
Currently, the --no-install option to `bundle package` is totally
ignored for git sources. This can have very strange effects if you have:

- a git-sourced gem,
- with native extensions,
- whose extconf.rb script depends on another gem,
- which is installed from Rubygems in the gemfile.

In that circumstance, `bundle package --no-install --all` will download
the Rubygems dependencies to `vendor/cache` but NOT install them. It
will also check out the git gems to `vendor/cache` (good), and attempt
to build their native extensions (bad!).

The native extension build will fail because the extconf.rb script crashes,
since the dependency it needs is missing.

I implemented a fix for this in `source/git.rb`, since this is analogous
to what's happening in `source/rubygems.rb`. I do admit though the whole
thing is a little strange though - an "install" method that.... proceeds
to look at a global flag to not install anything.

Add test to confirm cache respects the --no-install flag

https://github.com/rubygems/rubygems/commit/5a77d1c397

Co-authored-by: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
2023-03-07 22:36:36 +00:00
David Rodríguez 72591eb73f [rubygems/rubygems] Better suggestion when `bundler/setup` fails due to missing gems
If the original `BUNDLE_GEMFILE` is different from the default, then the
suggestion wouldn't work as is.

Before:

```
$ util/rubocop
Could not find rubocop-1.30.1 in locally installed gems
Run `bundle install` to install missing gems.

$  rubygems git:(better-cmd-suggestion) ✗ bundle install
Could not locate Gemfile
```

After:

```
$ util/rubocop
Could not find rubocop-1.30.1 in locally installed gems
Run `bundle install --gemfile /path/to/rubygems/bundler/tool/bundler/lint_gems.rb` to install missing gems.

$ bundle install --gemfile /path/to/rubygems/bundler/tool/bundler/lint_gems.rb
Fetching gem metadata from https://rubygems.org/.........
Using ast 2.4.2
Using bundler 2.4.7
Using parser 3.1.2.0
Using rainbow 3.1.1
Using parallel 1.22.1
Using regexp_parser 2.5.0
Using rubocop-ast 1.18.0
Using rexml 3.2.5
Using ruby-progressbar 1.11.0
Using unicode-display_width 2.1.0
Fetching rubocop 1.30.1
Installing rubocop 1.30.1
Using rubocop-performance 1.14.2
Bundle complete! 2 Gemfile dependencies, 12 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

$ util/rubocop
Inspecting 345 files
.........................................................................................................................................................................................................................................................................................................................................................

345 files inspected, no offenses detected
```

https://github.com/rubygems/rubygems/commit/bf1320d805
2023-03-07 16:51:36 +09:00
Takashi Kokubun 23ec248e48 s/mjit/rjit/ 2023-03-06 23:44:01 -08:00
Takashi Kokubun 2e875549a9 s/MJIT/RJIT/ 2023-03-06 23:44:01 -08:00
johnnyshields 79ede4ae99 [rubygems/rubygems] Alias CurrentRuby#mswin?, mswin64?, mingw?, x64_mingw? to #windows?. (This is done instead of logging a deprecation warning.)
https://github.com/rubygems/rubygems/commit/b9fcc7c0ab
2023-03-03 09:50:29 +00:00
Tony Hsu 5f3c7ac196 [rubygems/rubygems] Replace lockfile with `.locked`
https://github.com/rubygems/rubygems/commit/203f3e3802
2023-03-02 14:43:27 +00:00
Ellen Marie Dash d2d521b274 [rubygems/rubygems] Regenerate lockfile if spec list is invalid/empty.
https://github.com/rubygems/rubygems/commit/d2c56315e2
2023-03-02 00:50:58 +00:00
Daniel Colson 62b3bcba5e [rubygems/rubygems] Auto-heal on corrupted lockfile with missing deps
Following up on https://github.com/rubygems/rubygems/pull/6355, which
turned a crash into a nicer error message, this commit auto-heals the
corrupt lockfile instead.

In this particular case (a corrupt Gemfile.lock with missing
dependencies) the LazySpecification will not have accurate dependency
information, we have to materialize the SpecSet to determine there are
missing dependencies. We've already got a way to handle this, via
`SpecSet#incomplete_specs`, but it wasn't quite working for this case
because we'd get to `@incomplete_specs += lookup[name]` and
`lookup[name]` would be empty for the dependency.

With this commit we catch it a bit earlier, marking the parent spec
containing the missing dependency as incomplete.

https://github.com/rubygems/rubygems/commit/486ecb8f20
2023-03-01 02:50:40 +00:00
Takashi Kokubun 283c71eeff Skip a spec failing on master
https://github.com/ruby/ruby/actions/runs/4286361460/jobs/7466545010
http://ci.rvm.jp/results/trunk_gcc9@ruby-sp2-docker/4462424
http://ci.rvm.jp/results/trunk_clang_13@ruby-sp2-docker/4462422
2023-02-27 12:53:04 -08:00
Benoit Daloze 18b4def471 Update to ruby/spec@e7dc804 2023-02-27 21:02:44 +01:00
Benoit Daloze de60139053 Update to ruby/mspec@dc2eb26 2023-02-27 21:02:42 +01:00
Samuel Williams f94e83faa0
Assigning `nil` to fiber storage deletes the association. (#7378)
Also avoid allocations when looking up `Fiber#storage` if not needed.
2023-02-25 19:27:11 +13:00
Mercedes Bernard 9406245dbc [rubygems/rubygems] lint fix again
https://github.com/rubygems/rubygems/commit/118d28ad27
2023-02-23 08:50:06 +00:00
Mercedes Bernard 3d766122c8 [rubygems/rubygems] lint fix
https://github.com/rubygems/rubygems/commit/de3b69f1a7
2023-02-23 08:50:05 +00:00
Mercedes Bernard 10a393c25d [rubygems/rubygems] add safe_load_marshal for gem::version and gem::spec
https://github.com/rubygems/rubygems/commit/2ea2ead1b3
2023-02-23 08:50:05 +00:00
Mercedes Bernard e965133f56 [rubygems/rubygems] test Bundler::Fetcher that error raised when attempting load unexpected class
https://github.com/rubygems/rubygems/commit/795e796a9e
2023-02-23 08:50:04 +00:00
Mercedes Bernard 68995c21be [rubygems/rubygems] test rubygems_integration that error raised when attempting load unexpected class
https://github.com/rubygems/rubygems/commit/9798718b3b
2023-02-23 08:50:04 +00:00
Mercedes Bernard ffc202738b [rubygems/rubygems] add test for private load_marshal method
https://github.com/rubygems/rubygems/commit/3a772125b8
2023-02-23 08:50:03 +00:00
Mercedes Bernard 583137fe56 [rubygems/rubygems] make Bundler.load_marshal private
https://github.com/rubygems/rubygems/commit/4909d071d2
2023-02-23 08:50:03 +00:00
Nobuyoshi Nakada a26a0af074
Use `BigDecimal::VERSION` instead of `RUBY_VERSION` 2023-02-22 00:39:56 +09:00
Jean Boussier d2520b7b76 Marshal.load: restore instance variables on Regexp
[Bug #19439]

The instance variables were restore on the Regexp source,
not the regexp itself.

Unfortunately we have a bit of a chicken and egg problem.

The source holds the encoding, and the encoding need to be set on
the source to be able to instantiate the Regexp.

So the instance variables have to be read on the `source`.
To correct this we transfert the instance variables after
instantiating the Regexp.

The only way to avoid this would be to read the instance variable
twice and rewind.
2023-02-21 13:57:04 +01:00
Hiroshi SHIBATA 38fa8eb4cb Merge rubygems/bundler master
Pick from e9304aed7e
2023-02-21 19:28:12 +09:00
David Rodríguez a47e1328e6 [rubygems/rubygems] Give a better message when Gemfile branch does not exist
https://github.com/rubygems/rubygems/commit/cb4fc41cbc
2023-02-21 19:28:12 +09:00
David Rodríguez b5eb9ebd5d [rubygems/rubygems] Fix crash in pub grub involving empty ranges
https://github.com/rubygems/rubygems/commit/0f168516f7
2023-02-21 19:28:12 +09:00
John Hawthorn 4064e3e776 [rubygems/rubygems] Update pub_grub
* Replaces the wording of "is forbidden" with "cannot be used"
* Fixes the method signature of VersionRange::Empty#eql?

https://github.com/rubygems/rubygems/commit/8c6b3f130b

Co-authored-by: Daniel Colson <danieljamescolson@gmail.com>
2023-02-21 19:28:12 +09:00
David Rodríguez 8038991583 [rubygems/rubygems] Sync with pub_grub main branch
We became a bit out of sync lately.

https://github.com/rubygems/rubygems/commit/6161a2610a
2023-02-21 19:28:12 +09:00
David Rodríguez e7bf85961d [rubygems/rubygems] Restore better error message when locked ref does not exist
https://github.com/rubygems/rubygems/commit/c8e024359f
2023-02-21 19:28:12 +09:00
Yusuke Endoh 0e830e6373 Update some ruby specs for the new message format of NoMethodError 2023-02-20 10:33:06 +09:00
Takashi Kokubun 0d8ef62fc2 BigDecimal changed #remainder's spec
This test is no longer passing:
```
  1)
  BigDecimal#remainder returns NaN if Infinity is involved FAILED
  Expected Infinity.nan?
  to be truthy but was false
  /home/runner/work/ruby/ruby/src/spec/ruby/library/bigdecimal/remainder_spec.rb:58:in `block (2 levels) in <top (required)>'
  /home/runner/work/ruby/ruby/src/spec/ruby/library/bigdecimal/remainder_spec.rb:4:in `<top (required)>'
```

https://github.com/ruby/bigdecimal/pull/243
2023-02-17 10:53:08 -08:00
Jean Boussier 7ddcee5928 Marshal.load: also freeze extended objects
[Bug #19427]

The `proc` wouldn't be called either, that fixes both.
2023-02-13 17:08:21 +01:00
Takashi Kokubun 6517d1a188
[DOC] Move old ChangeLog files to doc/ChangeLog (#7293) 2023-02-10 16:57:56 -08:00
Daniel Colson 8edd350bda [rubygems/rubygems] Avoid crashing with a corrupted lockfile
I did a bad thing (script that edits the Gemfile.lock directly) and
ended up with a Gemfile.lock that was completely missing some indirect
dependencies. While this is my fault and an error is reasonable, I
noticed that the error got progressively less friendly in recent
versions of bundler.

Something similar came up in https://github.com/rubygems/rubygems/issues/6210,
and this commit would have helped with that case as well
(although we've already handled this a different way with #6219).

Details:
---

Back on Bundler 2.2.23, a corrupt lockfile like this would cause a helpful error:

```
Unable to find a spec satisfying minitest (>= 5.1) in the set. Perhaps the lockfile is corrupted?
```

Bundler 2.3.26 gave a helpful warning:

```
Warning:
Your lockfile was created by an old Bundler that left some things out.
Because of the missing DEPENDENCIES, we can only install gems one at a time,
instead of installing 16 at a time.
You can fix this by adding the missing gems to your Gemfile, running bundle
install, and then removing the gems from your Gemfile.
The missing gems are:
* minitest depended upon by activesupport
```

But then continued on and crashed while trying to report the unmet
dependency:

```
--- ERROR REPORT TEMPLATE -------------------------------------------------------

NoMethodError: undefined method `full_name' for nil:NilClass
lib/bundler/installer/parallel_installer.rb:127:in `block (2 levels) in check_for_unmet_dependencies'

...
```

Bundler 2.4.0 and up crash as above when jobs=1, but crash
even harder when run in parallel:

```
--- ERROR REPORT TEMPLATE -------------------------------------------------------

fatal: No live threads left. Deadlock?
3 threads, 3 sleeps current:0x00007fa6b6704660 main thread:0x00007fa6b6704660
* #<Thread:0x000000010833b130 sleep_forever>
   rb_thread_t:0x00007fa6b6704660 native:0x0000000108985600 int:0

* #<Thread:0x0000000108dea630@Parallel Installer Worker #0 tmp/1/gems/system/gems/bundler-2.5.0.dev/lib/bundler/worker.rb:90 sleep_forever>
   rb_thread_t:0x00007fa6b67f67c0 native:0x0000700009a62000 int:0

* #<Thread:0x0000000108dea4a0@Parallel Installer Worker #1 tmp/1/gems/system/gems/bundler-2.5.0.dev/lib/bundler/worker.rb:90 sleep_forever>
   rb_thread_t:0x00007fa6b67f63c0 native:0x0000700009c65000 int:0

<internal:thread_sync>:18:in `pop'
tmp/1/gems/system/gems/bundler-2.5.0.dev/lib/bundler/worker.rb:42:in `deq'

...
```

Changes
---

This commit fixes the confusing thread deadlock crash by detecting if
dependencies are missing such that we'll never be able to enqueue. When
that happens we treat it as a failure so the install can finish.

That gets us back to the `NoMethodError`, which this commit fixes by
using a different warning in the case where no spec is found.

https://github.com/rubygems/rubygems/commit/d73001a21d
2023-02-09 10:29:50 +00:00
Daniel Colson 728d2f808e [rubygems/rubygems] Improve wording of unmet dependencies warning
`trying to manually editing` doesn't seem quite grammatically
correct. We could change it to `trying to manually edit` (is that a
split infinitive?), but I don't think `trying to` adds much here so
I've removed it instead so `editing` is the verb.

For the list of dependencies, the wording before this commit seemed to
reverse the dependency. "B, depended on A" sounds like B depends on A
(or did in the past but doesn't anymore?), but that's not correct. I
think there's a missing word: "B, depended on by A", but I find "B,
dependency of A" a bit nicer.

https://github.com/rubygems/rubygems/commit/49a31257e3
2023-02-08 22:20:24 +00:00
Jean Boussier 3a0f6ce1d3 Use Thread.pass until thread.stop? to wait for thread to block
[Bug #19415]

It should be more reliable
2023-02-08 11:52:59 +01:00
Jean byroot Boussier 8ce2fb9bbb Only emit circular dependency warning for owned thread shields
[Bug #19415]

If multiple threads attemps to load the same file concurrently
it's not a circular dependency issue.

So we check that the existing ThreadShield is owner by the current
fiber before warning about circular dependencies.
2023-02-08 09:50:00 +01:00
Daniel Colson fd71a76f55 [rubygems/rubygems] Add Ruby 3.2 and 3.3 platforms to Gemfile DSL
Along the same lines as https://github.com/rubygems/rubygems/pull/5469,
this adds support for Ruby 3.2 and 3.3 platforms: `:ruby_32`, `mri_32`,
etc.

It also includes a spec that should help catch this earlier in the
future, failing if we don't support platforms for the version of Ruby
that is running the tests.

https://github.com/rubygems/rubygems/commit/7cd19d824d
2023-02-07 21:12:18 +00:00
Jean byroot Boussier c19defd026 Revert "Only emit circular dependency warning for owned thread shields"
This reverts commit fa49651e05.
2023-02-06 23:30:35 +01:00
Jean Boussier fa49651e05 Only emit circular dependency warning for owned thread shields
[Bug #19415]

If multiple threads attemps to load the same file concurrently
it's not a circular dependency issue.

So we check that the existing ThreadShield is owner by the current
fiber before warning about circular dependencies.
2023-02-06 19:35:38 +01:00
Akira Matsuda 77bec15c93 [rubygems/rubygems] Properly load the generated gemspec
The previous code loads bundler's gemspec which does not include the generated
gemspec file, and thus the test was passing where it should indeed fail.
With this change, the test properly fails now.

https://github.com/rubygems/rubygems/commit/2098ea0d75
2023-02-06 16:19:46 +00:00
Hiroshi SHIBATA d3822c9a8a Merge RubyGems/Bundler master.
Pick from 5ace20dbec
2023-01-31 10:49:08 +09:00
Mike Dalessio 927141a555 [rubygems/rubygems] Add test for old lockfile with new ruby version
Given an existing application using native gems (e.g., nokogiri)
And a lockfile generated with a stable ruby version
When we test the application against ruby-head and `bundle install`
Then bundler should fall back to the generic ruby platform gem

Note that this test has been passing since 45931ac9

https://github.com/rubygems/rubygems/commit/0ecc6de378
2023-01-31 10:49:08 +09:00
Tim Bates 369ed03cd4 [rubygems/rubygems] Fix issue with extensions not compiling properly using inline gemfile
https://github.com/rubygems/rubygems/commit/fa6e6ea95c
2023-01-31 10:49:08 +09:00
Daniel Colson 8429134d0d [rubygems/rubygems] Don't warn on bundler binstubs --standalone --all
Prior to this commit `bundle binstubs --standalone --all` would output a
warning about not being able to generate a standalone binstub for
bundler.

This warning predates the `--all` option, and I don't think it makes
sense in this context. The warning makes good sense when explicitly
trying to generate a bundler standalone binstub with `bundle binstubs
bundler --standalone`, since that command won't do what the user might
have expected. But `--all` is not specifically asking for bundler, and
having it report each time that the bundler binstubs could not be
generated does not seem particularly helpful. The only way to make that
warning go away would be to stop using `--standalone --all`.

This commit skips the warning when running with the `--all` option.

https://github.com/rubygems/rubygems/commit/e6a72e19eb
2023-01-27 21:06:39 +00:00
Hiroshi SHIBATA 545ade21a2 Enable code-coverage result for test-spec 2023-01-26 15:32:29 +09:00
Hiroshi SHIBATA 6608d47bed Enable code-coverage result for test-syntax-suggest 2023-01-26 13:52:20 +09:00
Nobuyoshi Nakada 5a73e131d7 Add tests for variables in `END` block shared with the toplevel 2023-01-24 16:36:33 +09:00
Hiroshi SHIBATA 5abb2ef153
blade is hosted under ruby-lang.org now 2023-01-23 13:07:29 +09:00
Samuel Williams f5ea43a2e6
More coverage tests & specs. (#7171)
* Add spec for eval and line coverage.

* Add test for main file coverage.
2023-01-22 13:49:13 +13:00
Nobuyoshi Nakada e3336e0929 Define RUBY_VERSION_IS_3_3 macro in rubyspec.h 2023-01-18 21:59:41 +09:00
Nobuyoshi Nakada 71ce7e1825
[Bug #19335] `Integer#remainder` should respect `#coerce` (#7120)
Also `Numeric#remainder` should.
2023-01-15 13:03:27 +09:00
Peter Zhu abff5f6203 Move classpath to rb_classext_t
This commit moves the classpath (and tmp_classpath) from instance
variables to the rb_classext_t. This improves performance as we no
longer need to set an instance variable when assigning a classpath to
a class.

I benchmarked with the following script:

```ruby
name = :MyClass

puts(Benchmark.measure do
  10_000_000.times do |i|
    Object.const_set(name, Class.new)
    Object.send(:remove_const, name)
  end
end)
```

Before this patch:

```
  5.440119   0.025264   5.465383 (  5.467105)
```

After this patch:

```
  4.889646   0.028325   4.917971 (  4.942678)
```
2023-01-11 11:06:58 -05:00
Benoit Daloze 6abe20e87b Remove Encoding#replicate 2023-01-11 13:41:41 +01:00
Hiroshi SHIBATA b311c35bdb Suppressing pending messages with RSpec 2023-01-11 20:00:21 +09:00
Hiroshi SHIBATA a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09:00
David Rodríguez 2e0159c5f2 [rubygems/rubygems] Fix resolver edge case
Let it deal with legacy gems with equivalent version and different
dependencies.

https://github.com/rubygems/rubygems/commit/b430babe97
2023-01-10 12:58:28 +09:00
Benoit Daloze 28cfc0c116 Only RangeError on CRuby for shift width >= 2**67
* It seems a better exception class too than NoMemoryError.
2023-01-07 13:18:04 +01:00
Benoit Daloze 897cf122bf Fix Integer#{<<,>>} specs with large shift width
* The limit depends on the implementation and platform, it seems unavoidable.
* See https://bugs.ruby-lang.org/issues/18518#note-9
2023-01-07 13:13:03 +01:00
Nobuyoshi Nakada e537aa65c0 [ruby/syntax_suggest] Run with the given ruby command
Running the file with shebang has a few issues.

* shebang is an OS dependent feature. Many modern UNIX-like OSes
  support it, but not all, e.g., Windows.
* `env` command may not be in `/usr/bin`.
* "ruby" command may not be "ruby", when `--program-suffix` or other
  configuration option is used.

https://github.com/ruby/syntax_suggest/commit/2edf241055
2023-01-07 17:02:49 +09:00
Benoit Daloze 2b88dbc6f9 Add bug number 2023-01-06 16:28:02 +01:00
Benoit Daloze 53938efd7b Update to ruby/spec@5e48206 2023-01-05 21:07:29 +01:00
Benoit Daloze ec14861f0d Update to ruby/spec@7e680fa 2023-01-05 20:23:57 +01:00
git 54950a78e3 * remove trailing spaces, append newline at EOF. [ci skip] 2023-01-05 18:06:01 +00:00
Benoit Daloze bbf54ec334 Update to ruby/spec@9d69b95 2023-01-05 19:05:29 +01:00
Benoit Daloze cd5e6cc0ea Update to ruby/mspec@fef9b81 2023-01-05 19:05:27 +01:00
yoka 799d805e21 [rubygems/rubygems] Raise invalid option when bundle open --path is called without a value
https://github.com/rubygems/rubygems/commit/c242311158
2023-01-04 13:13:19 +00:00
yoka 87c17a141d [rubygems/rubygems] Enhance bundle open with --path option
https://github.com/rubygems/rubygems/commit/3bf8e59304
2023-01-04 13:13:19 +00:00
Jeremy Evans 0903a25179 Make IO#set_encoding with binary external encoding use nil internal encoding
This was already the behavior when a single `'external:internal'`
encoding specifier string was passed.  This makes the behavior
consistent for the case where separate external and internal
encoding specifiers are provided.

While here, fix the IO#set_encoding method documentation to
state that either the first or second argument can be a string
with an encoding name, and describe the behavior when the
external encoding is binary.

Fixes [Bug #18899]
2023-01-01 09:00:24 -08:00
Kenta Murata 9f2378959e
numeric.c: Fix round_half_even for specific values (#7023)
Handle the integert and the float parts separately in round_half_even
to prevent error occursions in floating point calculation.
2022-12-26 21:02:47 +09:00
Hiroshi SHIBATA b7ad60a794 Merge RubyGems/Bundler master
from 72fd3dd209
2022-12-26 15:09:21 +09:00
Nobuyoshi Nakada 5df7118445
Skip insanely memory consuming tests
These tests do not only consume hundreds GiB bytes memory, result in
`rb_bug` when `RUBY_DEBUG` is enabled.
2022-12-26 15:01:44 +09:00
Hiroshi SHIBATA a236661a62
Skip some examples for Ruby 3.3 2022-12-26 13:52:48 +09:00
David Rodríguez 8f05e4f54b Update Bundler to 2.4.1 & and RubyGems to 3.4.1 2022-12-25 05:55:36 +09:00
Lars Kanis d0f5dc9eac Windows: Prefer USERPROFILE over HOMEPATH
HOMEPATH is set to "\WINDOWS\system32" when running per "runas" session.
This directory is not writable by ordinary users, leading to errors with many ruby tools.
Also config files in the home directory are not recognized.

Still keeping HOME at first which is not used by native Windows,
but by ruby specs and by MSYS2 environment.
2022-12-24 23:48:47 +09:00
Lars Kanis d6ce4180a5 Windows: Fix encoding of Dir.home
Dir.home returns an UTF-8 string since ruby-3.0, but the actual
encoding of the bytes was CP_ACP or CP_OEMCP.
That led to invalid bytes when calling Dir.home with an unicode
username.
2022-12-24 22:54:23 +09:00
Hiroshi SHIBATA f6620037ba Merge RubyGems-3.4.0 and Bundler-2.4.0 2022-12-24 16:57:07 +09:00
Hiroshi SHIBATA 4aeea3cc09 Removed the needless test guard for syntax_suggest.
It's resolved by 5bb43aeb89
2022-12-23 14:07:02 +09:00
Nobuyoshi Nakada bf3b376522 [ruby/syntax_suggest] Remove debug print
https://github.com/ruby/syntax_suggest/commit/4d53d31bc5
2022-12-23 13:05:26 +09:00
Nobuyoshi Nakada 5bb43aeb89 [ruby/syntax_suggest] Should not hardcode ruby name
https://github.com/ruby/syntax_suggest/commit/0d5201b24d
2022-12-23 13:05:25 +09:00
Jeremy Evans 7e8fa06022 Always issue deprecation warning when calling Regexp.new with 3rd positional argument
Previously, only certain values of the 3rd argument triggered a
deprecation warning.

First step for fix for bug #18797.  Support for the 3rd argument
will be removed after the release of Ruby 3.2.

Fix minor fallout discovered by the tests.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-12-22 11:50:26 -08:00
Benoit Daloze 0efa36ac06 Ensure Fiber storage is only accessed from the Fiber it belongs to 2022-12-20 19:32:23 +01:00
Benoit Daloze 45175962a6 Never use the storage of another Fiber, that violates the whole design
* See https://bugs.ruby-lang.org/issues/19078#note-30
2022-12-20 19:32:23 +01:00
Hiroshi SHIBATA 18ba89093a Merge RubyGems/Bundler master
Pick from ba3adad4d8
2022-12-20 13:15:02 +09:00
Mark Burns 870bcc96ba [rubygems/rubygems] fix
https://github.com/rubygems/rubygems/pull/6147 when --parseable and
--groups used
together

https://github.com/rubygems/rubygems/commit/3b0b95c509
2022-12-20 13:15:02 +09:00
Josef Šimánek 8eb6618013 [rubygems/rubygems] Turn `--ext` option into string. Deprecate usage without explicit value.
- this is preparation for onboarding Rust based extension gem generator

https://github.com/rubygems/rubygems/commit/d32801bdbc
2022-12-20 13:15:02 +09:00
Josef Šimánek f270aa3eda [rubygems/rubygems] Use safe Marshal deserialization for dependency API response. - adds Bundler#safe_load_marshal and Bundler::SAFE_MARSHAL_CLASSES listing safe classes to deserialize
https://github.com/rubygems/rubygems/commit/e947c608cc
2022-12-20 13:15:02 +09:00
David Rodríguez 1db9bcfeaf [rubygems/rubygems] Fix crash when building resolution errors with OR requirements
https://github.com/rubygems/rubygems/commit/8f287479bc
2022-12-20 13:15:02 +09:00
Michael Siegfried 32e72b78b3 [rubygems/rubygems] Add tests for bundle lock
Ensure `bundle lock` handles pre flag just like bundle update does.

https://github.com/rubygems/rubygems/commit/b9e85e3157
2022-12-20 13:15:02 +09:00
Michael Siegfried 42972bdd92 [rubygems/rubygems] Test the public interface
With `GemVersionPromoter#sort_versions` being so simple, we no longer
need to reach into the class's internals to make private methods public
in order to effectively test. We can just allow both cases to go through
the main method.

https://github.com/rubygems/rubygems/commit/6cbe891003
2022-12-20 13:15:02 +09:00
Michael Siegfried 2bc4f1dea5 [rubygems/rubygems] Support for pre flag in `bundle update`
Passing this flag allows bumping to the current version, even if that
version is prerelease. This works in concert with the current flags.

https://github.com/rubygems/rubygems/commit/a6409e3509
2022-12-20 13:15:02 +09:00
David Rodríguez 3fd33590f6 [rubygems/rubygems] Fix crash when lockfile is missing dependencies
We have a check for a corrupt lockfile right before installing. However,
the check accounted for locked specs not satisfying locked dependencies,
but not for locked specs missing for some locked dependencies.

Instead of fixing this check, I decided to remove it in favor of
automatically detecting the situation and re-resolve to automatically
fix the lockfile rather than printing a warning but leave the problem
there.

https://github.com/rubygems/rubygems/commit/4a7a584252
2022-12-20 13:15:02 +09:00
Alyssa Ross d4315284e9 [rubygems/rubygems] Add bundle lock --update --bundler
bundle lock --update can do everything that bundle update can do, but
it doesn't actually install gems. This is especially useful for
generating a lockfile on a machine that doesn't have the libraries
available to be able to build native extensions.

But, there was no parallel for bundle update --bundler. So let's add
one.

https://github.com/rubygems/rubygems/commit/7fc00bd2a5
2022-12-18 19:17:42 +00:00
Hiroshi SHIBATA 49b0f3b024 Merge RubyGems/Bundler master
Pick from 084f7d1f21
2022-12-15 19:06:40 +09:00
Samuel Williams d20bd06a97
Remove `require 'io/wait'` where it's no longer necessary. (#6932)
* Remove `require 'io/wait'` as it's part of core now.

* Update ruby specs using version gates.

* Add note about why it's conditional.
2022-12-15 11:37:01 +13:00
David Rodríguez 6d00053c74 [rubygems/rubygems] Use better matcher
Hopefully it gives a better error.

https://github.com/rubygems/rubygems/commit/5bc9ff64b6
2022-12-13 12:41:08 +09:00
Hiroshi SHIBATA bbe56a6437 Merge RubyGems/Bundler master
from bfb0ae6977
2022-12-12 10:49:43 +09:00
Samuel Williams 22d391dc63
Add spec for fiber storage. (#6896) 2022-12-10 13:54:53 +13:00
Nobuyoshi Nakada fe67998816
Clean up a temporary file 2022-12-09 22:15:38 +09:00
Nobuyoshi Nakada 11acb7f7bc
[Bug #19167] Remove useless conversion of classes for special const 2022-12-09 22:11:44 +09:00
Hiroshi SHIBATA 93ac1503be Added condition for ruby/ruby repository 2022-12-09 16:36:22 +09:00
Hiroshi SHIBATA 0677bbe3ff Merge syntax_suggest master
Pick from daee74dcb0
2022-12-09 16:36:22 +09:00
Hiroshi SHIBATA a4e14b9d9d Merge RubyGems/Bundler master
Pick from 823c776d95
2022-12-09 16:36:22 +09:00
Samuel Williams 6fd5d2dc00
Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867) 2022-12-08 18:19:53 +13:00
Aaron Patterson a89d856f26 Update spec/bundler/bundler/fetcher/compact_index_spec.rb
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-12-07 09:57:11 -08:00
Aaron Patterson edc7af48ac Stop transitioning to UNDEF when undefining an instance variable
Cases like this:

```ruby
obj = Object.new
loop do
  obj.instance_variable_set(:@foo, 1)
  obj.remove_instance_variable(:@foo)
end
```

can cause us to use many more shapes than we want (and even run out).
This commit changes the code such that when an instance variable is
removed, we'll walk up the shape tree, find the shape, then rebuild any
child nodes that happened to be below the "targetted for removal" IV.

This also requires moving any instance variables so that indexes derived
from the shape tree will work correctly.

Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com>
Co-authored-by: John Hawthorn <jhawthorn@github.com>
2022-12-07 09:57:11 -08:00
Martin Dürst e0487ec45e update rbconfig spec to Unicode version 15.0.0
(this includes emoji version 15.0)
2022-12-06 10:11:33 +09:00
Nobuyoshi Nakada 7b2306a3ab
Remove unguaranteed assertion [ci skip]
It can be configured by `--with-os-version-style=TYPE` option, and
just copies from theApple's installation as the default.  We don't
know why it is major only.
2022-12-03 11:27:16 +09:00
Koichi Sasada 59e389af28 UnboundMethod only refer defined_class
UnboundMethod records caller's class, like `D` or `E` on the
following case:

```ruby
class C
  def foo = :foo
end

class D < C
end

class E < C
end

d = D.instance_method(:foo)
e = E.instance_method(:foo)
```

But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't
record `D` or `E`. This behavior changes the following methods:

* `UnboundMethod#inspect` (doesn't show caller's class)
* `UnboundMethod#==` (`d == e` for example)

fix https://bugs.ruby-lang.org/issues/18798
2022-12-03 08:53:12 +09:00
Hiroshi SHIBATA d55d1a737b
Skip examples for SyntaxError extensions on Ruby 3.2 2022-12-02 10:34:00 +09:00
Nobuyoshi Nakada 9da2a5204f
[Bug #19087] Merge to "trailing garbage" case 2022-12-02 01:50:48 +09:00
Nobuyoshi Nakada c94cd8534a
[Bug #19087] Fix an assertion of `String#to_c` 2022-12-02 01:47:30 +09:00
schneems d6e91784ab Update SyntaxSuggest to use angle brackets `>`
```
$ ruby tool/sync_default_gems.rb syntax_suggest
Sync ruby/syntax_suggest
```

https://github.com/ruby/syntax_suggest/pull/161
2022-11-30 12:58:47 +09:00
schneems f64ba0fadd
[ruby/syntax_suggest] Do not output "Syntax OK" when there's an error
Due to a problem with ripper we do not recognize `break` as invalid code. It's confusing that "Syntax OK" is output in that case.

When there's no syntax error, the algorithm should not say anything. The exception is in the CLI and that's for compatibility with `ruby -wc`

```
$ cat /tmp/break.rb
break
️ 3.1.2 🚀 /Users/rschneeman/Documents/projects/syntax_suggest (schneems/no-syntax-not-okay-break)
$ ruby -wc /tmp/break.rb
Syntax OK
```

> Note that this is invalid, running this code will raise a Syntax error.

```
$ exe/syntax_suggest /tmp/break.rb
Syntax OK
```

Close https://github.com/ruby/syntax_suggest/pull/157

https://github.com/ruby/syntax_suggest/commit/d7bd8f03a2
2022-11-28 20:55:41 +09:00
schneems 4d51a0b495
[ruby/syntax_suggest] Failing test for #157
https://github.com/ruby/syntax_suggest/commit/14e8cdc916
2022-11-28 20:55:41 +09:00
Jeremy Evans 571d21fd4a Make String#rstrip{,!} raise Encoding::CompatibilityError for broken coderange
It's questionable whether we want to allow rstrip to work for strings
where the broken coderange occurs before the trailing whitespace and
not after, but this approach is probably simpler, and I don't think
users should expect string operations like rstrip to work on broken
strings.

In some cases, this changes rstrip to raise
Encoding::CompatibilityError instead of ArgumentError.  However, as
the problem is related to an encoding issue in the receiver, and due
not due to an issue with an argument, I think
Encoding::CompatibilityError is the more appropriate error.

Fixes [Bug #18931]
2022-11-24 18:24:42 -08:00
Nobuyoshi Nakada 36f297e621
Use valid tokens as cookie names 2022-11-22 11:32:28 +09:00
MSP-Greg cf05c202ce Fixup spec/ruby/optional/capi/rbasic_spec.rb for mswin 2022-11-21 19:52:44 +01:00
David Rodríguez c925a2ee91
Update RSpec gems 2022-11-15 14:45:51 +09:00
Takashi Kokubun 18fa7059e8
Deal with different Ruby versions 2022-11-12 22:15:40 -08:00
Takashi Kokubun c0735d1d72
Fix a CI failure in bigdecimal 2022-11-12 21:55:00 -08:00
Hiroshi SHIBATA 0a9d51ee9d Migrate our resolver engine to PubGrub
https://github.com/rubygems/rubygems/pull/5960

  Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2022-11-12 07:40:31 +09:00
Hiroshi SHIBATA 28611be6ee Merge RubyGems/Bundler master from ee2f8398324af4bc1b95f7565ce2fda98126e026 2022-11-11 17:24:08 +09:00
Yusuke Endoh d5513da01d [rubygems/rubygems] Update bundler/spec/bundler/shared_helpers_spec.rb
https://github.com/rubygems/rubygems/commit/8b1481ba77

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-11-10 22:45:31 +00:00
Yusuke Endoh b5f809c496 [rubygems/rubygems] Load "bundler/setup" in lib/rubygems.rb
Ruby interpreter loads some special gems at startup: did_you_mean,
error_highlight, and syntax_suggest. These gems are loaded before
`bundler/setup` is loaded by `RUBYOPT=-rbundler/setup`.
So, the versions of the gems are not controllable by Gemfile.

This change will `require "bundler/setup"` in rubygems.rb (i.e., before
the special gems are loaded). Now `bundle exec` sets an environment
variable `BUNDLER_SETUP`, and rubygems requires the variable if defined.

See also: https://bugs.ruby-lang.org/issues/19089

https://github.com/rubygems/rubygems/commit/963cb65a2d
2022-11-10 22:45:31 +00:00
Bo Anderson 0df47fdaf9 [rubygems/rubygems] Add tests for universal Ruby with arch-specific prebuilt gems
https://github.com/rubygems/rubygems/commit/11229b16c3
2022-11-08 17:05:19 +00:00
Nobuyoshi Nakada cb2323a983
Thread#native_thread_id is very platform specific 2022-11-08 09:31:58 +09:00
Benoit Daloze 83decbb62b Update to ruby/spec@740ccc8 2022-11-07 20:05:30 +01:00
Benoit Daloze c99e4c4278 Update to ruby/mspec@1e16420 2022-11-07 20:05:18 +01:00
Nobuyoshi Nakada ee86b57ee5
Revert jobserver handling in spec 2022-11-07 15:54:40 +09:00
Nobuyoshi Nakada b02b8e7756
Let other test runners follow the change of GNU make 4.4 jobserver 2022-11-07 10:08:30 +09:00
Nobuyoshi Nakada 174ddc79c5
Skip `File.atime`/`File.mtime` tests randomly failing on Travis
Not only powerpc64le, also s390x and arm32 seem failing too.  These
failures are probably caused by filesystem settings on Travis, but
unrelated to CPUs.
2022-10-24 09:32:13 +09:00
Stephen Ierodiaconou 54cad3123a
[Bug #19004] `Complex.polar` handles complex singular `abs` argument
`Complex.polar` accepts Complex values as arguments for the polar form as long
as the value of the complex has no imaginary part (ie it is 'real'). In
`f_complex_polar` this is handled by extracting the real part of the arguments.
However in the case `polar` is called with only a single argument, the absolute
value (abs), then the Complex is created without applying a check on the type
of abs, meaning it is possible to create a Complex where the real part is itself
an instance of a Complex. This change removes the short circuit for the single
argument case meaning the real part extraction is performed correctly
(by f_complex_polar).

Also adds an example to `spec/ruby/core/complex/polar_spec.rb` to check that
the real part of a complex argument is correctly extracted and used in the
resulting Complex real and imaginary parts.
2022-10-23 12:59:06 +09:00
Yusuke Endoh e026368061 Range#size returns nil for (.."a") and (nil..)
Fixes [Bug #18983]
2022-10-21 16:35:46 +09:00
Ufuk Kayserilioglu 0378e2f4a8 Add Class#attached_object
Implements [Feature #12084]

Returns the object for which the receiver is the singleton class, or
raises TypeError if the receiver is not a singleton class.
2022-10-20 17:30:17 +02:00
Hiroshi SHIBATA 4f1e0bfacd
Followed up CVE-2022-39253 for bundler examples 2022-10-20 14:36:06 +09:00
Jemma Issroff 0aaa6133ed Transition frozen string to frozen root shape
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2022-10-19 11:06:19 -07:00
Hiroshi SHIBATA f5df47d1f3 Merge RubyGems/Bundler master
6214d00b23
2022-10-18 16:33:15 +09:00
David Rodríguez 5fa18a7b0c [rubygems/rubygems] Fix bad spec wording
https://github.com/rubygems/rubygems/commit/06faad1e05
2022-10-18 16:33:15 +09:00
David Rodríguez e956caea88 [rubygems/rubygems] Extract matcher for slow perf spec
https://github.com/rubygems/rubygems/commit/1c0eb63c6a
2022-10-18 16:33:15 +09:00
David Rodríguez 804ae4ea12 [rubygems/rubygems] Simplify SpecGroup creation
https://github.com/rubygems/rubygems/commit/788e46e152
2022-10-18 16:33:15 +09:00
Jean Boussier 60defe0a68 thread_sync.c: Clarify and document the behavior of timeout == 0
[Feature #18982]

Instead of introducing an `exception: false` argument to have `non_block`
return nil rather than raise, we can clearly document that a timeout of 0
immediately returns.

The code is refactored a bit to avoid doing a time calculation in
such case.
2022-10-17 16:56:00 +02:00
Hiroshi SHIBATA b734832883
Skip utime example with Intel C Compiler suite 2022-10-13 13:42:22 +09:00
Nobuyoshi Nakada 6c5a8c2043 Ignore excessive precisions 2022-10-10 13:41:46 +09:00
Samuel Williams 24f3e397e9
Add spec for `Coverage.supported?` and `start(eval: true)`. (#6499)
* Don't emit coverage for eval when eval coverage is disabled.
2022-10-08 00:33:40 +13:00
Samuel Williams e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
Samuel Williams e696ec67ac
Introduce `Fiber.blocking{}` for bypassing the fiber scheduler. (#6498) 2022-10-06 23:00:49 +13:00
David Rodríguez 358fe26b31 [rubygems/rubygems] Fix little UI issue when bundler shows duplicated gems in a list
https://github.com/rubygems/rubygems/commit/3f71d882e9
2022-10-06 05:13:39 +09:00
David Rodríguez b2668248b6 [rubygems/rubygems] Make sure RSpec diffs don't omit the different part
We sometimes check assertions on lockfile contents, which involves
comparing a reasonably long string. Sometimes RSpec is not able to show
the part of the string that's actually different, making it hard to
figure out the issue.

Configuring this setting should fix the issue in most cases.

https://github.com/rubygems/rubygems/commit/5ad8ee499e
2022-10-04 06:22:50 +09:00
Victor Gama bc6c1e0e25 [rubygems/rubygems] Copy template contents instead of file and perms
This allows the file to be created without copying permissions
from Bundler's installation source. The previous behaviour was
noticed after installing Ruby through brew, and using bundle
init, which yielded a read-only Gemfile.

https://github.com/rubygems/rubygems/commit/839a06851d
2022-10-03 20:41:45 +09:00
Victor Shepelev ad651925e3
Add Data class implementation: Simple immutable value object 2022-09-30 18:23:19 +09:00
Benoit Daloze aa53d69aa2 Add specs for {Method,UnboundMethod}#owner of a zsuper method 2022-09-29 15:48:35 +02:00
Benoit Daloze 94cea3e4d0 Fix {Method,UnboundMethod}#super_method for zsuper methods
* We need to resolve the zsuper method first, and then look the super
  method of that.
2022-09-29 15:48:35 +02:00
Hiroshi SHIBATA 9948b8bfec
Skip unpack_sockaddr_in with http at Solaris platform
http://rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20220929T050003Z.fail.html.gz
2022-09-29 15:47:08 +09:00
Benoit Daloze 31cf1bb525 Update to ruby/spec@1d9d5c6 2022-09-28 18:37:17 +02:00
Benoit Daloze 5a1ab740fc Update to ruby/mspec@b60306d 2022-09-28 18:37:16 +02:00
Jemma Issroff d594a5a8bd
This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-28 08:26:21 -07:00
Vít Ondruch bcd30fb961 Re-enable TZ test missed due to merge conflict.
This was disabled by b7577b4d9e, while properly fixed upstream by:

https://github.com/ruby/spec/pull/939
2022-09-27 19:32:46 +02:00
Aaron Patterson 06abfa5be6
Revert this until we can figure out WB issues or remove shapes from GC
Revert "* expand tabs. [ci skip]"

This reverts commit 830b5b5c35.

Revert "This commit implements the Object Shapes technique in CRuby."

This reverts commit 9ddfd2ca00.
2022-09-26 16:10:11 -07:00
Jemma Issroff 9ddfd2ca00 This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-26 09:21:30 -07:00
Chris Salzberg 82ac4a2399 Support using at toplevel in wrapped script
Allow refinements to be used at the toplevel within a script that is
loaded under a module.

Fixes [Bug #18960]
2022-09-24 09:41:15 +09:00
Samuel Williams 9434a7333c Enable coverage for eval. 2022-09-22 22:19:12 +12:00
Yuta Saito 3f387e60ef Rescue File.expand_path in MSpecScript#try_load if HOME is unavailable
mspec tries to load ~/.mspecrc, but some platforms (e.g. WASI) doesn't
have HOME concept, so `~` cannot be expanded and `File.expand_path` can
fail.
2022-09-21 15:26:34 +09:00
Nobuyoshi Nakada bf72afa766
Remove warning for old TLS version connection
RubyGems.org already has refused connection requests using older than
TLS 1.2.
2022-09-15 14:48:47 +09:00
Benoit Daloze 14bcf69c9c Deprecate Encoding#replicate
* See [Feature #18949].
2022-09-10 19:02:15 +02:00
David Rodríguez e0cd466ae7 [rubygems/rubygems] Fix unused variable warning
https://github.com/rubygems/rubygems/commit/ca8d47e53a
2022-09-08 20:44:35 +09:00
David Rodríguez 24fd2f73d0 Resync Bundler & RubyGems 2022-09-08 11:25:03 +09:00
David Rodríguez 1f77cc3894 [rubygems/rubygems] Fix `set` not being found when running specs on dev rubies
https://github.com/rubygems/rubygems/commit/c5b2960388
2022-09-06 17:11:47 +09:00
David Rodríguez c664264c07 [rubygems/rubygems] Add `syntax_suggest` to exemption list in setup specs
https://github.com/rubygems/rubygems/commit/f9a51e4380
2022-09-06 17:11:47 +09:00
David Rodríguez 6bc6c8d031 [rubygems/rubygems] Remove no longer needed `fiddle` hacks
RubyInstaller has released patch versions backporting their changes to
not load `fiddle` on boot, so all these are no longer necessary.

https://github.com/rubygems/rubygems/commit/05a307deb2
2022-09-05 21:21:15 +09:00
Hiroshi SHIBATA 3eca1e438d Merge 16c3535413 2022-09-05 14:37:12 +09:00
Mike Dalessio 45fe7f7575
[rubygems/rubygems] Feature: `bundle add` supports `--path` option
https://github.com/rubygems/rubygems/commit/32bee01fbe
2022-09-05 11:43:14 +09:00
David Rodríguez f7cf641469
[rubygems/rubygems] Fix resolution hanging on musl platforms
After recent musl support was added, Bundler started hanging in musl
platforms. I identified the issue where valid candidates were being
filtered out because their platform was specified as a string, and thus
`Gem::Platform.match_spec?` which under the hood ends up calling
`Gem::Platform#===` would return `nil`, because it does not support
comparing platforms to strings.

In particular, `Bundler::EndpointSpecification`'s platform coming from
the API was not instantiated as a `Gem::Platform`, hence the issue.

Also, this spec surfaced another issue where a bug corrected in
`Gem::Platform#match_platforms` had not been yet backported to Bundler.
So this commit also backports that to get the spec green across RubyGems
versions.

Finally, the fix in `Bundler::EndpointSpecification` made a realworld
spec start failing. This spec was faking out `rails-4.2.7.1` requirement
on Bundler in the `Gemfile.lock` file to be `>= 1.17, < 3` when the real
requirement is `>= 1.17, < 2`. Due to the bug in
`Bundler::EndpointSpecification`, the real requirement provided by the
compact index API (recorded with VCR) was being ignored, and the
`Gemfile.lock` fake requirement was being used, which made the spec
pass. This is all expected, and to fix the issue I changed the spec to
be really realworld and don't fake any Bundler requirements.

https://github.com/rubygems/rubygems/commit/faf4ef46bc
2022-09-05 11:43:14 +09:00
Jean Boussier bbe5ec7846 rb_int_range_last: properly handle non-exclusive range
[Bug #18994]
2022-09-04 11:16:11 +02:00
git f069bc79f2 * append newline at EOF. [ci skip] 2022-09-02 15:57:18 +09:00
Hiroshi SHIBATA 740d530bb0
Added doc about `test-syntax-suggest` 2022-09-02 15:30:46 +09:00
Hiroshi SHIBATA e7a8e3e91f
Added entries about test-bundler-parallel and BUNDLER_SPECS 2022-09-02 15:25:54 +09:00
Takashi Kokubun 737402e938
Skip a couple of chroot spec faillures
I don't come up with a way to fix it right away. We'd need some
experiments on a pull request.
2022-08-29 09:55:57 -07:00
Benoit Daloze 1315c5aad9 Update to ruby/spec@b8a8240 2022-08-29 18:18:23 +02:00
Benoit Daloze b5358a98e6 Update to ruby/mspec@37151a0 2022-08-29 18:18:20 +02:00
Benoit Daloze 4ee1a68776 Update to ruby/spec@d01709f 2022-08-29 15:36:29 +02:00
shields 8799c91205 [rubygems/rubygems] Add platform :windows as a shortcut for all Windows platforms
https://github.com/rubygems/rubygems/commit/f3c49ad3f7
2022-08-29 00:33:15 +09:00
Aleksandr Varnin 381d8e43ce [rubygems/rubygems] Bundler: make to_lock consistent between Gem::Dependency and Bundler::Dependency
https://github.com/rubygems/rubygems/commit/971d57cf5a
2022-08-28 02:04:14 +09:00
Hiroshi SHIBATA 5e4d1f9908 Skip examples to need installed ruby exe 2022-08-26 12:15:47 +09:00
Hiroshi SHIBATA 8dfc077f70 Added syntax_suggest cli and resolve failing exapmle with it 2022-08-26 12:15:47 +09:00
Hiroshi SHIBATA bd1b1eeb0e ruby-prof is now optional 2022-08-26 12:15:47 +09:00
Hiroshi SHIBATA 0d9f4ea0d4 Import spec examples from ruby/syntax_suggest 2022-08-26 12:15:47 +09:00
Jean Boussier b2d0f78869 Fix private methods reported as protected when called via Symbol#to_proc
Ref: bfa6a8ddc8
Ref: [Bug #18826]
2022-08-25 17:49:50 +02:00
David Rodríguez ad8774f8e5 [rubygems/rubygems] Fix another regression for sorbet
Recently a changed was introduced to update the resolver platforms after
it has been created, in order to remove the "ruby" platform from it if
it's to be removed from the lockfile. However, it did not update the
`@resolving_only_for_ruby` instance variable in that case, so the
resolver was not properly doing the right thing anymore.

To fix this, I tweaked the code to restore not changing resolver
platforms after the resolver has been instantiated.

https://github.com/rubygems/rubygems/commit/8fbc30a1d0
2022-08-25 23:39:02 +09:00
David Rodríguez 0ad9cc1696 [rubygems/rubygems] Backport non-gnu libc on linux platform matching to Bundler
https://github.com/rubygems/rubygems/commit/703373b41f

Co-authored-by: Loic Nageleisen <loic.nageleisen@gmail.com>
2022-08-24 17:59:15 +09:00
Takuya Noguchi 7c784f0a67 [rubygems/rubygems] Bundler: avoid use of "can not" in spec literals
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

https://github.com/rubygems/rubygems/commit/73b5cf9bd1
2022-08-23 15:33:34 +09:00
Takuya Noguchi 22a416a3bb [rubygems/rubygems] Bundler: update the link suggested on error with the new one
Also typo is fixed.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

https://github.com/rubygems/rubygems/commit/9c1ea52ddf
2022-08-23 14:28:47 +09:00
Hiroshi SHIBATA f69244cee8 Merge rubygems/bundler HEAD
Pick from 6b3a5a9ab0
2022-08-23 10:45:57 +09:00
David Rodríguez 4790d0accd [rubygems/rubygems] Fix conservative update downgrading top level gems
When `--conservative` is passed, explicit unlocks are set for top level
gems via `@unlock[:gems]`, so that only those particular gems are
allowed to be updated.

When we compute the "base resolve" from the lockfile (the set of gems
whose versions should be kept pinned by the resolver), we always exclude
gems explicitly unlocked through `@unlock[:gems]` from it. This is done
by the `converge_specs` method.

However, the `converge_specs` method is also used for figuring out
additional lower bound requirements from the lockfile. But in this case,
even if gems are explicitly unlock in `@unlock[:gems]`, we still want to
add the additional requirement, so that gems are not downgraded by the
resolver.

So the solution is to move the line filtering out gems in
`@unlock[:gems]` from the `converged_specs` method out of that method,
so that it only applies for computing the "base resolve", but not the
addtional lower bound requirements.

https://github.com/rubygems/rubygems/commit/405119bd7b
2022-08-23 10:45:57 +09:00
David Rodríguez a9509068db [rubygems/rubygems] Make `compact_index_api_missing` server more strict
The compact index should not request any marshaled gemspecs whatsoever.

https://github.com/rubygems/rubygems/commit/6dbd44d0c0
2022-08-23 10:45:57 +09:00
David Rodríguez 560941e711 [rubygems/rubygems] Fix edge case where `bundler/inline` unintentionally skips install
If the application has the `no_install` setting set for `bundle
package`, then `bundler/inline` would silently skip installing any gems.

https://github.com/rubygems/rubygems/commit/7864f49b27
2022-08-21 17:54:11 +09:00
David Rodríguez b87ddd7538 [rubygems/rubygems] Fix `bundle platform` crash when there's a lockfile with no Ruby locked
https://github.com/rubygems/rubygems/commit/49fc54e87d
2022-08-21 17:53:40 +09:00
Benoit Daloze 209631a45f Consider resolved-through-zsuper methods equal for compatibility
* Fixes https://bugs.ruby-lang.org/issues/18751
2022-08-20 13:44:00 +02:00
Nobuyoshi Nakada 1ef49de834 [Bug #18955] format single character for `%c` 2022-08-20 03:57:13 +09:00
Jean Boussier fe61cad749 Implement SizedQueue#push(timeout: sec)
[Feature #18944]

If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
2022-08-18 10:07:37 +02:00
Nobuyoshi Nakada b7577b4d9e
The tzdata 2022c removed Amsterdam Mean Time 2022-08-17 00:45:27 +09:00
David Rodríguez e77c8397c2 [rubygems/rubygems] Fix Ruby platform incorrectly removed on `bundle update`
https://github.com/rubygems/rubygems/commit/0d321c9e3a
2022-08-15 17:42:16 +09:00
Jeremy Evans cfb9624460
Fix Array#[] with ArithmeticSequence with negative steps (#5739)
* Fix Array#[] with ArithmeticSequence with negative steps

Previously, Array#[] when called with an ArithmeticSequence
with a negative step did not handle all cases correctly,
especially cases involving infinite ranges, inverted ranges,
and/or exclusive ends.

Fixes [Bug #18247]

* Add Array#slice tests for ArithmeticSequence with negative step to test_array

Add tests of rb_arithmetic_sequence_beg_len_step C-API function.

* Fix ext/-test-/arith_seq/beg_len_step/depend

* Rename local variables

* Fix a variable name

Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com>
2022-08-11 19:16:49 +09:00
Jeremy Evans bfa6a8ddc8
Only allow procs created by Symbol#to_proc to call public methods
Fixes [Bug #18826]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-08-10 13:02:19 -07:00
Nobuyoshi Nakada 43239b23b4
[Bug #18946] New tests for fixed Time/DateTime conversions 2022-08-08 23:48:13 +09:00
Nobuyoshi Nakada e0dfa5967e
[Bug #18946] Use Gregorian dates to test 2022-08-08 23:48:09 +09:00
Nobuyoshi Nakada 03f86565a6
Silent backtrace from cve_2019_8325_spec.rb
Since the change at f310ac1cb2 to show
the backtraces by default, this test started to show the backtraces.
As the backtraces are not the subject of this test, silence them by
using Gem::SilentUI.
2022-08-07 17:57:52 +09:00
David Rodríguez 466a760e18 [rubygems/rubygems] Fix yanked gems being unintentionally update when other gems are unlocked
This is a regression from a change intended to raise errors when user
puts a gem under an incorrect source in the Gemfile by mistake. To fix
the issue, we revert the change that caused it and implement it in a
different way that restores the resolver independency from real
specifications. Now it deals only with names and versions and does not
try to materialize anything into real specifications before resolving.

https://github.com/rubygems/rubygems/commit/d2bf1b86eb
2022-08-06 15:41:46 +09:00