summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/check_misc.yml6
-rw-r--r--.github/workflows/dependabot_automerge.yml2
-rw-r--r--compile.c3
-rw-r--r--ext/json/lib/json/common.rb2
-rw-r--r--ext/win32/lib/win32/registry.rb6
-rw-r--r--gc.c1
-rw-r--r--hash.c1
-rw-r--r--io_buffer.c25
-rw-r--r--lib/rubygems/request_set.rb9
-rw-r--r--lib/tempfile.rb2
-rw-r--r--proc.c3
-rw-r--r--re.c3
-rw-r--r--spec/bundler/commands/newgem_spec.rb18
-rw-r--r--spec/bundler/install/gems/mirror_probe_spec.rb49
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb2
-rw-r--r--spec/bundler/runtime/setup_spec.rb1
-rw-r--r--test/ruby/test_io_buffer.rb13
-rw-r--r--test/rubygems/helper.rb8
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb27
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb58
-rw-r--r--test/rubygems/test_gem_installer.rb50
-rw-r--r--thread.c3
-rwxr-xr-x[-rw-r--r--]tool/auto-style.rb21
-rw-r--r--variable.c30
-rw-r--r--vm.c3
25 files changed, 193 insertions, 153 deletions
diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml
index 543c54a3c9..2d73e1771a 100644
--- a/.github/workflows/check_misc.yml
+++ b/.github/workflows/check_misc.yml
@@ -37,10 +37,10 @@ jobs:
GIT_AUTHOR_NAME: git
GIT_COMMITTER_NAME: git
- GITHUB_OLD_SHA: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.base.sha || github.event.before }}
- GITHUB_NEW_SHA: ${{ startsWith(github.event_name, 'pull') && github.event.pull_request.merge_commit_sha || github.event.after }}
+ GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }}
+ GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }}
PUSH_REF: ${{ github.ref == 'refs/heads/master' && github.ref || '' }}
- if: ${{ github.repository == 'ruby/ruby' }}
+ if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }}
- name: Check if C-sources are US-ASCII
run: |
diff --git a/.github/workflows/dependabot_automerge.yml b/.github/workflows/dependabot_automerge.yml
index b1293deb62..dd1f1bcdaa 100644
--- a/.github/workflows/dependabot_automerge.yml
+++ b/.github/workflows/dependabot_automerge.yml
@@ -19,7 +19,7 @@ jobs:
- name: Wait for status checks
uses: lewagon/wait-on-check-action@ccfb013c15c8afb7bf2b7c028fb74dc5a068cccc # v1.3.4
with:
- repo-token: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
check-regexp: 'make \(check, .*\)'
wait-interval: 30
diff --git a/compile.c b/compile.c
index cbde124516..6bcfcd3398 100644
--- a/compile.c
+++ b/compile.c
@@ -13384,7 +13384,8 @@ outer_variable_cmp(const void *a, const void *b, void *arg)
if (!ap->name) {
return -1;
- } else if (!bp->name) {
+ }
+ else if (!bp->name) {
return 1;
}
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index 6393a6df55..486ec62a58 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -268,7 +268,7 @@ module JSON
# to string interpolation.
#
# Note: no validation is performed on the provided string. It is the
- # responsability of the caller to ensure the string contains valid JSON.
+ # responsibility of the caller to ensure the string contains valid JSON.
Fragment = Struct.new(:json) do
def initialize(json)
unless string = String.try_convert(json)
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index d0cbb6afcf..8e2c8b2e1a 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -372,7 +372,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
# Replace %\w+% into the environment value of what is contained between the %'s
# This method is used for REG_EXPAND_SZ.
#
- # For detail, see expandEnvironmentStrings[http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp] \Win32 \API.
+ # For detail, see expandEnvironmentStrings[https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-expandenvironmentstringsa] \Win32 \API.
#
def self.expand_environ(str)
str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) {
@@ -487,7 +487,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
end
- # Win32::Registry object of parent key, or nil if predefeined key.
+ # Win32::Registry object of parent key, or nil if predefined key.
attr_reader :parent
# Same as subkey value of Registry.open or
# Registry.create method.
@@ -571,7 +571,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
# For each value it yields key, type and data.
#
# key is a String which contains name of key.
- # type is a type contant kind of Win32::Registry::REG_*
+ # type is a type constant kind of Win32::Registry::REG_*
# data is the value of this key.
#
def each_value
diff --git a/gc.c b/gc.c
index e920348a12..f0189294bd 100644
--- a/gc.c
+++ b/gc.c
@@ -3060,7 +3060,6 @@ rb_gc_mark_roots(void *objspace, const char **categoryp)
MARK_CHECKPOINT("vm");
rb_vm_mark(vm);
- if (vm->self) gc_mark_internal(vm->self);
MARK_CHECKPOINT("end_proc");
rb_mark_end_proc();
diff --git a/hash.c b/hash.c
index be26e0eb3f..379dac814b 100644
--- a/hash.c
+++ b/hash.c
@@ -3872,7 +3872,6 @@ rb_hash_values(VALUE hash)
}
rb_ary_set_len(values, size);
}
-
else {
rb_hash_foreach(hash, values_i, values);
}
diff --git a/io_buffer.c b/io_buffer.c
index 190b67d8ac..96f13c364a 100644
--- a/io_buffer.c
+++ b/io_buffer.c
@@ -273,6 +273,21 @@ io_buffer_free(struct rb_io_buffer *buffer)
}
static void
+rb_io_buffer_type_mark_and_move(void *_buffer)
+{
+ struct rb_io_buffer *buffer = _buffer;
+ if (buffer->source != Qnil) {
+ if (RB_TYPE_P(buffer->source, T_STRING)) {
+ // The `source` String has to be pinned, because the `base` may point to the embedded String content,
+ // which can be otherwise moved by GC compaction.
+ rb_gc_mark(buffer->source);
+ } else {
+ rb_gc_mark_and_move(&buffer->source);
+ }
+ }
+}
+
+static void
rb_io_buffer_type_free(void *_buffer)
{
struct rb_io_buffer *buffer = _buffer;
@@ -293,20 +308,16 @@ rb_io_buffer_type_size(const void *_buffer)
return total;
}
-RUBY_REFERENCES(io_buffer_refs) = {
- RUBY_REF_EDGE(struct rb_io_buffer, source),
- RUBY_REF_END
-};
-
static const rb_data_type_t rb_io_buffer_type = {
.wrap_struct_name = "IO::Buffer",
.function = {
- .dmark = RUBY_REFS_LIST_PTR(io_buffer_refs),
+ .dmark = rb_io_buffer_type_mark_and_move,
.dfree = rb_io_buffer_type_free,
.dsize = rb_io_buffer_type_size,
+ .dcompact = rb_io_buffer_type_mark_and_move,
},
.data = NULL,
- .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE | RUBY_TYPED_DECL_MARKING,
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
};
static inline enum rb_io_buffer_flags
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index 875df7e019..5a855fdb10 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -181,13 +181,10 @@ class Gem::RequestSet
# Install requested gems after they have been downloaded
sorted_requests.each do |req|
- if req.installed?
+ if req.installed? && @always_install.none? {|spec| spec == req.spec.spec }
req.spec.spec.build_extensions
-
- if @always_install.none? {|spec| spec == req.spec.spec }
- yield req, nil if block_given?
- next
- end
+ yield req, nil if block_given?
+ next
end
spec =
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index f3213c5684..7292e72c25 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -29,7 +29,7 @@ require 'tmpdir'
# require 'tempfile'
#
# # Tempfile.create with a block
-# # The filename are choosen automatically.
+# # The filename are chosen automatically.
# # (You can specify the prefix and suffix of the filename by an optional argument.)
# Tempfile.create {|f|
# f.puts "foo"
diff --git a/proc.c b/proc.c
index 98aa10d59f..8543110476 100644
--- a/proc.c
+++ b/proc.c
@@ -1562,7 +1562,8 @@ rb_sym_to_proc(VALUE sym)
RARRAY_ASET(sym_proc_cache, index, procval);
return RB_GC_GUARD(procval);
- } else {
+ }
+ else {
return sym_proc_new(rb_cProc, sym);
}
}
diff --git a/re.c b/re.c
index e666a7c3d4..b47538d594 100644
--- a/re.c
+++ b/re.c
@@ -3507,7 +3507,8 @@ rb_reg_regcomp(VALUE str)
return reg_cache;
return reg_cache = rb_reg_new_str(str, 0);
- } else {
+ }
+ else {
return rb_reg_new_str(str, 0);
}
}
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index dd2aa5c8c4..30655656a8 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -386,7 +386,6 @@ RSpec.describe "bundle gem" do
it "has no rubocop offenses when using --ext=rust and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
- skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version
bundle "gem #{gem_name} --ext=rust --linter=rubocop"
bundle_exec_rubocop
@@ -395,7 +394,6 @@ RSpec.describe "bundle gem" do
it "has no rubocop offenses when using --ext=rust, --test=minitest, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
- skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version
bundle "gem #{gem_name} --ext=rust --test=minitest --linter=rubocop"
bundle_exec_rubocop
@@ -404,7 +402,6 @@ RSpec.describe "bundle gem" do
it "has no rubocop offenses when using --ext=rust, --test=rspec, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
- skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version
bundle "gem #{gem_name} --ext=rust --test=rspec --linter=rubocop"
bundle_exec_rubocop
@@ -413,7 +410,6 @@ RSpec.describe "bundle gem" do
it "has no rubocop offenses when using --ext=rust, --test=test-unit, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
- skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version
bundle "gem #{gem_name} --ext=rust --test=test-unit --linter=rubocop"
bundle_exec_rubocop
@@ -1724,24 +1720,10 @@ RSpec.describe "bundle gem" do
end
end
- context "--ext parameter set with rust and old RubyGems" do
- it "fails in friendly way" do
- if ::Gem::Version.new("3.3.11") <= ::Gem.rubygems_version
- skip "RubyGems compatible with Rust builder"
- end
-
- expect do
- bundle ["gem", gem_name, "--ext=rust"].compact.join(" ")
- end.to raise_error(RuntimeError, /too old to build Rust extension/)
- end
- end
-
context "--ext parameter set with rust" do
let(:flags) { "--ext=rust" }
before do
- skip "RubyGems incompatible with Rust builder" if ::Gem::Version.new("3.3.11") > ::Gem.rubygems_version
-
bundle ["gem", gem_name, flags].compact.join(" ")
end
diff --git a/spec/bundler/install/gems/mirror_probe_spec.rb b/spec/bundler/install/gems/mirror_probe_spec.rb
index 5edd829e7b..fe9654e0a9 100644
--- a/spec/bundler/install/gems/mirror_probe_spec.rb
+++ b/spec/bundler/install/gems/mirror_probe_spec.rb
@@ -1,9 +1,6 @@
# frozen_string_literal: true
RSpec.describe "fetching dependencies with a not available mirror" do
- let(:mirror) { @mirror_uri }
- let(:original) { @server_uri }
- let(:server_port) { @server_port }
let(:host) { "127.0.0.1" }
before do
@@ -20,13 +17,13 @@ RSpec.describe "fetching dependencies with a not available mirror" do
context "with a specific fallback timeout" do
before do
- global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/__FALLBACK_TIMEOUT/" => "true",
- "BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror)
+ global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/__FALLBACK_TIMEOUT/" => "true",
+ "BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri)
end
it "install a gem using the original uri when the mirror is not responding" do
gemfile <<-G
- source "#{original}"
+ source "#{@server_uri}"
gem 'weakling'
G
@@ -41,12 +38,12 @@ RSpec.describe "fetching dependencies with a not available mirror" do
context "with a global fallback timeout" do
before do
global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1",
- "BUNDLE_MIRROR__ALL" => mirror)
+ "BUNDLE_MIRROR__ALL" => @mirror_uri)
end
it "install a gem using the original uri when the mirror is not responding" do
gemfile <<-G
- source "#{original}"
+ source "#{@server_uri}"
gem 'weakling'
G
@@ -60,47 +57,47 @@ RSpec.describe "fetching dependencies with a not available mirror" do
context "with a specific mirror without a fallback timeout" do
before do
- global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror)
+ global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri)
end
- it "fails to install the gem with a timeout error" do
+ it "fails to install the gem with a timeout error when the mirror is not responding" do
gemfile <<-G
- source "#{original}"
+ source "#{@server_uri}"
gem 'weakling'
G
bundle :install, artifice: nil, raise_on_error: false
- expect(out).to include("Fetching source index from #{mirror}")
+ expect(out).to include("Fetching source index from #{@mirror_uri}")
err_lines = err.split("\n")
- expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
- expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
- expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
- expect(err_lines).to include(%r{\ACould not fetch specs from #{mirror}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ACould not fetch specs from #{@mirror_uri}/ due to underlying error <})
end
end
context "with a global mirror without a fallback timeout" do
before do
- global_config("BUNDLE_MIRROR__ALL" => mirror)
+ global_config("BUNDLE_MIRROR__ALL" => @mirror_uri)
end
- it "fails to install the gem with a timeout error" do
+ it "fails to install the gem with a timeout error when the mirror is not responding" do
gemfile <<-G
- source "#{original}"
+ source "#{@server_uri}"
gem 'weakling'
G
bundle :install, artifice: nil, raise_on_error: false
- expect(out).to include("Fetching source index from #{mirror}")
+ expect(out).to include("Fetching source index from #{@mirror_uri}")
err_lines = err.split("\n")
- expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
- expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
- expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
- expect(err_lines).to include(%r{\ACould not fetch specs from #{mirror}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
+ expect(err_lines).to include(%r{\ACould not fetch specs from #{@mirror_uri}/ due to underlying error <})
end
end
@@ -108,13 +105,13 @@ RSpec.describe "fetching dependencies with a not available mirror" do
@server_port = find_unused_port
@server_uri = "http://#{host}:#{@server_port}"
- require_relative "../../support/artifice/endpoint"
+ require_relative "../../support/artifice/compact_index"
require_relative "../../support/silent_logger"
require "rackup/server"
@server_thread = Thread.new do
- Rackup::Server.start(app: Endpoint,
+ Rackup::Server.start(app: CompactIndexAPI,
Host: host,
Port: @server_port,
server: "webrick",
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index 50ef4dc3a7..7ad657a738 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -147,7 +147,6 @@ RSpec.shared_examples "bundle install --standalone" do
it "works and points to the vendored copies, not to the default copies" do
necessary_gems_in_bundle_path = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.4.3", "stringio --version 3.1.0"]
- necessary_gems_in_bundle_path += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a")
realworld_system_gems(*necessary_gems_in_bundle_path, path: scoped_gem_path(bundled_app("bundle")))
build_gem "foo", "1.0.0", to_system: true, default: true do |s|
@@ -186,7 +185,6 @@ RSpec.shared_examples "bundle install --standalone" do
it "works for gems with extensions and points to the vendored copies, not to the default copies" do
simulate_platform "arm64-darwin-23" do
necessary_gems_in_bundle_path = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.4.3", "stringio --version 3.1.0", "shellwords --version 0.2.0", "open3 --version 0.2.1"]
- necessary_gems_in_bundle_path += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a")
realworld_system_gems(*necessary_gems_in_bundle_path, path: scoped_gem_path(bundled_app("bundle")))
build_gem "baz", "1.0.0", to_system: true, default: true, &:add_c_extension
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index e47e64de29..b9b78cb044 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -1406,7 +1406,6 @@ end
describe "default gem activation" do
let(:exemptions) do
exempts = %w[did_you_mean bundler uri pathname]
- exempts << "etc" if (Gem.ruby_version < Gem::Version.new("3.2") || Gem.ruby_version >= Gem::Version.new("3.3.2")) && Gem.win_platform?
exempts << "error_highlight" # added in Ruby 3.1 as a default gem
exempts << "ruby2_keywords" # added in Ruby 3.1 as a default gem
exempts << "syntax_suggest" # added in Ruby 3.2 as a default gem
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb
index 70c5ef061d..62c4667888 100644
--- a/test/ruby/test_io_buffer.rb
+++ b/test/ruby/test_io_buffer.rb
@@ -693,4 +693,17 @@ class TestIOBuffer < Test::Unit::TestCase
buf.set_string('a', 0, 0)
assert_predicate buf, :empty?
end
+
+ # https://bugs.ruby-lang.org/issues/21210
+ def test_bug_21210
+ omit "compaction is not supported on this platform" unless GC.respond_to?(:compact)
+
+ str = +"hello"
+ buf = IO::Buffer.for(str)
+ assert_predicate buf, :valid?
+
+ GC.verify_compaction_references(expand_heap: true, toward: :empty)
+
+ assert_predicate buf, :valid?
+ end
end
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index d847d3b35e..af78bab724 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -683,6 +683,14 @@ class Gem::TestCase < Test::Unit::TestCase
path
end
+ def write_dummy_extconf(gem_name)
+ write_file File.join(@tempdir, "extconf.rb") do |io|
+ io.puts "require 'mkmf'"
+ yield io if block_given?
+ io.puts "create_makefile '#{gem_name}'"
+ end
+ end
+
##
# Load a YAML string, the psych 3 way
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index 77525aed2c..d05cfef653 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -647,17 +647,10 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = %w[a]
use_ui @ui do
- # Don't use Dir.chdir with a block, it warnings a lot because
- # of a downstream Dir.chdir with a block
- old = Dir.getwd
-
- begin
- Dir.chdir @tempdir
+ Dir.chdir @tempdir do
assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- ensure
- Dir.chdir old
end
end
@@ -684,17 +677,10 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = %w[a]
use_ui @ui do
- # Don't use Dir.chdir with a block, it warnings a lot because
- # of a downstream Dir.chdir with a block
- old = Dir.getwd
-
- begin
- Dir.chdir @tempdir
+ Dir.chdir @tempdir do
assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- ensure
- Dir.chdir old
end
end
@@ -720,17 +706,10 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = %w[a]
use_ui @ui do
- # Don't use Dir.chdir with a block, it warnings a lot because
- # of a downstream Dir.chdir with a block
- old = Dir.getwd
-
- begin
- Dir.chdir @tempdir
+ Dir.chdir @tempdir do
assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
- ensure
- Dir.chdir old
end
end
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index 56b84160c4..f84881579a 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -382,13 +382,9 @@ class TestGemDependencyInstaller < Gem::TestCase
FileUtils.mv f1_gem, @tempdir
inst = nil
- pwd = Dir.getwd
- Dir.chdir @tempdir
- begin
+ Dir.chdir @tempdir do
inst = Gem::DependencyInstaller.new
inst.install "f"
- ensure
- Dir.chdir pwd
end
assert_equal %w[f-1], inst.installed_gems.map(&:full_name)
@@ -523,6 +519,58 @@ class TestGemDependencyInstaller < Gem::TestCase
assert_equal %w[a-1], inst.installed_gems.map(&:full_name)
end
+ def test_install_local_with_extensions_already_installed
+ pend "needs investigation" if Gem.java_platform?
+ pend "ruby.h is not provided by ruby repo" if ruby_repo?
+
+ @spec = quick_gem "a" do |s|
+ s.extensions << "extconf.rb"
+ s.files += %w[extconf.rb a.c]
+ end
+
+ write_dummy_extconf "a"
+
+ c_source_path = File.join(@tempdir, "a.c")
+
+ write_file c_source_path do |io|
+ io.write <<-C
+ #include <ruby.h>
+ void Init_a() { }
+ C
+ end
+
+ package_path = Gem::Package.build @spec
+ installer = Gem::Installer.at(package_path)
+
+ # Make sure the gem is installed and backup the correct package
+
+ installer.install
+
+ package_bkp_path = "#{package_path}.bkp"
+ FileUtils.cp package_path, package_bkp_path
+
+ # Break the extension, rebuild it, and try to install it
+
+ write_file c_source_path do |io|
+ io.write "typo"
+ end
+
+ Gem::Package.build @spec
+
+ assert_raise Gem::Ext::BuildError do
+ installer.install
+ end
+
+ # Make sure installing the good package again still works
+
+ FileUtils.cp "#{package_path}.bkp", package_path
+
+ Dir.chdir @tempdir do
+ inst = Gem::DependencyInstaller.new domain: :local
+ inst.install package_path
+ end
+ end
+
def test_install_minimal_deps
util_setup_gems
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index dfa8df283c..6d8a523507 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -1478,12 +1478,7 @@ end
@spec = setup_base_spec
@spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
- io.write <<-RUBY
- require "mkmf"
- create_makefile("#{@spec.name}")
- RUBY
- end
+ write_dummy_extconf @spec.name
@spec.files += %w[extconf.rb]
@@ -1503,12 +1498,7 @@ end
@spec = setup_base_spec
@spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
- io.write <<-RUBY
- require "mkmf"
- create_makefile("#{@spec.name}")
- RUBY
- end
+ write_dummy_extconf @spec.name
@spec.files += %w[extconf.rb]
@@ -1539,12 +1529,7 @@ end
def test_install_user_extension_dir
@spec = setup_base_spec
@spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
- io.write <<-RUBY
- require "mkmf"
- create_makefile("#{@spec.name}")
- RUBY
- end
+ write_dummy_extconf @spec.name
@spec.files += %w[extconf.rb]
@@ -1571,15 +1556,13 @@ end
@spec = setup_base_spec
@spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
+ write_dummy_extconf @spec.name do |io|
io.write <<-RUBY
- require "mkmf"
CONFIG['CC'] = '$(TOUCH) $@ ||'
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
$ruby = '#{Gem.ruby}'
- create_makefile("#{@spec.name}")
RUBY
end
@@ -1618,12 +1601,7 @@ end
@spec = setup_base_spec
@spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
- io.write <<-RUBY
- require "mkmf"
- create_makefile("#{@spec.name}")
- RUBY
- end
+ write_dummy_extconf @spec.name
rb = File.join("lib", "#{@spec.name}.rb")
@spec.files += [rb]
@@ -1663,15 +1641,13 @@ end
@spec.extensions << "extconf.rb"
- write_file File.join(@tempdir, "extconf.rb") do |io|
+ write_dummy_extconf @spec.name do |io|
io.write <<-RUBY
- require "mkmf"
CONFIG['CC'] = '$(TOUCH) $@ ||'
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
$ruby = '#{Gem.ruby}'
- create_makefile("#{@spec.name}")
RUBY
end
@@ -1698,13 +1674,13 @@ end
@spec.require_paths = ["."]
@spec.extensions << "extconf.rb"
- File.write File.join(@tempdir, "extconf.rb"), <<-RUBY
- require "mkmf"
- CONFIG['CC'] = '$(TOUCH) $@ ||'
- CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
- $ruby = '#{Gem.ruby}'
- create_makefile("#{@spec.name}")
- RUBY
+ write_dummy_extconf @spec.name do |io|
+ io.write <<~RUBY
+ CONFIG['CC'] = '$(TOUCH) $@ ||'
+ CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
+ $ruby = '#{Gem.ruby}'
+ RUBY
+ end
# empty depend file for no auto dependencies
@spec.files += %W[depend #{@spec.name}.c].each do |file|
diff --git a/thread.c b/thread.c
index 41bd6c9ec6..5575157728 100644
--- a/thread.c
+++ b/thread.c
@@ -6229,7 +6229,8 @@ threadptr_interrupt_exec_exec(rb_thread_t *th)
if (task) {
if (task->flags & rb_interrupt_exec_flag_new_thread) {
rb_thread_create(task->func, task->data);
- } else {
+ }
+ else {
(*task->func)(task->data);
}
ruby_xfree(task);
diff --git a/tool/auto-style.rb b/tool/auto-style.rb
index d2b007bd51..25055ace7d 100644..100755
--- a/tool/auto-style.rb
+++ b/tool/auto-style.rb
@@ -69,7 +69,7 @@ class Git
def git(*args)
cmd = ['git', *args].shelljoin
puts "+ #{cmd}"
- unless with_clean_env { system(cmd) }
+ unless with_clean_env { system('git', *args) }
abort "Failed to run: #{cmd}"
end
end
@@ -173,6 +173,10 @@ IGNORED_FILES = [
%r{\Asample/trick[^/]*/},
]
+DIFFERENT_STYLE_FILES = %w[
+ addr2line.c io_buffer.c prism*.c scheduler.c
+]
+
oldrev, newrev, pushref = ARGV
unless dry_run = pushref.empty?
branch = IO.popen(['git', 'rev-parse', '--symbolic', '--abbrev-ref', pushref], &:read).strip
@@ -194,7 +198,7 @@ if files.empty?
exit
end
-trailing = eofnewline = expandtab = false
+trailing = eofnewline = expandtab = indent = false
edited_files = files.select do |f|
src = File.binread(f) rescue next
@@ -202,6 +206,8 @@ edited_files = files.select do |f|
trailing0 = false
expandtab0 = false
+ indent0 = false
+
src.gsub!(/^.*$/).with_index do |line, lineno|
trailing = trailing0 = true if line.sub!(/[ \t]+$/, '')
line
@@ -225,7 +231,15 @@ edited_files = files.select do |f|
end
end
- if trailing0 or eofnewline0 or expandtab0
+ if File.fnmatch?("*.[ch]", f, File::FNM_PATHNAME) &&
+ !DIFFERENT_STYLE_FILES.any? {|pat| File.fnmatch?(pat, f, File::FNM_PATHNAME)}
+ src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n")
+ src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1')
+ src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '')
+ indent = indent0 = true
+ end
+
+ if trailing0 or eofnewline0 or expandtab0 or indent0
File.binwrite(f, src)
true
end
@@ -236,6 +250,7 @@ else
msg = [('remove trailing spaces' if trailing),
('append newline at EOF' if eofnewline),
('expand tabs' if expandtab),
+ ('adjust indents' if indent),
].compact
message = "* #{msg.join(', ')}. [ci skip]"
if expandtab
diff --git a/variable.c b/variable.c
index 6bd9f69d06..a2f8c17b47 100644
--- a/variable.c
+++ b/variable.c
@@ -1227,12 +1227,6 @@ gen_fields_tbl_bytes(size_t n)
return offsetof(struct gen_fields_tbl, as.shape.fields) + n * sizeof(VALUE);
}
-static struct gen_fields_tbl *
-gen_fields_tbl_resize(struct gen_fields_tbl *old, uint32_t new_capa)
-{
- RUBY_ASSERT(new_capa > 0);
- return xrealloc(old, gen_fields_tbl_bytes(new_capa));
-}
void
rb_mark_generic_ivar(VALUE obj)
@@ -1837,13 +1831,29 @@ generic_ivar_set_shape_fields(VALUE obj, void *data)
int existing = st_lookup(tbl, (st_data_t)obj, (st_data_t *)&fields_tbl);
if (!existing || fields_lookup->resize) {
+ uint32_t new_capa = RSHAPE_CAPACITY(fields_lookup->shape_id);
+ uint32_t old_capa = RSHAPE_CAPACITY(RSHAPE_PARENT(fields_lookup->shape_id));
+
if (existing) {
RUBY_ASSERT(RSHAPE_TYPE_P(fields_lookup->shape_id, SHAPE_IVAR) || RSHAPE_TYPE_P(fields_lookup->shape_id, SHAPE_OBJ_ID));
- RUBY_ASSERT(RSHAPE_CAPACITY(RSHAPE_PARENT(fields_lookup->shape_id)) < RSHAPE_CAPACITY(fields_lookup->shape_id));
+ RUBY_ASSERT(old_capa < new_capa);
+ RUBY_ASSERT(fields_tbl);
+ }
+ else {
+ RUBY_ASSERT(!fields_tbl);
+ RUBY_ASSERT(old_capa == 0);
}
+ RUBY_ASSERT(new_capa > 0);
- fields_tbl = gen_fields_tbl_resize(fields_tbl, RSHAPE_CAPACITY(fields_lookup->shape_id));
+ struct gen_fields_tbl *old_fields_tbl = fields_tbl;
+ fields_tbl = xmalloc(gen_fields_tbl_bytes(new_capa));
+ if (old_fields_tbl) {
+ memcpy(fields_tbl, old_fields_tbl, gen_fields_tbl_bytes(old_capa));
+ }
st_insert(tbl, (st_data_t)obj, (st_data_t)fields_tbl);
+ if (old_fields_tbl) {
+ xfree(old_fields_tbl);
+ }
}
if (fields_lookup->shape_id) {
@@ -2371,7 +2381,9 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
return;
}
- new_fields_tbl = gen_fields_tbl_resize(0, RSHAPE_CAPACITY(dest_shape_id));
+ uint32_t dest_capa = RSHAPE_CAPACITY(dest_shape_id);
+ RUBY_ASSERT(dest_capa > 0);
+ new_fields_tbl = xmalloc(gen_fields_tbl_bytes(dest_capa));
VALUE *src_buf = obj_fields_tbl->as.shape.fields;
VALUE *dest_buf = new_fields_tbl->as.shape.fields;
diff --git a/vm.c b/vm.c
index 6f20d43ee4..7b0775fbb3 100644
--- a/vm.c
+++ b/vm.c
@@ -2982,6 +2982,7 @@ rb_vm_update_references(void *ptr)
if (ptr) {
rb_vm_t *vm = ptr;
+ vm->self = rb_gc_location(vm->self);
vm->mark_object_ary = rb_gc_location(vm->mark_object_ary);
vm->load_path = rb_gc_location(vm->load_path);
vm->load_path_snapshot = rb_gc_location(vm->load_path_snapshot);
@@ -3068,6 +3069,8 @@ rb_vm_mark(void *ptr)
rb_gc_mark_maybe(*list->varptr);
}
+ rb_gc_mark_movable(vm->self);
+
if (vm->main_namespace) {
rb_namespace_entry_mark((void *)vm->main_namespace);
}