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: 2 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
[![Travis Status](https://app.travis-ci.com/ruby/ruby.svg?branch=master)](https://app.travis-ci.com/ruby/ruby)

[English](rdoc-ref:README.md)

# Rubyとは

Rubyはシンプルかつ強力なオブジェクト指向スクリプト言語です. Rubyは純粋なオブジェクト指向言語として設計されているので,
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
[![Travis Status](https://app.travis-ci.com/ruby/ruby.svg?branch=master)](https://app.travis-ci.com/ruby/ruby)

[日本語](rdoc-ref:README.ja.md)

# What is Ruby?

Ruby is an interpreted object-oriented programming language often
Expand Down
36 changes: 36 additions & 0 deletions bootstraptest/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2413,3 +2413,39 @@ def call_test(obj)
:ok
end
RUBY

# When creating bmethods in Ractors, they should only be usable from their
# defining ractor, even if it is GC'd
assert_equal 'ok', <<~'RUBY'
CLASSES = 1000.times.map { Class.new }.freeze

# This would be better to run in parallel, but there's a bug with lambda
# creation and YJIT causing crashes in dev mode
ractors = CLASSES.map do |klass|
Ractor.new(klass) do |klass|
Ractor.receive
klass.define_method(:foo) {}
end
end

ractors.each do |ractor|
ractor << nil
ractor.join
end

ractors.clear
GC.start

any = 1000.times.map do
Ractor.new do
CLASSES.any? do |klass|
begin
klass.new.foo
true
rescue RuntimeError
false
end
end
end
end.map(&:value).none? && :ok
RUBY
6 changes: 4 additions & 2 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,10 @@ class_detach_subclasses(VALUE klass, VALUE arg)
static void
class_switch_superclass(VALUE super, VALUE klass)
{
class_detach_subclasses(klass, Qnil);
rb_class_subclass_add(super, klass);
RB_VM_LOCKING() {
class_detach_subclasses(klass, Qnil);
rb_class_subclass_add(super, klass);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion method.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ typedef struct rb_method_refined_struct {
typedef struct rb_method_bmethod_struct {
VALUE proc; /* should be marked */
struct rb_hook_list_struct *hooks;
VALUE defined_ractor;
rb_serial_t defined_ractor_id;
} rb_method_bmethod_t;

enum method_optimized_type {
Expand Down
17 changes: 17 additions & 0 deletions spec/bundler/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
require_relative "support/matchers"
require_relative "support/permissions"
require_relative "support/platforms"
require_relative "support/windows_tag_group"

$debug = false

Expand All @@ -56,6 +57,7 @@ def self.ruby=(ruby)
config.include Spec::Path
config.include Spec::Platforms
config.include Spec::Permissions
config.include Spec::WindowsTagGroup

# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
Expand Down Expand Up @@ -129,4 +131,19 @@ def self.ruby=(ruby)
ensure
reset!
end

Spec::WindowsTagGroup::EXAMPLE_MAPPINGS.each do |tag, file_paths|
file_pattern = Regexp.union(file_paths.map {|path| Regexp.new(Regexp.escape(path) + "$") })

config.define_derived_metadata(file_path: file_pattern) do |metadata|
metadata[tag] = true
end
end

config.before(:context) do |example|
metadata = example.class.metadata
if metadata[:type] != :aruba && metadata.keys.none? {|k| Spec::WindowsTagGroup::EXAMPLE_MAPPINGS.keys.include?(k) }
warn "#{metadata[:file_path]} is not assigned to any Windows runner group. see spec/support/windows_tag_group.rb for details."
end
end
end
190 changes: 190 additions & 0 deletions spec/bundler/support/windows_tag_group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# frozen_string_literal: true

# This group classifies test files into 4 groups by running `bin/rspec --profile 10000`
# to ensure balanced execution times. When adding new test files, it is recommended to
# re-aggregate and adjust the groups to keep them balanced.
# For now, please add new files to group 'windows_d'.

module Spec
module WindowsTagGroup
EXAMPLE_MAPPINGS = {
windows_a: [
"spec/runtime/setup_spec.rb",
"spec/commands/install_spec.rb",
"spec/commands/add_spec.rb",
"spec/install/gems/compact_index_spec.rb",
"spec/commands/config_spec.rb",
"spec/commands/pristine_spec.rb",
"spec/install/gemfile/path_spec.rb",
"spec/update/git_spec.rb",
"spec/commands/open_spec.rb",
"spec/commands/remove_spec.rb",
"spec/commands/show_spec.rb",
"spec/plugins/source/example_spec.rb",
"spec/commands/console_spec.rb",
"spec/runtime/require_spec.rb",
"spec/runtime/env_helpers_spec.rb",
"spec/runtime/gem_tasks_spec.rb",
"spec/install/gemfile_spec.rb",
"spec/commands/fund_spec.rb",
"spec/commands/init_spec.rb",
"spec/bundler/ruby_dsl_spec.rb",
"spec/bundler/mirror_spec.rb",
"spec/bundler/source/git/git_proxy_spec.rb",
"spec/bundler/source_list_spec.rb",
"spec/bundler/plugin/installer_spec.rb",
"spec/bundler/friendly_errors_spec.rb",
"spec/resolver/platform_spec.rb",
"spec/bundler/fetcher/downloader_spec.rb",
"spec/update/force_spec.rb",
"spec/bundler/env_spec.rb",
"spec/install/gems/mirror_spec.rb",
"spec/install/failure_spec.rb",
"spec/bundler/yaml_serializer_spec.rb",
"spec/bundler/environment_preserver_spec.rb",
"spec/install/gemfile/install_if_spec.rb",
"spec/install/gems/gemfile_source_header_spec.rb",
"spec/bundler/fetcher/base_spec.rb",
"spec/bundler/rubygems_integration_spec.rb",
"spec/bundler/worker_spec.rb",
"spec/bundler/dependency_spec.rb",
"spec/bundler/ui_spec.rb",
"spec/bundler/plugin/source_list_spec.rb",
"spec/bundler/source/path_spec.rb",
],
windows_b: [
"spec/install/gemfile/git_spec.rb",
"spec/install/gems/standalone_spec.rb",
"spec/commands/lock_spec.rb",
"spec/cache/gems_spec.rb",
"spec/other/major_deprecation_spec.rb",
"spec/install/gems/dependency_api_spec.rb",
"spec/install/gemfile/gemspec_spec.rb",
"spec/plugins/install_spec.rb",
"spec/commands/binstubs_spec.rb",
"spec/install/gems/flex_spec.rb",
"spec/runtime/inline_spec.rb",
"spec/commands/post_bundle_message_spec.rb",
"spec/runtime/executable_spec.rb",
"spec/lock/git_spec.rb",
"spec/plugins/hook_spec.rb",
"spec/install/allow_offline_install_spec.rb",
"spec/install/gems/post_install_spec.rb",
"spec/install/gemfile/ruby_spec.rb",
"spec/install/security_policy_spec.rb",
"spec/install/yanked_spec.rb",
"spec/update/gemfile_spec.rb",
"spec/runtime/load_spec.rb",
"spec/plugins/command_spec.rb",
"spec/commands/version_spec.rb",
"spec/install/prereleases_spec.rb",
"spec/bundler/uri_credentials_filter_spec.rb",
"spec/bundler/plugin_spec.rb",
"spec/install/gems/mirror_probe_spec.rb",
"spec/plugins/list_spec.rb",
"spec/bundler/compact_index_client/parser_spec.rb",
"spec/bundler/gem_version_promoter_spec.rb",
"spec/other/cli_dispatch_spec.rb",
"spec/bundler/source/rubygems_spec.rb",
"spec/cache/platform_spec.rb",
"spec/update/gems/fund_spec.rb",
"spec/bundler/stub_specification_spec.rb",
"spec/bundler/retry_spec.rb",
"spec/bundler/installer/spec_installation_spec.rb",
"spec/bundler/spec_set_spec.rb",
"spec/quality_es_spec.rb",
"spec/bundler/index_spec.rb",
"spec/other/cli_man_pages_spec.rb",
],
windows_c: [
"spec/commands/newgem_spec.rb",
"spec/commands/exec_spec.rb",
"spec/commands/clean_spec.rb",
"spec/commands/platform_spec.rb",
"spec/cache/git_spec.rb",
"spec/install/gemfile/groups_spec.rb",
"spec/commands/cache_spec.rb",
"spec/commands/check_spec.rb",
"spec/commands/list_spec.rb",
"spec/install/path_spec.rb",
"spec/bundler/cli_spec.rb",
"spec/install/bundler_spec.rb",
"spec/install/git_spec.rb",
"spec/commands/doctor_spec.rb",
"spec/bundler/dsl_spec.rb",
"spec/install/gems/fund_spec.rb",
"spec/install/gems/env_spec.rb",
"spec/bundler/ruby_version_spec.rb",
"spec/bundler/definition_spec.rb",
"spec/install/gemfile/eval_gemfile_spec.rb",
"spec/plugins/source_spec.rb",
"spec/install/gems/dependency_api_fallback_spec.rb",
"spec/plugins/uninstall_spec.rb",
"spec/bundler/plugin/index_spec.rb",
"spec/bundler/bundler_spec.rb",
"spec/bundler/fetcher_spec.rb",
"spec/bundler/source/rubygems/remote_spec.rb",
"spec/bundler/lockfile_parser_spec.rb",
"spec/cache/cache_path_spec.rb",
"spec/bundler/source/git_spec.rb",
"spec/bundler/source_spec.rb",
"spec/commands/ssl_spec.rb",
"spec/bundler/fetcher/compact_index_spec.rb",
"spec/bundler/plugin/api_spec.rb",
"spec/bundler/endpoint_specification_spec.rb",
"spec/bundler/fetcher/index_spec.rb",
"spec/bundler/settings/validator_spec.rb",
"spec/bundler/build_metadata_spec.rb",
"spec/bundler/current_ruby_spec.rb",
"spec/bundler/installer/gem_installer_spec.rb",
"spec/bundler/cli_common_spec.rb",
"spec/bundler/ci_detector_spec.rb",
],
windows_d: [
"spec/commands/outdated_spec.rb",
"spec/commands/update_spec.rb",
"spec/lock/lockfile_spec.rb",
"spec/install/deploy_spec.rb",
"spec/install/gemfile/sources_spec.rb",
"spec/runtime/self_management_spec.rb",
"spec/install/gemfile/specific_platform_spec.rb",
"spec/commands/info_spec.rb",
"spec/install/gems/resolving_spec.rb",
"spec/install/gemfile/platform_spec.rb",
"spec/bundler/gem_helper_spec.rb",
"spec/install/global_cache_spec.rb",
"spec/runtime/platform_spec.rb",
"spec/update/gems/post_install_spec.rb",
"spec/install/gems/native_extensions_spec.rb",
"spec/install/force_spec.rb",
"spec/cache/path_spec.rb",
"spec/install/gemspecs_spec.rb",
"spec/commands/help_spec.rb",
"spec/bundler/shared_helpers_spec.rb",
"spec/bundler/settings_spec.rb",
"spec/resolver/basic_spec.rb",
"spec/install/gemfile/force_ruby_platform_spec.rb",
"spec/commands/licenses_spec.rb",
"spec/install/gemfile/lockfile_spec.rb",
"spec/bundler/fetcher/dependency_spec.rb",
"spec/quality_spec.rb",
"spec/bundler/remote_specification_spec.rb",
"spec/install/process_lock_spec.rb",
"spec/install/binstubs_spec.rb",
"spec/bundler/compact_index_client/updater_spec.rb",
"spec/bundler/ui/shell_spec.rb",
"spec/other/ext_spec.rb",
"spec/commands/issue_spec.rb",
"spec/update/path_spec.rb",
"spec/bundler/plugin/api/source_spec.rb",
"spec/install/gems/win32_spec.rb",
"spec/bundler/plugin/dsl_spec.rb",
"spec/runtime/requiring_spec.rb",
"spec/bundler/plugin/events_spec.rb",
"spec/bundler/resolver/candidate_spec.rb",
"spec/bundler/digest_spec.rb",
"spec/bundler/fetcher/gem_remote_fetcher_spec.rb",
],
}.freeze
end
end
13 changes: 13 additions & 0 deletions test/ruby/test_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -917,4 +917,17 @@ class T
end
end;
end

def test_safe_multi_ractor_subclasses_list_mutation
assert_ractor "#{<<~"begin;"}\n#{<<~'end;'}"
begin;
4.times.map do
Ractor.new do
20_000.times do
Object.new.singleton_class
end
end
end.each(&:join)
end;
end
end
Loading