Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/spec_guards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
# Specs from ruby/spec should still run on all supported Ruby versions.
# This also ensures the needed ruby_version_is guards are there, see spec/README.md.
ruby:
- ruby-3.2
- ruby-3.3
- ruby-3.4
- ruby-4.0
Expand Down
2 changes: 1 addition & 1 deletion ext/coverage/coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ rb_coverage_supported(VALUE self, VALUE _mode)
* If +lines+ is enabled, +oneshot_lines+ cannot be enabled.
* See {Lines Coverage}[rdoc-ref:Coverage@Lines+Coverage].
* - +branches+: Enables branch coverage that records the number of times each
* branch in each conditional was executed. See {Branches Coverage}[rdoc-ref:Coverage@Branch+Coverage].
* branch in each conditional was executed. See {Branches Coverage}[rdoc-ref:Coverage@Branches+Coverage].
* - +methods+: Enables method coverage that records the number of times each method was exectued.
* See {Methods Coverage}[rdoc-ref:Coverage@Methods+Coverage].
* - +eval+: Enables coverage for evaluations (e.g. Kernel#eval, Module#class_eval).
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def converge_specs(specs)
end
end

if parent_dep
if parent_dep && parent_dep.source.is_a?(Source::Path)
replacement_source = parent_dep.source
else
replacement_source = sources.get(lockfile_source)
Expand Down
48 changes: 24 additions & 24 deletions lib/net/http/requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#
# - Request body: optional.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: yes.
#
# Related:
#
Expand Down Expand Up @@ -52,9 +52,9 @@ class Net::HTTP::Get < Net::HTTPRequest
#
# - Request body: optional.
# - Response body: no.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: yes.
#
# Related:
#
Expand Down Expand Up @@ -87,9 +87,9 @@ class Net::HTTP::Head < Net::HTTPRequest
#
# - Request body: yes.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: no.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: yes.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: no.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: yes.
#
# Related:
#
Expand Down Expand Up @@ -123,9 +123,9 @@ class Net::HTTP::Post < Net::HTTPRequest
#
# - Request body: yes.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
Expand Down Expand Up @@ -157,9 +157,9 @@ class Net::HTTP::Put < Net::HTTPRequest
#
# - Request body: optional.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
Expand Down Expand Up @@ -189,9 +189,9 @@ class Net::HTTP::Delete < Net::HTTPRequest
#
# - Request body: optional.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
Expand Down Expand Up @@ -221,9 +221,9 @@ class Net::HTTP::Options < Net::HTTPRequest
#
# - Request body: no.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: yes.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: yes.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
Expand Down Expand Up @@ -256,9 +256,9 @@ class Net::HTTP::Trace < Net::HTTPRequest
#
# - Request body: yes.
# - Response body: yes.
# - {Safe}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods]: no.
# - {Cacheable}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Cacheable_methods]: no.
# - {Safe}[https://en.wikipedia.org/wiki/HTTP#Safe_method]: no.
# - {Idempotent}[https://en.wikipedia.org/wiki/HTTP#Idempotent_method]: no.
# - {Cacheable}[https://en.wikipedia.org/wiki/HTTP#Cacheable_method]: no.
#
# Related:
#
Expand Down
15 changes: 9 additions & 6 deletions lib/open-uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@
require 'time'

module URI
# Allows the opening of various resources including URIs.
# Allows the opening of various resources including URIs. Example:
#
# If the first argument responds to the 'open' method, 'open' is called on
# require "open-uri"
# URI.open("http://example.com") { |f| f.read }
#
# If the first argument responds to the +open+ method, +open+ is called on
# it with the rest of the arguments.
#
# If the first argument is a string that begins with <code>(protocol)://</code>, it is parsed by
# URI.parse. If the parsed object responds to the 'open' method,
# 'open' is called on it with the rest of the arguments.
# URI.parse. If the parsed object responds to the +open+ method,
# +open+ is called on it with the rest of the arguments.
#
# Otherwise, Kernel#open is called.
#
# OpenURI::OpenRead#open provides URI::HTTP#open, URI::HTTPS#open and
# URI::FTP#open, Kernel#open.
#
# We can accept URIs and strings that begin with http://, https:// and
# ftp://. In these cases, the opened file object is extended by OpenURI::Meta.
# We can accept URIs and strings that begin with <code>http://</code>, <code>https://</code> and
# <code>ftp://</code>. In these cases, the opened file object is extended by OpenURI::Meta.
def self.open(name, *rest, &block)
if name.respond_to?(:open)
name.open(*rest, &block)
Expand Down
24 changes: 20 additions & 4 deletions lib/prism/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,26 @@ def dump_options_command_line(options)

# Return the value that should be dumped for the version option.
def dump_options_version(version)
current = version == "current"
checking =
case version
when "current"
RUBY_VERSION
when "latest"
nil
when "nearest"
if RUBY_VERSION <= "3.3"
"3.3"
elsif RUBY_VERSION >= "4.1"
"4.1"
else
RUBY_VERSION
end
else
version
end

case current ? RUBY_VERSION : version
when nil, "latest"
case checking
when nil
0 # Handled in pm_parser_init
when /\A3\.3(\.\d+)?\z/
1
Expand All @@ -437,7 +453,7 @@ def dump_options_version(version)
when /\A4\.1(\.\d+)?\z/
4
else
if current
if version == "current"
raise CurrentVersionError, RUBY_VERSION
else
raise ArgumentError, "invalid version: #{version}"
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/remote_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def download(spec, source_uri, install_dir = Gem.dir)
end

verbose "Using local gem #{local_gem_path}"
when nil then # TODO: test for local overriding cache
when nil then
source_path = if Gem.win_platform? && source_uri.scheme &&
!source_uri.path.include?(":")
"#{source_uri.scheme}:#{source_uri.path}"
Expand Down
27 changes: 22 additions & 5 deletions prism/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,24 @@ build_options_i(VALUE key, VALUE value, VALUE argument) {
const char *version = check_string(value);

if (RSTRING_LEN(value) == 7 && strncmp(version, "current", 7) == 0) {
const char *current_version = RSTRING_PTR(rb_const_get(rb_cObject, rb_intern("RUBY_VERSION")));
if (!pm_options_version_set(options, current_version, 3)) {
rb_exc_raise(rb_exc_new_cstr(rb_cPrismCurrentVersionError, current_version));
const char *ruby_version = RSTRING_PTR(rb_const_get(rb_cObject, rb_intern("RUBY_VERSION")));
if (!pm_options_version_set(options, ruby_version, 3)) {
rb_exc_raise(rb_exc_new_cstr(rb_cPrismCurrentVersionError, ruby_version));
}
} else if (RSTRING_LEN(value) == 7 && strncmp(version, "nearest", 7) == 0) {
const char *ruby_version = RSTRING_PTR(rb_const_get(rb_cObject, rb_intern("RUBY_VERSION")));
const char *nearest_version;

if (ruby_version[0] < '3' || (ruby_version[0] == '3' && ruby_version[2] < '3')) {
nearest_version = "3.3";
} else if (ruby_version[0] > '4' || (ruby_version[0] == '4' && ruby_version[2] > '1')) {
nearest_version = "4.1";
} else {
nearest_version = ruby_version;
}

if (!pm_options_version_set(options, nearest_version, 3)) {
rb_raise(rb_eArgError, "invalid nearest version: %s", nearest_version);
}
} else if (!pm_options_version_set(options, version, RSTRING_LEN(value))) {
rb_raise(rb_eArgError, "invalid version: %" PRIsVALUE, value);
Expand Down Expand Up @@ -894,8 +909,10 @@ parse_input(pm_string_t *input, const pm_options_t *options) {
* version of Ruby syntax (which you can trigger with `nil` or
* `"latest"`). You may also restrict the syntax to a specific version of
* Ruby, e.g., with `"3.3.0"`. To parse with the same syntax version that
* the current Ruby is running use `version: "current"`. Raises
* ArgumentError if the version is not currently supported by Prism.
* the current Ruby is running use `version: "current"`. To parse with the
* nearest version to the current Ruby that is running, use
* `version: "nearest"`. Raises ArgumentError if the version is not
* currently supported by Prism.
*/
static VALUE
parse(int argc, VALUE *argv, VALUE self) {
Expand Down
8 changes: 7 additions & 1 deletion prism/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ typedef void (*pm_options_shebang_callback_t)(struct pm_options *options, const
* parse in the same way as a specific version of CRuby would have.
*/
typedef enum {
/** If an explicit version is not provided, the current version of prism will be used. */
/**
* If an explicit version is not provided, the current version of prism will
* be used.
*/
PM_OPTIONS_VERSION_UNSET = 0,

/** The vendored version of prism in CRuby 3.3.x. */
Expand Down Expand Up @@ -452,6 +455,9 @@ PRISM_EXPORTED_FUNCTION void pm_options_free(pm_options_t *options);
* | ----- | ------------------------- |
* | `0` | use the latest version of prism |
* | `1` | use the version of prism that is vendored in CRuby 3.3.0 |
* | `2` | use the version of prism that is vendored in CRuby 3.4.0 |
* | `3` | use the version of prism that is vendored in CRuby 4.0.0 |
* | `4` | use the version of prism that is vendored in CRuby 4.1.0 |
*
* Each scope is laid out as follows:
*
Expand Down
41 changes: 41 additions & 0 deletions spec/bundler/install/gemfile/sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1195,4 +1195,45 @@
expect(gem_section).not_to include("activerecord (7.0.0)")
end
end

context "when a scoped rubygems source is missing a transitive dependency" do
before do
build_repo2 do
build_gem "fallback_dep", "1.0.0"
build_gem "foo", "1.0.0"
end

build_repo3 do
build_gem "private_parent", "1.0.0" do |s|
s.add_dependency "fallback_dep"
end
end

gemfile <<-G
source "https://gem.repo2"

gem "foo"

source "https://gem.repo3" do
gem "private_parent", "1.0.0"
end
G

bundle :install, artifice: "compact_index"
end

it "falls back to the default rubygems source for that dependency" do
build_repo2 do
build_gem "foo", "2.0.0"
end

system_gems []

bundle "update foo", artifice: "compact_index"

expect(the_bundle).to include_gems("private_parent 1.0.0", "fallback_dep 1.0.0", "foo 2.0.0")
expect(the_bundle).to include_gems("private_parent 1.0.0", source: "remote3")
expect(the_bundle).to include_gems("fallback_dep 1.0.0", source: "remote2")
end
end
end
6 changes: 3 additions & 3 deletions spec/mspec/tool/sync/sync-rubyspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,20 @@ def test_new_specs
Dir.chdir(SOURCE_REPO) do
workflow = YAML.load_file(".github/workflows/ci.yml")
job_name = MSPEC ? "test" : "specs"
versions = workflow.dig("jobs", job_name, "strategy", "matrix", "ruby")
versions = workflow.dig("jobs", job_name, "strategy", "matrix", "ruby").map(&:to_s)
versions = versions.grep(/^\d+\./) # Test on MRI
min_version, max_version = versions.minmax

test_command = MSPEC ? "bundle install && bundle exec rspec" : "../mspec/bin/mspec -j"

run_test = -> version {
command = "chruby #{version} && #{test_command}"
command = "chruby ruby-#{version} && #{test_command}"
sh ENV["SHELL"], "-c", command
}

run_test[min_version]
run_test[max_version]
run_test["ruby-master"] if TEST_MASTER
run_test["master"] if TEST_MASTER
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/mspec/tool/tag_from_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

NUMBER = /^\d+\)$/
ERROR_OR_FAILED = / (ERROR|FAILED)$/
SPEC_FILE = /^(\/.+_spec\.rb)\:\d+/
SPEC_FILE = /^((?:\/|[CD]:\/).+_spec\.rb)\:\d+/

output.slice_before(NUMBER).select { |number, *rest|
number =~ NUMBER and rest.any? { |line| line =~ ERROR_OR_FAILED }
Expand Down
1 change: 1 addition & 0 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ For older specs try these commits:
* Ruby 2.7.8 - [Suite](https://github.com/ruby/spec/commit/93787e6035c925b593a9c0c6fb0e7e07a6f1df1f) using [MSpec](https://github.com/ruby/mspec/commit/1d8cf64722d8a7529f7cd205be5f16a89b7a67fd)
* Ruby 3.0.7 - [Suite](https://github.com/ruby/spec/commit/affef93d9940f615e4836f64b011da211f570913) using [MSpec](https://github.com/ruby/mspec/commit/0aabb3e548eb5ea6cad0125f8f46cee34542b6b7)
* Ruby 3.1.6 - [Suite](https://github.com/ruby/spec/commit/ec960f2389d1c2265d32397fa8afa6d462014efc) using [MSpec](https://github.com/ruby/mspec/commit/484310dbed35b84c74484fd674602f88c42d063a)
* Ruby 3.2.9 - [Suite](https://github.com/ruby/spec/commit/97f076242b7fc6e60703e6a6053365065cd6fc30) using [MSpec](https://github.com/ruby/mspec/commit/54704795e21128a930af2021c72c49cb87065134)

### Running the specs

Expand Down
5 changes: 1 addition & 4 deletions spec/ruby/command_line/dash_r_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), options: "-r #{@test_file}", args: "2>&1", exit_status: 1)
$?.should_not.success?
out.should include("REQUIRED")

# it's tempting not to rely on error message and rely only on exception class name,
# but CRuby before 3.2 doesn't print class name for syntax error
out.should include_any_of("syntax error", "SyntaxError")
out.should include("SyntaxError")
end

it "does not require the file if the main script file does not exist" do
Expand Down
10 changes: 2 additions & 8 deletions spec/ruby/command_line/syntax_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
describe "The interpreter" do
it "prints an error when given a file with invalid syntax" do
out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), args: "2>&1", exit_status: 1)

# it's tempting not to rely on error message and rely only on exception class name,
# but CRuby before 3.2 doesn't print class name for syntax error
out.should include_any_of("syntax error", "SyntaxError")
out.should.include?("SyntaxError")
end

it "prints an error when given code via -e with invalid syntax" do
out = ruby_exe(nil, args: "-e 'a{' 2>&1", exit_status: 1)

# it's tempting not to rely on error message and rely only on exception class name,
# but CRuby before 3.2 doesn't print class name for syntax error
out.should include_any_of("syntax error", "SyntaxError")
out.should.include?("SyntaxError")
end
end
Loading