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
2 changes: 1 addition & 1 deletion .github/workflows/auto_request_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: ${{ github.repository == 'ruby/ruby' && github.base_ref == 'master' }}
steps:
- name: Request review based on files changes and/or groups the author belongs to
uses: necojackarc/auto-request-review@035f049cb68460341ab744f19aa9f31aae685e36 # master
uses: necojackarc/auto-request-review@9a4b11888f2d60c79120c5413f13eb63febc2b68 # master
with:
# scope: public_repo
token: ${{ secrets.MATZBOT_AUTO_REQUEST_REVIEW_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,18 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/ruby/all-ruby/dispatches \
-d '{"event_type": "update"}'

- uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
with:
payload: |
{
"attachments": [{
"title": "Publish Ruby ${{ github.event.client_payload.version || github.event.inputs.version }}",
"title_link": "https://cache.ruby-lang.org/pub/ruby/",
"text": "${{ job.status }}: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }} at ${{ github.event.client_payload.version || github.event.inputs.version }}>",
"color": "${{ job.status == 'success' && 'good' || 'danger' }}"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
if: always()
2 changes: 1 addition & 1 deletion .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
rustup install ${{ matrix.rust_version }} --profile minimal
rustup default ${{ matrix.rust_version }}
- uses: taiki-e/install-action@9534c84618278caac52cb373bb164ed464dbd8af # v2.87.11
- uses: taiki-e/install-action@3f74d7c16a4242f1c95561e98edc25d36adb4375 # v2.87.12
with:
tool: nextest@0.9
if: ${{ matrix.test_task == 'zjit-check' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
ruby-version: '3.1'
bundler: none

- uses: taiki-e/install-action@9534c84618278caac52cb373bb164ed464dbd8af # v2.87.11
- uses: taiki-e/install-action@3f74d7c16a4242f1c95561e98edc25d36adb4375 # v2.87.12
with:
tool: nextest@0.9
if: ${{ matrix.test_task == 'zjit-check' }}
Expand Down
10 changes: 5 additions & 5 deletions ext/socket/ipsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ allocate_fast_fallback_getaddrinfo_shared(int family_size)
}

static void
allocate_fast_fallback_getaddrinfo_hints(struct addrinfo *hints, int family, int remote_addrinfo_hints, int additional_flags)
init_fast_fallback_getaddrinfo_hints(struct addrinfo *hints, int family, int remote_addrinfo_hints, int additional_flags)
{
MEMZERO(hints, struct addrinfo, 1);
hints->ai_family = family;
Expand Down Expand Up @@ -691,7 +691,7 @@ init_fast_fallback_inetsock_internal(VALUE v)

struct addrinfo getaddrinfo_hints[arg->family_size];

allocate_fast_fallback_getaddrinfo_hints(
init_fast_fallback_getaddrinfo_hints(
&getaddrinfo_hints[i],
arg->families[i],
remote_addrinfo_hints,
Expand All @@ -707,18 +707,18 @@ init_fast_fallback_inetsock_internal(VALUE v)
arg->getaddrinfo_entries[i]->test_ecode = 0;

/* for testing HEv2 */
if (!NIL_P(test_mode_settings) && RB_TYPE_P(test_mode_settings, T_HASH)) {
if (RB_TYPE_P(test_mode_settings, T_HASH)) {
const char *family_sym = arg->families[i] == AF_INET6 ? "ipv6" : "ipv4";

VALUE test_delay_setting = rb_hash_aref(test_mode_settings, ID2SYM(rb_intern("delay")));
if (!NIL_P(test_delay_setting)) {
if (RB_TYPE_P(test_delay_setting, T_HASH)) {
VALUE rb_test_delay_ms = rb_hash_aref(test_delay_setting, ID2SYM(rb_intern(family_sym)));
long test_delay_ms = NIL_P(rb_test_delay_ms) ? 0 : NUM2LONG(rb_test_delay_ms);
arg->getaddrinfo_entries[i]->test_sleep_ms = test_delay_ms;
}

VALUE test_error_setting = rb_hash_aref(test_mode_settings, ID2SYM(rb_intern("error")));
if (!NIL_P(test_error_setting)) {
if (RB_TYPE_P(test_error_setting, T_HASH)) {
VALUE rb_test_ecode = rb_hash_aref(test_error_setting, ID2SYM(rb_intern(family_sym)));
if (!NIL_P(rb_test_ecode)) {
arg->getaddrinfo_entries[i]->test_ecode = NUM2INT(rb_test_ecode);
Expand Down
2 changes: 1 addition & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2885,7 +2885,7 @@ rb_file_ctime(VALUE obj)
*
*/

VALUE
static VALUE
rb_file_s_birthtime(VALUE klass, VALUE fname)
{
rb_io_stat_data st;
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/gem_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def sh_with_status(cmd, &block)
Bundler.ui.debug(cmd)
SharedHelpers.chdir(base) do
outbuf = IO.popen(cmd, err: [:child, :out], &:read)
status = $?
status = Process.last_status
block&.call(outbuf) if status.success?
[outbuf, status]
end
Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems/ext/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def self.run(command, results, command_name = nil, dir = Dir.pwd, env = {})

require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess.
# Under Ruby::Box mkmf makes RbConfig.expand recurse until SystemStackError.
# Under Ruby::Box defined?($gvar) does not see assignments made inside the
# box, so mkmf have_devel? never memoizes and recurses until SystemStackError
# (https://bugs.ruby-lang.org/issues/22283).
# Drop $RUBY_BOX last so no caller can restore it.
build_env = { "SOURCE_DATE_EPOCH" => Gem.source_date_epoch_string }.merge(env).merge("RUBY_BOX" => nil)
# A single-element command would be parsed as a shell command line,
Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ def rev_parse # :nodoc:
hash = Gem::Util.popen(git_command, "rev-parse", @reference).strip
end

# Process.last_status instead of $?, which Ruby::Box leaves uninitialized
# (https://bugs.ruby-lang.org/issues/22280)
raise Gem::Exception,
"unable to find reference #{@reference} in #{@repository}" unless
$?.success?
Process.last_status.success?

hash
end
Expand Down
6 changes: 6 additions & 0 deletions spec/bundler/bundler/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@
end

it "executes the hook" do
skip "Ruby::Box ignores $stdout reassignment (https://bugs.ruby-lang.org/issues/21867)" if defined?(Ruby::Box) && Ruby::Box.enabled?

expect do
Plugin.hook(Bundler::Plugin::Events::EVENT1)
end.to output("hook for event 1\n").to_stdout
Expand All @@ -331,6 +333,8 @@
RUBY

it "evals plugins.rb once" do
skip "Ruby::Box ignores $stdout reassignment (https://bugs.ruby-lang.org/issues/21867)" if defined?(Ruby::Box) && Ruby::Box.enabled?

expect do
Plugin.hook(Bundler::Plugin::Events::EVENT1)
Plugin.hook(Bundler::Plugin::Events::EVENT2)
Expand All @@ -344,6 +348,8 @@
RUBY

it "is passed to the hook" do
skip "Ruby::Box ignores $stdout reassignment (https://bugs.ruby-lang.org/issues/21867)" if defined?(Ruby::Box) && Ruby::Box.enabled?

expect do
Plugin.hook(Bundler::Plugin::Events::EVENT1) { puts "win" }
end.to output("win\n").to_stdout
Expand Down
9 changes: 7 additions & 2 deletions spec/bundler/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@

before do
ENV["RUBYOPT"] = "-r#{install_path}/bundler/setup"
allow(File).to receive(:expand_path).and_return("#{install_path}/bundler/setup")
# Only fake the resolution of bundler/setup itself. A blanket stub
# breaks unrelated RubyGems path lookups triggered lazily inside the
# example, see #set_rubyopt.
allow(File).to receive(:expand_path).and_call_original
allow(File).to receive(:expand_path).with("setup", anything).and_return("#{install_path}/bundler/setup")
allow(Gem).to receive(:bin_path).and_return("#{install_path}/bundler/setup")
end

Expand All @@ -403,7 +407,8 @@
let(:install_path) { "/opt/ruby with space/lib" }

before do
allow(File).to receive(:expand_path).and_return("#{install_path}/bundler/setup")
allow(File).to receive(:expand_path).and_call_original
allow(File).to receive(:expand_path).with("setup", anything).and_return("#{install_path}/bundler/setup")
allow(Gem).to receive(:bin_path).and_return("#{install_path}/bundler/setup")
end

Expand Down
4 changes: 4 additions & 0 deletions spec/bundler/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,10 @@ def gem_make_out
end

it "preserves bundled native extensions when BUNDLE_CLEAN removes another gem" do
# The command-line/RUBYOPT -r bypasses gem activation under RUBY_BOX=1
# (https://bugs.ruby-lang.org/issues/22295)
skip "-r cannot activate gems under Ruby::Box" if defined?(Ruby::Box) && Ruby::Box.enabled?

build_repo4 do
build_gem "native_child", "1.0", &:add_c_extension
build_gem "native_parent", "1.0" do |s|
Expand Down
1 change: 1 addition & 0 deletions spec/bundler/install/gemfile/content_addressable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@
RSpec.describe "bundle install with content-addressable gems invisible to pre-4.1 RubyGems clients", :compact_index, rubygems: ">= 4.1.0.a" do
before do
skip "Gem::ContentAddress not available" if ruby_core?
skip "A prerelease Ruby does not satisfy the ~> X.Y.0 ABI pin of content-addressed gems" if Gem.ruby_version.prerelease?
end

let(:current_abi) { "#{Gem.ruby_version.segments[0]}.#{Gem.ruby_version.segments[1]}" }
Expand Down
12 changes: 6 additions & 6 deletions spec/bundler/runtime/env_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ def run_bundler_script(env, script)
create_file("source.rb", <<-'RUBY')
Bundler.original_system("ruby", "-e", "exit(42) if ENV['BUNDLE_FOO'] == 'bar'")

exit $?.exitstatus
exit Process.last_status.exitstatus
RUBY
end

it "runs system inside with_original_env" do
run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
expect(Process.last_status.exitstatus).to eq(42)
end
end

Expand All @@ -182,13 +182,13 @@ def run_bundler_script(env, script)
create_file("source.rb", <<-'RUBY')
Bundler.unbundled_system("ruby", "-e", "exit(42) unless ENV['BUNDLE_FOO'] == 'bar'")

exit $?.exitstatus
exit Process.last_status.exitstatus
RUBY
end

it "runs system inside with_unbundled_env" do
run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(42)
expect(Process.last_status.exitstatus).to eq(42)
end
end

Expand All @@ -209,7 +209,7 @@ def run_bundler_script(env, script)
skip "Fork not implemented" if Gem.win_platform?

run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(0)
expect(Process.last_status.exitstatus).to eq(0)
end
end

Expand All @@ -230,7 +230,7 @@ def run_bundler_script(env, script)
skip "Fork not implemented" if Gem.win_platform?

run_bundler_script({ "BUNDLE_FOO" => "bar" }, bundled_app("source.rb"))
expect($?.exitstatus).to eq(1)
expect(Process.last_status.exitstatus).to eq(1)
end
end
end
15 changes: 14 additions & 1 deletion spec/bundler/support/command_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

module Spec
class CommandExecution
# Under RUBY_BOX, every spawned ruby prints an experimental warning to
# stderr, breaking specs that assert clean stderr.
RUBY_BOX_WARNING = Regexp.union(
/^[^\n]*: warning: Ruby::Box is experimental, and the behavior may change in the future!\n?/,
%r{^See https://docs\.ruby-lang\.org/\S+ for known issues, etc\.\n?}
)

def initialize(command, timeout:)
@command = command
@timeout = timeout
Expand Down Expand Up @@ -72,7 +79,13 @@ def failure?
attr_reader :failure_reason

def normalize(string)
string.dup.force_encoding(Encoding::UTF_8).scrub.strip.gsub("\r\n", "\n")
string = string.dup.force_encoding(Encoding::UTF_8).scrub.gsub("\r\n", "\n")
string = string.gsub(RUBY_BOX_WARNING, "") if ruby_box_enabled?
string.strip
end

def ruby_box_enabled?
defined?(Ruby::Box) && Ruby::Box.enabled?
end
end
end
21 changes: 21 additions & 0 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ def setup
ENV["BUNDLE_COOLDOWN"] = nil
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "true"

# Child ruby processes inherit RUBY_BOX and print an experimental
# warning on startup, breaking assertions on subprocess stderr.
ENV["RUBYOPT"] = [ENV["RUBYOPT"], "-W:no-experimental"].compact.join(" ") if ruby_box_enabled?

@current_dir = Dir.pwd
@fetcher = nil

Expand Down Expand Up @@ -1440,6 +1444,23 @@ def ruby_repo?
!ENV["GEM_COMMAND"].nil?
end

##
# Is this test running under Ruby::Box (RUBY_BOX=1)?

def ruby_box_enabled?
defined?(Ruby::Box) && Ruby::Box.enabled?
end

##
# Ruby::Box gives each box detached copies of the stdio globals, so
# reassigning $stdout/$stderr cannot capture output written by Kernel#warn,
# Kernel#puts or subprocesses. Pends until the ruby-core fix for
# https://bugs.ruby-lang.org/issues/21867 lands.

def pend_for_ruby_box_stdio_capture
pend "Ruby::Box breaks $stdout/$stderr capture (https://bugs.ruby-lang.org/issues/21867)" if ruby_box_enabled?
end

##
# Returns the make command for the current platform. For versions of Ruby
# built on MS Windows with VC++ or Borland it will return 'nmake'. On all
Expand Down
3 changes: 3 additions & 0 deletions test/rubygems/test_deprecate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_deprecated_method_calls_the_old_method
end

def test_deprecated_method_outputs_a_warning
pend_for_ruby_box_stdio_capture
out, err = capture_output do
thing = Thing.new
thing.foo
Expand Down Expand Up @@ -165,6 +166,7 @@ def execute
end

def test_deprecated_method_outputs_a_warning_old_way
pend_for_ruby_box_stdio_capture
out, err = capture_output do
thing = OtherThing.new
thing.foo
Expand All @@ -180,6 +182,7 @@ def test_deprecated_method_outputs_a_warning_old_way
end

def test_deprecated_method_when_class_overrides_format
pend_for_ruby_box_stdio_capture
out, err = capture_output do
thing = ThingWithFormat.new
thing.foo
Expand Down
3 changes: 2 additions & 1 deletion test/rubygems/test_exit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
class TestGemExit < Gem::TestCase
def test_exit
system(*ruby_with_rubygems_in_load_path, "-e", "raise Gem::SystemExitException.new(2)")
assert_equal 2, $?.exitstatus
# Process.last_status instead of $?, which Ruby::Box leaves uninitialized
assert_equal 2, Process.last_status.exitstatus
end

def test_status
Expand Down
2 changes: 2 additions & 0 deletions test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ def test_self_try_activate_missing_prerelease
end

def test_self_try_activate_missing_extensions
pend_for_ruby_box_stdio_capture
spec = util_spec "ext", "1" do |s|
s.extensions = %w[ext/extconf.rb]
s.installed_by_version = v("2.2")
Expand Down Expand Up @@ -1352,6 +1353,7 @@ def test_setting_paths_does_not_mutate_parameter_object
end

def test_deprecated_paths=
pend_for_ruby_box_stdio_capture
stdout, stderr = capture_output do
Gem.paths = { "GEM_HOME" => Gem.paths.home,
"GEM_PATH" => [Gem.paths.home, "foo"] }
Expand Down
1 change: 1 addition & 0 deletions test/rubygems/test_gem_commands_build_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def test_execute_strict_with_warnings
end

def test_execute_bad_spec
pend_for_ruby_box_stdio_capture
@gem.date = "2010-11-08"

gemspec_file = File.join(@tempdir, @gem.spec_name)
Expand Down
1 change: 1 addition & 0 deletions test/rubygems/test_gem_commands_open_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def gem(name, version = "1.0")
end

def test_execute
pend_for_ruby_box_stdio_capture
omit "JRuby on Windows spawns the editor with a different cwd" if Gem.win_platform? && Gem.java_platform?

@cmd.options[:args] = %w[foo]
Expand Down
1 change: 1 addition & 0 deletions test/rubygems/test_gem_config_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def test_handle_arguments_backtrace
end

def test_handle_arguments_debug
pend_for_ruby_box_stdio_capture
assert_equal false, $DEBUG

args = %w[--debug]
Expand Down
Loading