diff options
-rw-r--r-- | actionmailbox/lib/action_mailbox/test_helper.rb | 12 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 | ||||
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 1 | ||||
-rw-r--r-- | railties/Rakefile | 41 | ||||
-rw-r--r-- | railties/test/application/zeitwerk_integration_test.rb | 1 |
6 files changed, 51 insertions, 15 deletions
diff --git a/actionmailbox/lib/action_mailbox/test_helper.rb b/actionmailbox/lib/action_mailbox/test_helper.rb index 0ec9152844..d248fa8734 100644 --- a/actionmailbox/lib/action_mailbox/test_helper.rb +++ b/actionmailbox/lib/action_mailbox/test_helper.rb @@ -29,16 +29,16 @@ module ActionMailbox create_inbound_email_from_fixture(*args).tap(&:route) end - # Create an +InboundEmail+ from fixture using the same arguments as +create_inbound_email_from_mail+ - # and immediately route it to processing. + # Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_mail+ and immediately route it to + # processing. def receive_inbound_email_from_mail(**kwargs) create_inbound_email_from_mail(**kwargs).tap(&:route) end - # Create an +InboundEmail+ from fixture using the same arguments as +create_inbound_email_from_source+ - # and immediately route it to processing. - def receive_inbound_email_from_source(**kwargs) - create_inbound_email_from_source(**kwargs).tap(&:route) + # Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_source+ and immediately route it + # to processing. + def receive_inbound_email_from_source(*args) + create_inbound_email_from_source(*args).tap(&:route) end end end diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 2ba3e3f4a3..91318a0af1 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -422,7 +422,7 @@ module ActiveRecord } # Returns the version of the connected PostgreSQL server. - def get_database_version + def get_database_version # :nodoc: @connection.server_version end alias :postgresql_version :database_version diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 7ea18c3069..90b5e9a118 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -252,9 +252,6 @@ module ActiveRecord def _select!(*fields) # :nodoc: fields.reject!(&:blank?) fields.flatten! - fields.map! do |field| - klass.attribute_alias?(field) ? klass.attribute_alias(field).to_sym : field - end self.select_values += fields self end @@ -1164,9 +1161,9 @@ module ActiveRecord case field when Symbol field = field.to_s - arel_column(field) { connection.quote_table_name(field) } + arel_column(field, &connection.method(:quote_table_name)) when String - arel_column(field) { field } + arel_column(field, &:itself) when Proc field.call else @@ -1182,7 +1179,7 @@ module ActiveRecord if klass.columns_hash.key?(field) && (!from || table_name_matches?(from)) arel_attribute(field) else - yield + yield field end end diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 90b208092f..3f370e5ede 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -292,6 +292,7 @@ module ActiveRecord klass.create!(description: "foo") assert_equal ["foo"], klass.select(:description).from(klass.all).map(&:desc) + assert_equal ["foo"], klass.reselect(:description).from(klass.all).map(&:desc) end def test_relation_merging_with_merged_joins_as_strings diff --git a/railties/Rakefile b/railties/Rakefile index 4ae546b202..0f305ea332 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -11,6 +11,33 @@ task test: "test:isolated" namespace :test do task :isolated do + estimated_duration = { + "test/application/test_runner_test.rb" => 201, + "test/application/assets_test.rb" => 131, + "test/application/rake/migrations_test.rb" => 65, + "test/generators/scaffold_generator_test.rb" => 57, + "test/generators/plugin_test_runner_test.rb" => 57, + "test/application/test_test.rb" => 52, + "test/application/configuration_test.rb" => 49, + "test/generators/app_generator_test.rb" => 43, + "test/application/rake/dbs_test.rb" => 43, + "test/application/rake_test.rb" => 33, + "test/generators/plugin_generator_test.rb" => 30, + "test/railties/engine_test.rb" => 27, + "test/generators/scaffold_controller_generator_test.rb" => 23, + "test/railties/generators_test.rb" => 19, + "test/application/console_test.rb" => 16, + "test/engine/commands_test.rb" => 15, + "test/application/routing_test.rb" => 15, + "test/application/mailer_previews_test.rb" => 15, + "test/application/rake/multi_dbs_test.rb" => 13, + "test/application/asset_debugging_test.rb" => 12, + "test/application/bin_setup_test.rb" => 11, + "test/engine/test_test.rb" => 10, + "test/application/runner_test.rb" => 10, + } + estimated_duration.default = 1 + dash_i = [ "test", "lib", @@ -39,13 +66,23 @@ namespace :test do test_patterns = dirs.map { |dir| "test/#{dir}/*_test.rb" } test_files = Dir[*test_patterns].select do |file| !file.start_with?("test/fixtures/") && !file.start_with?("test/isolation/assets/") - end.sort + end if ENV["BUILDKITE_PARALLEL_JOB_COUNT"] n = ENV["BUILDKITE_PARALLEL_JOB"].to_i m = ENV["BUILDKITE_PARALLEL_JOB_COUNT"].to_i - test_files = test_files.each_slice(m).map { |slice| slice[n] }.compact + buckets = Array.new(m) { [] } + allocations = Array.new(m) { 0 } + test_files.sort_by { |file| [-estimated_duration[file], file] }.each do |file| + idx = allocations.index(allocations.min) + buckets[idx] << file + allocations[idx] += estimated_duration[file] + end + + puts "Running #{buckets[n].size} of #{test_files.size} test files, estimated duration #{allocations[n]}s" + + test_files = buckets[n] end test_files.each do |file| diff --git a/railties/test/application/zeitwerk_integration_test.rb b/railties/test/application/zeitwerk_integration_test.rb index b461d82450..b248459e47 100644 --- a/railties/test/application/zeitwerk_integration_test.rb +++ b/railties/test/application/zeitwerk_integration_test.rb @@ -365,6 +365,7 @@ class ZeitwerkIntegrationTest < ActiveSupport::TestCase ensure Object.send(:remove_const, :ZeitwerkDTIntegrationTestRoot) Object.send(:remove_const, :ZeitwerkDTIntegrationTestChild) + Object.send(:remove_const, :ZeitwerkDTIntegrationTestGrandchild) end end end |